1. Marco Yuen
  2. nextrain

Commits

Marco Yuen  committed 64c293e

Show the nearby stops in a listview.

  • Participants
  • Parent commits 2c75b4c
  • Branches master

Comments (0)

Files changed (4)

File resources/public/js/location.coffee

View file
  • Ignore whitespace
         $.post('/findstops',
                {lat: position.coords.latitude, lon: position.coords.longitude},
                (data, status, jqxhr) ->
-                 directive = {'li': {
-                               'stop<-stops': {
-                                 '.': 'stop' }}}
-                 $('#stops-list-template').render(data, directive)
+                 $('#stops-list-template').autoRender(data)
                  console.log(data))
 
     errorhandler = (error) ->

File resources/public/js/location.js

View file
  • Ignore whitespace
       lat: position.coords.latitude,
       lon: position.coords.longitude
     }, function(data, status, jqxhr) {
-      var directive;
-      directive = {
-        'li': {
-          'stop<-stops': {
-            '.': 'stop'
-          }
-        }
-      };
-      $('#stops-list-template').render(data, directive);
+      $('#stops-list-template').autoRender(data);
       return console.log(data);
     });
   };

File src/nextrain/controller.clj

View file
  • Ignore whitespace
                              {:stop_lon [> lon-min]}
                              {:stop_lat [< lat-max]}
                              {:stop_lon [< lon-max]})))]
-    (map :stop_name result)))
+    result))
 
 ;;;
 ;;; Handlers
   (let [lat (read-string (:lat params))
         lon (read-string (:lon params))
         stops (nearest-stops [lat lon])]
-    (json-response {:stops stops})))
-
+    (json-response {:stop (map
+                           #(assoc % :stop_url (str "/stop/" (:stop_id %)))
+                           stops)})))

File src/nextrain/snippets.clj

View file
  • Ignore whitespace
   (mobile-page :header (html [:h1 "Nearest Stops"])
                :content (html [:div#stops-list-template
                                 [:ul {:data-role "listview"}
-                                  [:li]]])))
+                                 [:li.stop
+                                  [:a {:class "stop_name stop_url@href"}]]]])))