summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2015-03-11 22:38:45 +0000
committerChristopher Baines <cb15g11@soton.ac.uk>2015-03-11 22:38:45 +0000
commitddba621bb02ef18cf180194a46f6f267b7f626ee (patch)
treeff9aeb21cac9dcb5705454d4e28799b031d06c91
downloaduos-live.js-ddba621bb02ef18cf180194a46f6f267b7f626ee.tar
uos-live.js-ddba621bb02ef18cf180194a46f6f267b7f626ee.tar.gz
Initial commit
-rw-r--r--.gitmodules3
m---------libraries/pollymer0
-rw-r--r--uos-live.js46
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();
+
+ }
+
+})();