diff options
Diffstat (limited to 'js-maybe-remove/top.js')
| -rwxr-xr-x | js-maybe-remove/top.js | 251 |
1 files changed, 251 insertions, 0 deletions
diff --git a/js-maybe-remove/top.js b/js-maybe-remove/top.js new file mode 100755 index 0000000..9263bf8 --- /dev/null +++ b/js-maybe-remove/top.js @@ -0,0 +1,251 @@ +var Keyboard = + { + altMode: false, + fullscreenKeys: function (event) + { + kc = event.keyCode + if (kc === 27) + Viewport.fullscreenOff() + if (kc === 37 || kc === 177) + Player.playPrev() + if (kc === 39 || kc === 176) + Player.playNext() + if (kc === 32 || kc === 179) + Player.toggle() + if (kc === 76) + Player.likeClick() + return false + }, + standardKeys: function (event) + { + kc = event.keyCode + if (kc === 91) + { + Keyboard.altMode = true + return true + } + if (kc === 27) + { + Viewport.fullscreenOn() + return false + } + if (kc === 37 || kc === 177) + { + Player.playPrev() + return false + } + else if (kc === 39 || kc === 176) + { + Player.playNext() + return false + } + if (! Keyboard.altMode && kc === 76) + { + Player.likeClick() + return false + } + if (kc === 32 || kc === 179) + { + Player.toggle() + return false + } + Keyboard.altMode = false + return true + } + } +var Viewport = + { + fullscreenMode: false, + fullscreenOn: function () + { + $("#logo,#logobg,#sitez,#playlist,#playlistbg,#contact,#bg,#gif-container,#controls").hide() + $("#settings-container").hide() + $(window).unbind("resize") + $(window).bind("resize", Viewport.fullscreenResize) + $(window).unbind("keydown") + $(window).bind("keydown", Keyboard.fullscreenKeys) + Viewport.fullscreenResize() + Viewport.fullscreenMode = true + }, + fullscreenResize: function () + { + $("#projector").css({ position: 'fixed', top: 0, left: 0, width: $(window).width(), height: $(window).height() }) + $("#screen,#ytscreen").css({ width: $(window).width(), height: $(window).height() }) + }, + fullscreenOff: function () + { + $("#logo,#logobg,#sitez,#playlist,#playlistbg,#contact,#bg,#gif-container,#controls").show() + $(window).unbind("resize") + $(window).bind("resize", Viewport.standardResize) + Viewport.standardResize() + Viewport.fullscreenMode = false + $(window).unbind("keydown") + $(window).bind("keydown", Keyboard.standardKeys) + $("#fullscreen").unbind("click") + $("#fullscreen").bind("click", Viewport.fullscreenOn) + }, + standardResize: function () + { + var w = $(window).width() + var h = $(window).height() + var contact = w * 200 / 1425 + var ytw = (w-contact-40)*4/7 + var yth = ytw * 9/16 + var plw = (w-contact-40)*3/7 + + $("#contact img").css("max-width", contact) + var conheight = $("#controls").height() + var contactheight = $("#contact").height() + var qheight = Math.max(yth+conheight+40, h - 94 - 60 - 100) + + $("#playlist").css("top", 94).css("left", contact/2) + $("#playlist,#playlistbg").css("width", plw-20+40) + $("#playlist,#playlistbg").css("height", qheight) + $("#queue").css("height", qheight) + var queuetop = $("#queue").offset().top + $("#playlistbg").css("top", queuetop).css("left", contact/2) + + $("#projector").css({ position: 'absolute', }) + $("#player").css("height", yth+conheight+20) + // $("#player").css("top", queuetop+(qheight-yth-conheight-20)/2).css("left", plw+(contact/2)+40) + $("#player").css("top", queuetop).css("left", plw+(contact/2)+40) + $("#projector").css("left", 10) + $("#player,#projector,#screen,#ytscreen").width(ytw-40) + $("#projector,#screen,#ytscreen").height(yth) + + $("#controls").css({ position: 'absolute', top: yth+20, bottom: 'auto', right: 'auto', }) + + $("#gif-container").css("top", qheight+30+134) + } + } + +var Profile = + { + mode: false, + loadQueue: function (queue) + { + if (! queue || ! queue.length) + return + Player.clearQueue() + $("#queue").html("") + Playlist.enqueueOldVideoFormat(queue) + }, + loadTodayQueue: function () + { + if (Profile.mode === "today") + return + Profile.mode = "today" + $(".mode").removeClass("mode") + $("#todayQueue").addClass("mode") + Profile.loadQueue(todayVideoQueue) + }, + loadYesterdayQueue: function () + { + if (Profile.mode === "yesterday") + return + Profile.mode = "yesterday" + $(".mode").removeClass("mode") + $("#yesterdayQueue").addClass("mode") + Profile.loadQueue(yesterdayVideoQueue) + }, + loadTopQueue: function () + { + if (Profile.mode === "top") + return + Profile.mode = "top" + $(".mode").removeClass("mode") + $("#topQueue").addClass("mode") + Profile.loadQueue(topVideoQueue) + }, + init: function () + { + if (todayVideoQueue && todayVideoQueue.length && todayVideoQueueTitle) + { + $("#queueLinks").append('<li id="todayQueue">'+todayVideoQueueTitle+'</li>') + $("#todayQueue").bind("click", Profile.loadTodayQueue) + todayVideoQueue.reverse() + } + if (yesterdayVideoQueue && yesterdayVideoQueue.length && yesterdayVideoQueueTitle) + { + $("#queueLinks").append('<li id="yesterdayQueue">'+yesterdayVideoQueueTitle+'</li>') + $("#yesterdayQueue").bind("click", Profile.loadYesterdayQueue) + } + if (topVideoQueue && topVideoQueue.length && topVideoQueueTitle) + { + $("#queueLinks").append('<li id="topQueue">'+topVideoQueueTitle+'</li>') + $("#topQueue").bind("click", Profile.loadTopQueue) + topVideoQueue.reverse() + } + if (todayVideoQueue && todayVideoQueue.length) + Profile.loadTodayQueue() + else if (yesterdayVideoQueue && yesterdayVideoQueue.length) + Profile.loadYesterdayQueue() + } + } + +var Room = + { + } +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() + Viewport.standardResize() + }, + 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 () + { + $(window).bind("resize", Viewport.standardResize) + $(window).bind("keydown", Keyboard.standardKeys) + Playlist.showScores = true + Auth.success = Poll.init + if (Auth.init()) + Auth.checkin() + Profile.init() + Player.init() + $("#controls").fadeIn(2000) + $("#contact").fadeIn(2000) + setTimeout('Viewport.standardResize()', 1000) + } + } +Main.init() + |
