Skip to content

Commit 308849a

Browse files
committed
first stable version
1 parent 08f904b commit 308849a

File tree

9 files changed

+391
-2
lines changed

9 files changed

+391
-2
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/bower_components
2+
/.idea/
3+
/.codekit-cache/
4+
/config.codekit
5+
/node_modules

Gruntfile.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = function(grunt) {
2+
3+
grunt.initConfig({
4+
pkg: grunt.file.readJSON('package.json'),
5+
uglify: {
6+
js: {
7+
files : {
8+
'dist/angular-openweathermap-api-factory.min.js' : ['src/angular-openweathermap-api-factory.js']
9+
}
10+
},
11+
options: {
12+
banner: '\n/*! <%= pkg.name %> v<%= pkg.version %> (<%= grunt.template.today("dd-mm-yyyy") %>) by <%= pkg.author %> */\n',
13+
}
14+
},
15+
watch: {
16+
minifiyJs: {
17+
files: [
18+
'src/angular-openweathermap-api-factory.js'
19+
],
20+
tasks: ['uglify'],
21+
options: {
22+
spawn: true,
23+
},
24+
},
25+
},
26+
});
27+
28+
grunt.loadNpmTasks('grunt-contrib-uglify');
29+
grunt.loadNpmTasks('grunt-contrib-watch');
30+
31+
grunt.registerTask('default', ['watch']);
32+
33+
};

README.md

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,106 @@
1-
# angular-openweathermap-api-factory
2-
AngularJS Factory for OpenWeatherMap JSON REST API requests
1+
**angular-openweathermap-api-factory** is an angularjs module with a openweathermap api factory.
2+
3+
Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
4+
5+
## Usage
6+
7+
1. Install via [bower](http://bower.io/) :
8+
1. `bower install --save angular-openweathermap-api-factory`
9+
2. Add `jtt_openweathermap` to your application's module dependencies.
10+
3. Include dependencies in your HTML.
11+
1. When using bower:
12+
13+
```html
14+
<script src="bower_components/angular/angular.js"></script>
15+
<script src="bower_components/angular-openweathermap-api-factory/src/angular-openweathermap-api-factory.js"></script>
16+
```
17+
18+
4. Use the factory `openweathermapFactory`.
19+
20+
21+
### factory methods
22+
23+
#### weather from city by name
24+
```js
25+
// docs: http://openweathermap.org/current#name
26+
openweathermapFactory.getWeatherFromCitySearchByName({
27+
q:"<CITY_NAME>,<COUNTRY_CODE>", //city name and country code divided by comma, use ISO 3166 country codes eg "London,uk"
28+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
29+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
30+
type:"<TYPE>", // (optional) 'like' = close result, 'accurate' = accurate result
31+
appid:"<APP_ID>"
32+
}).success(function(_data){
33+
//on success
34+
}).error(function (_data) {
35+
//on error
36+
});
37+
```
38+
39+
#### weather from city by id
40+
```js
41+
// docs: http://openweathermap.org/current#cityid
42+
openweathermapFactory.getWeatherFromCityById({
43+
id:"<CITY_ID>", //List of city ID can be downloaded here http://bulk.openweathermap.org/sample/city.list.json.gz
44+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
45+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
46+
appid:"<APP_ID>"
47+
}).success(function(_data){
48+
//on success
49+
}).error(function (_data) {
50+
//on error
51+
});
52+
```
53+
54+
#### weather from group of cities by id
55+
```js
56+
// docs: http://openweathermap.org/current#severalid
57+
openweathermapFactory.getWeatherFromGroupOfCitiesById({
58+
id:"<CITY_ID>,<CITY_ID>,<CITY_ID>,...", //List of city ID can be downloaded here http://bulk.openweathermap.org/sample/city.list.json.gz
59+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
60+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
61+
appid:"<APP_ID>"
62+
}).success(function(_data){
63+
//on success
64+
}).error(function (_data) {
65+
//on error
66+
});
67+
```
68+
69+
#### weather from location by coordinates
70+
```js
71+
// docs: http://openweathermap.org/current#geo
72+
openweathermapFactory.getWeatherFromLocationByCoordinates({
73+
lat:"<LAT>",
74+
lon:"<LONG>",
75+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
76+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
77+
appid:"<APP_ID>"
78+
}).success(function(_data){
79+
//on success
80+
}).error(function (_data) {
81+
//on error
82+
});
83+
```
84+
85+
#### weather from location by zipcode
86+
```js
87+
// docs: http://openweathermap.org/current#zip
88+
openweathermapFactory.getWeatherFromLocationByCoordinates({
89+
zip:"<ZIPCODE>,<COUNTRY_CODE>", //use ISO 3166 country codes
90+
lang:"<LANGUAGE>", // http://openweathermap.org/current#multi
91+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
92+
appid:"<APP_ID>"
93+
}).success(function(_data){
94+
//on success
95+
}).error(function (_data) {
96+
//on error
97+
});
98+
```
99+
100+
## OpenWeatherMap JSON API
101+
102+
* docs: http://openweathermap.org/api
103+
104+
## License
105+
106+
MIT

bower.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "angular-openweathermap-api-factory",
3+
"description": "angularjs factory for openweathermap json rest api requests",
4+
"version": "0.1.0",
5+
"main": "Gruntfile.js",
6+
"authors": [
7+
"Jonathan Hornung"
8+
],
9+
"license": "MIT",
10+
"keywords": [
11+
"angularjs",
12+
"angular",
13+
"openweathermap",
14+
"api",
15+
"factory"
16+
],
17+
"homepage": "https://openweathermap.com/JohnnyTheTank/angular-openweathermap-api-factory",
18+
"moduleType": [
19+
"globals"
20+
],
21+
"ignore": [
22+
"**/.*",
23+
"node_modules",
24+
"bower_components",
25+
"test",
26+
"tests"
27+
],
28+
"dependencies": {
29+
"angular": "*"
30+
}
31+
}

demo/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html lang="de">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>angular-openweathermap-api-factory</title>
6+
7+
<script src="../bower_components/angular/angular.min.js"></script>
8+
<script src="js/app.js"></script>
9+
<script src="../src/angular-openweathermap-api-factory.js"></script>
10+
11+
</head>
12+
<body ng-app="app">
13+
<div ng-controller="controller">
14+
Look in your console
15+
</div>
16+
17+
</body>
18+
</html>

demo/js/app.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var app = angular.module("app", ['jtt_openweathermap']);
2+
app.controller('controller', ['$scope', 'openweathermapFactory', function($scope, openweathermapFactory) {
3+
4+
var _appid = "<YOUR_OPENWEATHERMAP_APP_ID";
5+
6+
openweathermapFactory.getWeatherFromCitySearchByName({
7+
q:"munich",
8+
appid:_appid
9+
}).success(function(_data){
10+
console.info("weather from city by name", _data);
11+
});
12+
13+
openweathermapFactory.getWeatherFromCityById({
14+
id:"3220838",
15+
appid:_appid
16+
}).success(function(_data){
17+
console.info("weather from city by id", _data);
18+
});
19+
20+
openweathermapFactory.getWeatherFromGroupOfCitiesById({
21+
id:"3220838,524901",
22+
appid:_appid
23+
}).success(function(_data){
24+
console.info("weather from group of cities by id", _data);
25+
});
26+
27+
openweathermapFactory.getWeatherFromLocationByCoordinates({
28+
lat:"48.1",
29+
lon:"11.63",
30+
appid:_appid
31+
}).success(function(_data){
32+
console.info("weather from location by coordinates", _data);
33+
});
34+
35+
openweathermapFactory.getWeatherFromLocationByZipcode({
36+
zip:"81539,de",
37+
appid:_appid
38+
}).success(function(_data){
39+
console.info("weather from location by zipcode", _data);
40+
});
41+
42+
}]);

dist/angular-openweathermap-api-factory.min.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "angular-openweathermap-api-factory",
3+
"version": "0.1.0",
4+
"description": "angularjs factory for openweathermap json rest api requests",
5+
"main": "Gruntfile.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/JohnnyTheTank/angular-openweathermap-api-factory.git"
12+
},
13+
"keywords": [
14+
"angularjs",
15+
"angular",
16+
"openweathermap",
17+
"api",
18+
"factory"
19+
],
20+
"author": "Jonathan Hornung",
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/JohnnyTheTank/angular-openweathermap-api-factory/issues"
24+
},
25+
"homepage": "https://github.com/JohnnyTheTank/angular-openweathermap-api-factory#readme",
26+
"devDependencies": {
27+
"grunt": "^0.4.5",
28+
"grunt-contrib-uglify": "^0.11.0",
29+
"grunt-contrib-watch": "^0.6.1"
30+
}
31+
}

0 commit comments

Comments
 (0)