From ef51b60c6481254d88c5fc3c34f4127b7f881a58 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Nov 2012 12:05:40 -0500 Subject: Frontend static/ folder --- frontend/static/js/poll.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 frontend/static/js/poll.js (limited to 'frontend/static/js/poll.js') 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() + -- cgit v1.2.3-70-g09d2