From 0214910d7e0c0c91cdd07374ebe09fb92fb307ed Mon Sep 17 00:00:00 2001 From: calzoneman Date: Fri, 7 Jun 2013 18:09:36 -0400 Subject: [PATCH] ho hum more rewriting stuff --- www/assets/css/ytsync.css | 16 +++++-- www/assets/js/data.js | 25 ++++++++++ www/assets/js/ui.js | 99 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 132 insertions(+), 8 deletions(-) diff --git a/www/assets/css/ytsync.css b/www/assets/css/ytsync.css index 466e37c3..204ed1b8 100644 --- a/www/assets/css/ytsync.css +++ b/www/assets/css/ytsync.css @@ -15,15 +15,23 @@ html, body { clear: both; } -#librarywrap, #userplaylistwrap, #playlist_controls { - display: none; -} - #welcome { font-size: 10pt; color: #ffffff; } +#usercountwrap, #userlist, #messagebuffer, #videowrap { + background-color: #ffffff; +} + +#librarytoggle, #userpltoggle, #playlisttoggle { + background-color: #ffffff; +} + +#librarywrap, #userplaylistwrap, #playlist_controls { + display: none; +} + .videolist { list-style: none outside none; margin-left: 0; diff --git a/www/assets/js/data.js b/www/assets/js/data.js index cb639879..a99dfa7a 100644 --- a/www/assets/js/data.js +++ b/www/assets/js/data.js @@ -70,3 +70,28 @@ var Rank = { Owner: 10, Siteadmin: 255 }; + +function createCookie(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; +} + +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(";"); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==" ") c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; +} + +function eraseCookie(name) { + createCookie(name,"",-1); +} diff --git a/www/assets/js/ui.js b/www/assets/js/ui.js index 85e22322..a6b165a0 100644 --- a/www/assets/js/ui.js +++ b/www/assets/js/ui.js @@ -22,16 +22,24 @@ generateToggle("#playlisttoggle", "#playlist_controls"); /* navbar stuff */ $("#optlink").click(showOptionsMenu); -$("#guestlogin").click(function() { - socket && socket.emit("login", { + +function guestLogin() { + socket.emit("login", { name: $("#guestname").val(), }); +} +$("#guestlogin").click(guestLogin); +$("#guestname").keydown(function(ev) { + if(ev.keyCode == 13) { + guestLogin(); + } }); + $("#login").click(showLoginMenu); $("#logout").click(function() { eraseCookie("cytube_name"); eraseCookie("cytube_session"); - document.ocation.reload(true); + document.location.reload(true); }); /* chatbox */ @@ -117,7 +125,6 @@ $("#library_query").keydown(function(ev) { source: "library", query: $("#library_query").val().toLowerCase() }); - } }); @@ -147,3 +154,87 @@ $("#userpl_save").click(function() { }); /* playlist controls */ + +function queue(pos) { + var links = $("#mediaurl").val().split(","); + if(pos == "next") { + links = links.reverse(); + } + links.forEach(function(link) { + var data = parseMediaLink(link); + socket.emit("queue", { + id: data.id, + type: data.type, + pos: "end" + }); + }); +} + +$("#queue_next").click(function() { + queue("next"); +}); + +$("#queue_end").click(function() { + queue("end"); +}); + +$("#mediaurl").keydown(function(ev) { + if(ev.keyCode == 13) { + queue("end"); + } +}); + +$("#qlockbtn").click(function() { + socket.emit("togglePlaylistLock"); +}); + +$("#getplaylist").click(function() { + var callback = function(data) { + socket.listeners("playlist").splice( + socket.listeners("playlist").indexOf(callback) + ); + var list = []; + for(var i = 0; i < data.pl.length; i++) { + var entry = formatURL(data.pl[i]); + // TODO formatURL in util.js + list.push(entry); + } + var urls = list.join(","); + + var modal = $("
").addClass("modal hide fade") + .appendTo($("body")); + var head = $("
").addClass("modal-header") + .appendTo(modal); + $("