diff --git a/src/c3nav/editor/templates/editor/base.html b/src/c3nav/editor/templates/editor/base.html index 376c20c0..2f8705f1 100644 --- a/src/c3nav/editor/templates/editor/base.html +++ b/src/c3nav/editor/templates/editor/base.html @@ -44,6 +44,7 @@ {% endblock %} + {% include 'site/fragment_fakemobileclient.html' %} {% compress js %} diff --git a/src/c3nav/site/static/site/js/fakemobileclient.js b/src/c3nav/site/static/site/js/fakemobileclient.js new file mode 100644 index 00000000..9c9ab232 --- /dev/null +++ b/src/c3nav/site/static/site/js/fakemobileclient.js @@ -0,0 +1,25 @@ +mobileclient = { + nearbyStations: [], + setNearbyStations: function(data) { + this.nearbyStations = data; + nearby_stations_available(); + }, + getNearbyStations: function() { + return JSON.stringify(this.nearbyStations); + }, + port: 8042, + scanNow: function() { + console.log('mobileclient: scanNow'); + $.getJSON('http://localhost:'+String(mobileclient.port)+'/scan', function(data) { + mobileclient.setNearbyStations(data.data); + }).fail(function() { + mobileclient.scanNow(); + }); + }, + shareUrl: function(url) { + console.log('mobileclient: sharing url: '+url); + }, + createShortcut: function(url, title) { + console.log('mobileclient: shortcut url: '+url+' title: '+title); + } +}; diff --git a/src/c3nav/site/templates/site/fragment_fakemobileclient.html b/src/c3nav/site/templates/site/fragment_fakemobileclient.html new file mode 100644 index 00000000..073851cf --- /dev/null +++ b/src/c3nav/site/templates/site/fragment_fakemobileclient.html @@ -0,0 +1,10 @@ +{% load static %} + +{% if request.GET.fakemobileclient != None %} + + {% if request.GET.fakemobileclient and request.GET.fakemobileclient.isdigit %} + + {% endif %} +{% endif %} diff --git a/src/c3nav/site/templates/site/map.html b/src/c3nav/site/templates/site/map.html index d8513ab6..468b0ec9 100644 --- a/src/c3nav/site/templates/site/map.html +++ b/src/c3nav/site/templates/site/map.html @@ -142,6 +142,7 @@ {% endif %} + {% include 'site/fragment_fakemobileclient.html' %} {% compress js %} diff --git a/tools/fakemobileclient.py b/tools/fakemobileclient.py index d82f0068..7f9a84a6 100644 --- a/tools/fakemobileclient.py +++ b/tools/fakemobileclient.py @@ -15,8 +15,8 @@ def get_from_lines(lines, keyword): class FakeMobileClientHandler(http.server.BaseHTTPRequestHandler): def do_GET(self): """Serve a GET request.""" - if self.path != '/scan/': - self.send_error(404, explain='Look at /scan/') + if self.path != '/scan': + self.send_error(404, explain='Look at /scan') return while True: