diff options
-rw-r--r-- | .gitmodules | 3 | ||||
m--------- | libraries/pollymer | 0 | ||||
-rw-r--r-- | uos-live.js | 46 |
3 files changed, 49 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..572e964 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libraries/pollymer"] + path = libraries/pollymer + url = https://github.com/fanout/pollymer.git diff --git a/libraries/pollymer b/libraries/pollymer new file mode 160000 +Subproject 16c672b6357040a60ab83de29475eb8b72998df diff --git a/uos-live.js b/uos-live.js new file mode 100644 index 0000000..b1fc127 --- /dev/null +++ b/uos-live.js @@ -0,0 +1,46 @@ +(function() { + + window.UoSLive = {}; + + var busStopRequests = {}; + + UoSLive.getBusStopURL = function(busStop) { + var base = "http://bus.southampton.ac.uk/bus-stop/"; + + var url = base + busStop + ".json"; + + return url; + }; + + UoSLive.subscribeToBusStop = function(busStop, callback) { + + + var url = UoSLive.getBusStopURL(busStop); + + var req = new Pollymer.Request(); + + busStopRequests[busStop] = req; + + req.recurring = true; + + req.on('finished', function(code, result, headers) { + callback(result); + }); + + req.on('error', function(reason) { + }); + + req.maxTries = -1; + + req.start('GET', url); + }; + + UoSLive.unsubscribeToBusStop = function(busStop) { + + var req = busStopRequests[busStop]; + + req.abort(); + + } + +})(); |