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,#calendar,.furniture").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,#calendar,.furniture").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 ytw = (w)*1/3 var yth = ytw * 9/16 var buttonheight = $("#fullscreen").height() var topoffset = 100 var rightoffset = 100 $("#player").css("right", rightoffset) $("#player").css("top", topoffset) $("#player").css("height", yth+buttonheight+20) $("#player,#projector,#screen,#ytscreen").width(ytw) $("#projector,#screen,#ytscreen").height(yth) $("#projector").css("position", "absolute") $("#controls").css("top", yth+10+10) var playerHeight = yth+buttonheight+topoffset+10 $("#playlist,#playlistbg").css("right", rightoffset) $("#playlist,#playlistbg").css("top", playerHeight+30) $("#playlist,#playlistbg").css("width", ytw+19) $("#playlist,#playlistbg,#queue").css("height", h-playerHeight-50) $("#controls").css({ position: 'absolute', top: yth+20, bottom: 'auto', right: 'auto', }) $("#calendar").css({ top: playerHeight-63, right: rightoffset+ytw+50 }) } } var Profile = { mode: false, loadQueue: function (queue) { if (! queue || ! queue.length) return Player.clearQueue() $("#queue").html("") Playlist.enqueueOldVideoFormat(queue) }, init: function () { } } 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 Calendar = { background: "", dateLoad: function (y, m, d) { var data = { year: y, month: m, day: d, } $.post(API.URL.video.date, data).success(Calendar.dateSuccess) }, todayLoad: function () { d.warn("today") $.post(API.URL.video.date).success(Calendar.dateSuccess) }, dateSuccess: function (raw) { var lines = API.parse("/video/date", raw) if (! lines.length) return var videos = [] for (i in lines) { var line = lines[i].split("\t") if (line[0] === "BG") { if (Calendar.background === line[1]) continue Calendar.background = line[1] $("#bg").fadeOut(1000, function () { $("#bg img").attr("src", Calendar.background) $("#bg img").bind("load", function () { $("#bg").fadeIn(1000) $("#bg img").unbind("load") }) }) } if (line[0] === "VIDEO") { line.shift() videos.push(line) } } Player.clearQueue() $("#queue").html("") Playlist.enqueueOldVideoFormat(videos) }, onSelect: function (dateText, inst) { var datez = dateText.split("-") Calendar.dateLoad(datez[0], datez[1], datez[2]) }, init: function () { $('#calendar').datepicker({ inline: true, onSelect: Calendar.onSelect, dateFormat: "yy-m-d", minDate: new Date(2011, 2, 2), maxDate: new Date(), }) Calendar.todayLoad() $('#calendar').fadeIn(1000) } } 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() Like.likeContentDelay = 6000 $("#controls").fadeIn(2000) $("#contact").fadeIn(2000) setTimeout('Viewport.standardResize()', 1000) Calendar.init() } } Main.init()