diff options
| author | root <root@lalalizard.com> | 2012-11-26 12:05:40 -0500 |
|---|---|---|
| committer | root <root@lalalizard.com> | 2012-11-26 12:05:40 -0500 |
| commit | ef51b60c6481254d88c5fc3c34f4127b7f881a58 (patch) | |
| tree | 42a9596a7d53951d2a10f60fea4c2854fc9348af /frontend/static/js/poll.js | |
| parent | ddc5b25b4a47ef8175aced9c06fc1767d004e826 (diff) | |
Frontend static/ folder
Diffstat (limited to 'frontend/static/js/poll.js')
| -rw-r--r-- | frontend/static/js/poll.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/frontend/static/js/poll.js b/frontend/static/js/poll.js new file mode 100644 index 0000000..01f480b --- /dev/null +++ b/frontend/static/js/poll.js @@ -0,0 +1,53 @@ +var Poll = + { + room: "main", + delay: 5000, + init: function () + { + if (document.cookie) + { + var cookies = document.cookie.split(";") + for (i in cookies) + { + var cookie = cookies[i].split("=") + if (cookie[0].indexOf("room") !== -1) + { + if (cookie[1] !== 'false' && cookie[1] !== 'undefined') + { + Poll.room = cookie[1] + break + } + } + } + } + Poll.poll() + }, + poll: function () + { + $.post(API.URL.room.poll, + { + room: Poll.room, + session: Auth.session, + last: 1, + }).success(Poll.pollCallback).error(Poll.pollErrorCallback) + }, + pollErrorCallback: function () + { + Poll.timer = setTimeout(Poll.poll, Poll.delay) + }, + pollCallback: function (raw) + { + Poll.timer = setTimeout(Poll.poll, Poll.delay) + } + } +var Main = + { + init: function () + { + Auth.success = Poll.init + if (Auth.init()) + Auth.checkin() + } + } +Main.init() + |
