1
+
2
+ var geocode = false ;
1
3
var reactiveApp = Ractive . extend ( {
2
4
oninit : function ( ) {
5
+
3
6
console . log ( 'reactiveApp oninit' ) ;
4
- procent = 0.30 ;
5
- if ( location . hash . replace ( '#' , '' ) . split ( '-' ) [ 0 ] && location . hash . replace ( '#' , '' ) . split ( '-' ) [ 0 ] != '' )
7
+ procent = 0.23 ;
8
+ if ( location . hash . replace ( '#' , '' ) . split ( '-' ) [ 0 ] && location . hash . replace ( '#' , '' ) . split ( '-' ) [ 0 ] != '' ) {
6
9
ABAB . setPage ( location . hash . replace ( '#' , '' ) . split ( '-' ) [ 0 ] , location . hash . replace ( '#' , '' ) . split ( '-' ) [ 1 ] , true ) ;
10
+ procent = 0.30 ;
11
+ }
7
12
else
8
13
ABAB . setPage ( 'Rooms' ) ;
9
14
@@ -66,7 +71,23 @@ if (localStorage.getItem('auth')) {
66
71
localStorage . removeItem ( 'auth' ) ;
67
72
}
68
73
}
74
+ ractiveComponent [ 'rootApp' ] . on ( 'update_filter' , function ( e , id ) {
75
+ var formarr = $ ( '#' + id ) . serializeArray ( ) ;
76
+ var form_obj = { } ;
77
+ for ( var i in formarr ) {
78
+ if ( form_obj [ formarr [ i ] . name ] && typeof form_obj [ formarr [ i ] . name ] === 'string' ) {
79
+ form_obj [ formarr [ i ] . name ] = [ form_obj [ formarr [ i ] . name ] , formarr [ i ] . value ] ;
80
+ } else if ( form_obj [ formarr [ i ] . name ] && typeof form_obj [ formarr [ i ] . name ] === 'object' ) {
81
+ form_obj [ formarr [ i ] . name ] . push ( formarr [ i ] . value ) ;
82
+ } else
83
+ form_obj [ formarr [ i ] . name ] = formarr [ i ] . value
84
+ }
85
+ form_obj . people_count = { $gte :form_obj . people_count } ;
86
+ form_obj . children_count = { $gte :form_obj . children_count } ;
87
+ ABAB . event [ 'update_filter' ] ( form_obj , true ) ;
88
+ } ) ;
69
89
ractiveComponent [ 'rootApp' ] . on ( 'location_input_scan' , function ( ) {
90
+
70
91
console . log ( $ ( '#location_input_scan' ) . val ( ) ) ;
71
92
} ) ;
72
93
ractiveComponent [ 'rootApp' ] . on ( 'auth_start' , function ( ) {
@@ -217,53 +238,16 @@ $('#location_input_scan').flexdatalist({
217
238
} , { "address.country" : { '$regex' : json . city , '$options' : 'i' } } ]
218
239
} ;
219
240
}
220
- API ( 'GetRooms' , { page : 1 , find : find } , true , function ( res ) {
221
-
222
- ractiveComponent [ 'reactive-RoomsApp' ] . set ( 'rooms' , res . rooms ) ;
223
- ractiveComponent [ 'reactive-RoomsApp' ] . set ( 'rooms_count' , res . count ) ;
224
-
225
- if ( window . map && window . geocode && window . geocode ) {
226
- geocode = res . rooms . map ( function ( room , i ) {
227
- if ( room . location [ 0 ] && room . location [ 1 ] ) {
228
- var infowindow = new google . maps . InfoWindow ( {
229
- content : '<div id="content">' +
230
- '<div id="siteNotice">' +
231
- '</div>' +
232
- '<h1 id="firstHeading" class="firstHeading">' + room . title + '</h1>' +
233
- '<div id="bodyContent">' +
234
- '<p><b>' + room . title + '</b></p>' +
235
- '<p>Transaction: <a href="' + ractiveComponent [ 'reactive-RoomsApp' ] . get ( 'blockchain_url' ) + 'tx/' + room . txHash + '" target="_blank">' +
236
- room . txHash + '</a>' +
237
- '<br>' +
238
- '(last update ' + room . update_at . split ( 'T' ) [ 0 ] + ').</p>' +
239
- '</div>' +
240
- '</div>' ,
241
- maxWidth : 250
242
- } ) ;
243
- var marker = new google . maps . Marker ( {
244
- position : { lat : room . location [ 0 ] * 1 , lng : room . location [ 1 ] * 1 } ,
245
- // label: ''
246
- animation : google . maps . Animation . DROP ,
247
- map : map
248
-
249
- } ) ;
250
- marker . addListener ( 'click' , function ( ) {
251
- infowindow . open ( map , marker ) ;
252
- } ) ;
253
- return marker ;
254
- }
255
- else return false ;
256
- } ) ;
257
- new MarkerClusterer ( map , markers ,
258
- { imagePath : 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m' } ) ;
259
-
260
- geocode . geocode ( { address : json . city + ',' + json . country } , function ( results , status ) {
261
- map . setCenter ( { lng : results [ 0 ] . geometry . location . lng ( ) , lat : results [ 0 ] . geometry . location . lat ( ) } ) ;
262
- map . setZoom ( 8 ) ;
263
- } ) ;
241
+ if ( json && json . city && json . city === 'Russia' ) json . city = 'Москва' ;
242
+ geocode . geocode ( { address : ( json . city || '' ) + ',' + ( json . country || '' ) } , function ( results , status ) {
243
+ console . log ( results ) ;
244
+ if ( results . length > 0 ) {
245
+ map . setCenter ( { lng : results [ 0 ] . geometry . location . lng ( ) , lat : results [ 0 ] . geometry . location . lat ( ) } ) ;
246
+ map . setZoom ( 8 ) ;
247
+ } else {
248
+ console . warn ( '[map geocode] address not fount:' , json )
264
249
}
265
250
} ) ;
251
+ ABAB . event [ 'update_filter' ] ( find , true ) ;
266
252
267
-
268
- console . log ( data . value ) ;
269
253
} ) ;
0 commit comments