diff options
| author | Pepper <pepper@scannerjammer.com> | 2015-05-20 11:16:13 -0400 |
|---|---|---|
| committer | Pepper <pepper@scannerjammer.com> | 2015-05-20 11:16:13 -0400 |
| commit | a4916103efb2d97896c456ff0e83064b21e85d25 (patch) | |
| tree | b3eb529e4b96375109626bbeada35d4f8a2667ee /js-maybe-remove/poll.js | |
| parent | 3790eedc2f48c725c586b8c7b924875fedbeb7b4 (diff) | |
first commit in a while
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() + |
