1
- this . title = "Welcome to bvg webservice!" ;
1
+ this . title = "Welcome to the inofficial bvg webservice!" ;
2
2
this . name = "bvg api module" ;
3
3
this . version = "0.0.1" ;
4
4
this . endpoint = "http://bvg-api.herokuapp.com" ;
@@ -8,6 +8,7 @@ var util = require('util'),
8
8
jjw = require ( 'jjw' ) ;
9
9
10
10
// you can pass an object -- will return an object with the results matching these keys
11
+ /*
11
12
var scrapers = {
12
13
stations: function($) {
13
14
var arr = []
@@ -17,6 +18,7 @@ var scrapers = {
17
18
return arr;
18
19
}
19
20
};
21
+ */
20
22
21
23
exports . stations = function ( options , callback ) {
22
24
//http://mobil.bvg.de/IstAbfahrtzeiten/index/mobil?input=Stromstr.+%28Berlin%29
@@ -44,26 +46,34 @@ exports.stations = function(options, callback){
44
46
} ) ;
45
47
return arr ;
46
48
} ,
47
- departures : function ( $ ) {
49
+ stations : function ( $ ) {
50
+ /*
48
51
var obj = {};
49
52
obj.results = [];
50
53
obj.status = "";
54
+ */
55
+ var stations = [ ] ;
51
56
$ ( '.ivu_result_box' ) . each ( function ( ) {
52
- if ( $ ( this ) . attr ( 'id' ) == 'ivuStreckeninfos' ) {
53
- obj . status = $ . trim ( $ ( this ) . text ( ) ) ;
54
- } else {
57
+ if ( $ ( this ) . attr ( 'id' ) != 'ivuStreckeninfos' ) {
55
58
$ ( this ) . find ( '.ivu_table' ) . each ( function ( ) {
59
+ var station = { } ;
60
+ stations . push ( station ) ;
61
+ station . id = $ ( this ) . find ( 'thead tr th' ) . text ( ) . match ( / M a s t : [ \s ] * ( \w * ) / ) [ 1 ] ;
62
+ station . departures = [ ] ;
56
63
$ ( this ) . find ( 'tbody tr' ) . each ( function ( ) {
57
64
var departure = { } ;
58
- departure . time = $ . trim ( $ ( this ) . find ( '.ivu_table_c_dep' ) . text ( ) ) ;
65
+ departure . time = $ ( this ) . find ( '.ivu_table_c_dep' ) . text ( ) . replace ( / \s / g , "" ) ;
59
66
departure . line = $ . trim ( $ ( this ) . find ( '.ivu_table_c_line' ) . text ( ) ) ;
60
67
departure . direction = $ . trim ( $ ( this ) . find ( '.catlink' ) . text ( ) ) ;
61
- obj . results . push ( departure ) ;
68
+ station . departures . push ( departure ) ;
62
69
} ) ;
70
+
63
71
} ) ;
72
+ } else {
73
+ //obj.status = $.trim($(this).text());
64
74
}
65
75
} ) ;
66
- return obj ;
76
+ return stations ;
67
77
}
68
78
} ;
69
79
@@ -84,15 +94,4 @@ exports.stations.schema = {
84
94
type : 'string' ,
85
95
optional : false
86
96
}
87
- }
88
-
89
- exports . departures = function ( options , callback ) {
90
- callback ( null , options . input ) ;
91
- } ;
92
- exports . departures . description = "this is the echo method, it echos back your msg" ;
93
- exports . departures . schema = {
94
- input : {
95
- type : 'string' ,
96
- optional : false
97
- }
98
- } ;
97
+ }
0 commit comments