diff options
author | raylu <raylu@mixpanel.com> | 2011-08-06 19:55:57 -0700 |
---|---|---|
committer | raylu <raylu@mixpanel.com> | 2011-08-06 19:55:57 -0700 |
commit | 8f85f1a74cb9f8796638a00c5b78541d027b9845 (patch) | |
tree | 709f50a0d15106ed62e0d2aa7be64d95b7646fc8 /static/poller.js | |
parent | 082514b9ed2071f21e75a735830741d3f319cf50 (diff) | |
download | audioaxis-8f85f1a74cb9f8796638a00c5b78541d027b9845.tar.xz |
other users' adds will show up; temp crappy internet fixes
Diffstat (limited to 'static/poller.js')
-rw-r--r-- | static/poller.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/static/poller.js b/static/poller.js new file mode 100644 index 0000000..31d6799 --- /dev/null +++ b/static/poller.js @@ -0,0 +1,33 @@ +importScripts('/static/jquery.hive.pollen.min.js'); + +var pid; +var timestamp = '0'; + +function getUpdates() { + $.ajax.get({ + url: '/poll/', + dataType: 'json', + data: {pid: pid, timestamp: timestamp}, + timeout: 1000 * 30, + success: handleUpdates + }); +} +function handleUpdates(data) { + var updates = []; + for (var i = 0; i < data.length; i++) { + updates.push({ + 'action': data[i].Action, + 'yid': data[i].Song.Yid, + 'title': data[i].Song.Title, + 'user': data[i].Song.User + }); + timestamp = data[i].Timestamp; + } + $.send({updates: updates}); + getUpdates(); +} + +$(function (data) { + pid = data.pid; + getUpdates(); +}); |