fakemobileclient.js
This commit is contained in:
parent
8aa94e5c2f
commit
9066318b10
5 changed files with 39 additions and 2 deletions
|
@ -44,6 +44,7 @@
|
|||
{% endblock %}
|
||||
</div>
|
||||
|
||||
{% include 'site/fragment_fakemobileclient.html' %}
|
||||
{% compress js %}
|
||||
<script type="text/javascript" src="{% static 'jquery/jquery.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'bootstrap/js/bootstrap.js' %}"></script>
|
||||
|
|
25
src/c3nav/site/static/site/js/fakemobileclient.js
Normal file
25
src/c3nav/site/static/site/js/fakemobileclient.js
Normal file
|
@ -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);
|
||||
}
|
||||
};
|
10
src/c3nav/site/templates/site/fragment_fakemobileclient.html
Normal file
10
src/c3nav/site/templates/site/fragment_fakemobileclient.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% load static %}
|
||||
|
||||
{% if request.GET.fakemobileclient != None %}
|
||||
<script type="text/javascript" src="{% static 'site/js/fakemobileclient.js' %}"></script>
|
||||
{% if request.GET.fakemobileclient and request.GET.fakemobileclient.isdigit %}
|
||||
<script type="text/javascript">
|
||||
mobileclient.port = {{ request.GET.fakemobileclient }};
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -142,6 +142,7 @@
|
|||
<div id="modal-content"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include 'site/fragment_fakemobileclient.html' %}
|
||||
{% compress js %}
|
||||
<script type="text/javascript" src="{% static 'jquery/jquery.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'leaflet/leaflet.js' %}"></script>
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue