diff options
Diffstat (limited to 'js-maybe-remove/poll.js')
| -rwxr-xr-x | js-maybe-remove/poll.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/js-maybe-remove/poll.js b/js-maybe-remove/poll.js new file mode 100755 index 0000000..01f480b --- /dev/null +++ b/js-maybe-remove/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() + |
