From 9d49df61578bb5d0d2c945340d53a831a98ba354 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 25 Dec 2013 16:18:21 -0500 Subject: [PATCH] Work on user options --- lib/channel.js | 2 +- lib/io/ioserver.js | 5 + lib/web/jade.js | 3 +- templates/channel.jade | 33 ++-- templates/useroptions.jade | 82 ++++++++++ www/assets/js/ui.js | 7 +- www/assets/js/util.js | 312 ++++++++----------------------------- www/css/cytube.css | 11 ++ 8 files changed, 197 insertions(+), 258 deletions(-) create mode 100644 templates/useroptions.jade diff --git a/lib/channel.js b/lib/channel.js index 7b164121..7c1e4f01 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -1610,7 +1610,7 @@ Channel.prototype.addMedia = function(data, user) { if (self.dead) return; - if (err) { + if (err && err !== "Item not in library") { user.socket.emit("queueFail", { msg: "Internal error: " + err, link: $util.formatLink(data.id, data.type) diff --git a/lib/io/ioserver.js b/lib/io/ioserver.js index acd71e72..953d1714 100644 --- a/lib/io/ioserver.js +++ b/lib/io/ioserver.js @@ -103,6 +103,11 @@ function handleConnection(sock) { user.name = sock.handshake.user.name; user.global_rank = sock.handshake.user.global_rank; user.loggedIn = true; + user.socket.emit("login", { + success: true, + name: user.name + }); + user.socket.emit("rank", user.global_rank); } } diff --git a/lib/web/jade.js b/lib/web/jade.js index b7098201..391eb108 100644 --- a/lib/web/jade.js +++ b/lib/web/jade.js @@ -43,7 +43,8 @@ function sendJade(res, view, locals) { if (!(view in cache) || process.env['DEBUG']) { var file = path.join(templates, view + '.jade'); var fn = jade.compile(fs.readFileSync(file), { - filename: file + filename: file, + pretty: true }); cache[view] = fn; } diff --git a/templates/channel.jade b/templates/channel.jade index ffe9c9bb..e553d3a3 100644 --- a/templates/channel.jade +++ b/templates/channel.jade @@ -13,8 +13,8 @@ html(lang="en") - var cname = "/r/" + channelName ul.nav.navbar-nav +navdefaultlinks(cname) - li: a(href="javascript:showUserOptions()") Options - li: a(href="javascript:$('#channeloptions').modal()") Channel Settings + li: a(href="#", onclick="javascript:showUserOptions()") Options + li: a(href="#", onclick="javascript:$('#channeloptions').modal()") Channel Settings +navloginlogout(cname) section#mainpage .container @@ -123,14 +123,6 @@ html(lang="en") i.glyphicon.glyphicon-lock .col-lg-12.col-md-12 #queue.videolist - li.queue_entry - a.qe_title(href="#") Derp - span.qe_time 00:00 - div.qe_clear - li.queue_entry.queue_active.queue_temp - a.qe_title(href="#") Derp - span.qe_time 00:00 - div.qe_clear #plmeta span#plcount 0 items span#pllength 00:00:00 @@ -138,6 +130,27 @@ html(lang="en") .col-lg-5.col-md-5 #videowidth.col-lg-7.col-md-7 #sitefooter + #useroptions.modal.fade(tabindex="-1", role="dialog", aria-hidden="true") + .modal-dialog + .modal-content + .modal-header + button.close(data-dismiss="modal", aria-hidden="true")× + h4 User Preferences + ul.nav.nav-tabs + li: a(href="#us-general", data-toggle="tab") General + li: a(href="#us-playback", data-toggle="tab") Playback + li: a(href="#us-chat", data-toggle="tab") Chat + li: a(href="#us-mod", data-toggle="tab", style="") Moderator + .modal-body + .tab-content + include useroptions + +us-general() + +us-playback() + +us-chat() + +us-mod() + .modal-footer + button.btn.btn-primary(type="button", data-dismiss="modal", onclick="javascript:saveUserOptions()") Save + button.btn.btn-default(type="button", data-dismiss="modal") Close #channeloptions.modal.fade(tabindex="-1", role="dialog", aria-hidden="true") .modal-dialog .modal-content diff --git a/templates/useroptions.jade b/templates/useroptions.jade new file mode 100644 index 00000000..6d5c8e58 --- /dev/null +++ b/templates/useroptions.jade @@ -0,0 +1,82 @@ +mixin lcheckbox(id, label) + .form-group + label.control-label.col-sm-4(for=id)= label + .col-sm-8 + .checkbox + input(type="checkbox", id=id) + +mixin rcheckbox(id, label) + .form-group + .col-sm-8.col-sm-offset-4 + .checkbox + label.control-label(for=id)= label + input(type="checkbox", id=id) + +mixin textbox(id, label, placeholder) + .form-group + label.control-label.col-sm-4(for=id)= label + .col-sm-8 + if placeholder + input.form-control(id=id, type="text", placeholder=placeholder) + else + input.form-control(id=id, type="text") + +mixin us-general + #us-general.tab-pane + h4 General Preferences + form.form-horizontal(action="javascript:void(0)") + .form-group + label.control-label.col-sm-4(for="#us-theme") Theme + .col-sm-8 + select#us-theme.form-control + option(value="default") Default + option(value="/css/bootstrap-theme.min.css") Bootstrap + option(value="/css/dark.css") Dark + .form-group + label.control-label.col-sm-4(for="#us-layout") Layout + .col-sm-8 + select#us-layout.form-control + option(value="default") Compact + option(value="synchtube") Synchtube (flipped) + option(value="fluid") Fluid + .col-sm-4 + .col-sm-8 + p.text-danger Changing layouts may require refreshing to take effect. + +rcheckbox("us-no-channelcss", "Ignore Channel CSS") + +rcheckbox("us-no-channeljs", "Ignore Channel Javascript") + +rcheckbox("us-ssl", "Encrypt connection with SSL") + +mixin us-playback + #us-playback.tab-pane + h4 Playback Preferences + form.form-horizontal(action="javascript:void(0)") + +rcheckbox("us-synch", "Synchronize video playback") + +textbox("us-synch-accuracy", "Synch threshold (seconds)", "2") + +rcheckbox("us-wmode-transparent", "Set wmode=transparent") + .col-sm-4 + .col-sm-8 + p.text-info Setting wmode=transparent allows objects to be displayed above the video player, but may cause performance issues on some systems. + +rcheckbox("us-hidevideo", "Remove the video player") + +rcheckbox("us-playlistbuttons", "Hide playlist buttons by default") + +rcheckbox("us-oldbtns", "Old style playlist buttons") + +mixin us-chat + #us-chat.tab-pane + h4 Chat Preferences + form.form-horizontal(action="javascript:void(0)") + +rcheckbox("us-chat-timestamp", "Show timestamps in chat") + +rcheckbox("us-sort-rank", "Sort userlist by rank") + +rcheckbox("us-sort-afk", "Sort AFKers to bottom") + +rcheckbox("us-chat-notice", "Ping on all new messages") + .col-sm-4 + .col-sm-8 + p.text-info When unchecked, you will only be pinged if your name is mentioned + +rcheckbox("us-boop", "Play a sound when pinged") + +rcheckbox("us-sendbtn", "Add a send button to chat") + +mixin us-mod + #us-mod.tab-pane + h4 Moderator Preferences + form.form-horizontal(action="javascript:void(0)") + +rcheckbox("us-modflair", "Show name color") + +rcheckbox("us-joinmessage", "Show join messages") diff --git a/www/assets/js/ui.js b/www/assets/js/ui.js index 60d043a3..26ac9ca8 100644 --- a/www/assets/js/ui.js +++ b/www/assets/js/ui.js @@ -238,7 +238,7 @@ $("#userpl_save").click(function() { $(select).click(function() { VIDEOQUALITY = preset; USEROPTS.default_quality = select; - saveOpts(); + storeOpts(); var btn = $("#qdrop"); var caret = btn.find(".caret").detach(); btn.text($(select).text()); @@ -435,9 +435,12 @@ $(window).resize(function() { /* load channel */ var loc = document.location+""; -var m = loc.match(/\/r\/([a-zA-Z0-9-_]+)$/); +var m = loc.match(/\/r\/([a-zA-Z0-9-_#]+)$/); if(m) { CHANNEL.name = m[1]; + if (CHANNEL.name.indexOf("#") !== -1) { + CHANNEL.name = CHANNEL.name.substring(0, CHANNEL.name.indexOf("#")); + } } /* else { diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 165c9d21..613f55f7 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -476,7 +476,7 @@ function addQueueButtons(li) { menu.detach().prependTo(li); menu.find(".btn").each(function() { // Clear icon - var icon = $(this).find("i"); + var icon = $(this).find(".glyphicon"); $(this).html(""); icon.appendTo(this); }); @@ -524,242 +524,75 @@ function rebuildPlaylist() { /* menus */ /* user settings menu */ -// TODO fix this -function showOptionsMenu() { +function showUserOptions() { hidePlayer(); - var modal = $("
").addClass("modal hide fade") - .appendTo($("body")); - - modal.load("useroptions.html", function () { - if (CLIENT.rank < 2) { - $("#uopt-btn-mod").remove(); - } - - var tabHandler = function (btnid, panelid) { - $(btnid).click(function () { - modal.find(".btn.btn-small").attr("disabled", false); - modal.find(".uopt-panel").hide(); - $(btnid).attr("disabled", true); - $(panelid).show(); - }); - }; - - tabHandler("#uopt-btn-general", "#uopt-panel-general"); - tabHandler("#uopt-btn-playback", "#uopt-panel-playback"); - tabHandler("#uopt-btn-chat", "#uopt-panel-chat"); - tabHandler("#uopt-btn-mod", "#uopt-panel-mod"); - - var initForm = function (id) { - var f = $("
").appendTo($(id)) - .addClass("form-horizontal") - .attr("action", "javascript:void(0)"); - return $("
").appendTo(f); - }; - - var addOption = function (form, lbl, thing) { - var g = $("
").addClass("control-group").appendTo(form); - $("