2013-06-19 21:56:05 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
Copyright (c) 2013 Calvin Montgomery
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2013-06-20 04:42:20 +00:00
|
|
|
/* window focus/blur */
|
|
|
|
$(window).focus(function() {
|
|
|
|
FOCUSED = true;
|
|
|
|
clearInterval(TITLE_BLINK);
|
|
|
|
TITLE_BLINK = false;
|
|
|
|
document.title = PAGETITLE;
|
|
|
|
}).blur(function() {
|
|
|
|
FOCUSED = false;
|
|
|
|
});
|
|
|
|
|
2013-06-06 23:38:47 +00:00
|
|
|
/* Generalized show/hide function */
|
|
|
|
function generateToggle(chevron, div) {
|
|
|
|
$(chevron).click(function() {
|
|
|
|
if($(div).css("display") == "none") {
|
2013-06-09 18:03:41 +00:00
|
|
|
$(chevron).html($(chevron).html().replace(/Show/, "Hide"));
|
2013-06-06 23:38:47 +00:00
|
|
|
$(div).show();
|
2013-06-15 21:45:07 +00:00
|
|
|
$(chevron+" i").removeClass("icon-plus")
|
|
|
|
.addClass("icon-minus");
|
2013-06-06 23:38:47 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-06-09 18:03:41 +00:00
|
|
|
$(chevron).html($(chevron).html().replace(/Hide/, "Show"));
|
2013-06-06 23:38:47 +00:00
|
|
|
$(div).hide();
|
2013-06-15 21:45:07 +00:00
|
|
|
$(chevron+" i").removeClass("icon-minus")
|
|
|
|
.addClass("icon-plus");
|
2013-06-06 23:38:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-06-06 21:48:21 +00:00
|
|
|
|
2013-06-07 03:13:24 +00:00
|
|
|
/* setup show/hide toggles */
|
2013-09-21 07:22:51 +00:00
|
|
|
generateToggle("#usercount", "#userlist");
|
|
|
|
generateToggle("#userlisttoggle", "#userlist");
|
2013-06-20 04:42:20 +00:00
|
|
|
$("#usercountwrap").click(scrollChat);
|
2013-06-06 23:38:47 +00:00
|
|
|
generateToggle("#librarytoggle", "#librarywrap");
|
|
|
|
generateToggle("#userpltoggle", "#userplaylistwrap");
|
|
|
|
generateToggle("#playlisttoggle", "#playlist_controls");
|
2013-06-07 03:13:24 +00:00
|
|
|
|
2013-11-14 04:36:43 +00:00
|
|
|
$("#editmotd").click(showMOTDEditor);
|
|
|
|
|
2013-10-03 03:26:28 +00:00
|
|
|
$("#togglemotd").click(function () {
|
|
|
|
var hidden = $("#motd").css("display") === "none";
|
|
|
|
$("#motd").toggle();
|
|
|
|
if (hidden) {
|
|
|
|
$("#togglemotd").find(".icon-plus")
|
|
|
|
.removeClass("icon-plus")
|
|
|
|
.addClass("icon-minus");
|
|
|
|
} else {
|
|
|
|
$("#togglemotd").find(".icon-minus")
|
|
|
|
.removeClass("icon-minus")
|
|
|
|
.addClass("icon-plus");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-06-07 03:13:24 +00:00
|
|
|
/* navbar stuff */
|
|
|
|
$("#optlink").click(showOptionsMenu);
|
2013-06-11 23:51:00 +00:00
|
|
|
$("#chatonly").click(chatOnly);
|
2013-06-07 22:09:36 +00:00
|
|
|
|
|
|
|
function guestLogin() {
|
|
|
|
socket.emit("login", {
|
2013-06-07 03:13:24 +00:00
|
|
|
name: $("#guestname").val(),
|
|
|
|
});
|
2013-06-07 22:09:36 +00:00
|
|
|
}
|
|
|
|
$("#guestlogin").click(guestLogin);
|
|
|
|
$("#guestname").keydown(function(ev) {
|
|
|
|
if(ev.keyCode == 13) {
|
|
|
|
guestLogin();
|
|
|
|
}
|
2013-06-07 03:13:24 +00:00
|
|
|
});
|
2013-06-07 22:09:36 +00:00
|
|
|
|
2013-06-07 03:13:24 +00:00
|
|
|
$("#login").click(showLoginMenu);
|
|
|
|
$("#logout").click(function() {
|
|
|
|
eraseCookie("cytube_name");
|
|
|
|
eraseCookie("cytube_session");
|
2013-06-07 22:09:36 +00:00
|
|
|
document.location.reload(true);
|
2013-06-07 03:13:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/* chatbox */
|
2013-08-08 14:39:58 +00:00
|
|
|
|
2013-09-21 07:22:51 +00:00
|
|
|
$("#modflair").click(function () {
|
|
|
|
var m = $("#modflair");
|
|
|
|
if (m.hasClass("label-success")) {
|
|
|
|
USEROPTS.modhat = false;
|
|
|
|
m.removeClass("label-success")
|
|
|
|
.addClass("label-default");
|
|
|
|
} else {
|
|
|
|
USEROPTS.modhat = true;
|
|
|
|
m.removeClass("label-default")
|
|
|
|
.addClass("label-success");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#adminflair").click(function () {
|
|
|
|
var m = $("#adminflair");
|
|
|
|
if (m.hasClass("label-important")) {
|
|
|
|
USEROPTS.adminhat = false;
|
|
|
|
m.removeClass("label-important")
|
|
|
|
.addClass("label-default");
|
|
|
|
} else {
|
|
|
|
USEROPTS.adminhat = true;
|
|
|
|
m.removeClass("label-default")
|
|
|
|
.addClass("label-important");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#usercount").mouseenter(function (ev) {
|
2013-08-08 14:39:58 +00:00
|
|
|
var breakdown = calcUserBreakdown();
|
|
|
|
// re-using profile-box class for convenience
|
|
|
|
var popup = $("<div/>")
|
|
|
|
.addClass("profile-box")
|
|
|
|
.css("top", (ev.pageY + 5) + "px")
|
|
|
|
.css("left", (ev.pageX) + "px")
|
2013-09-21 07:22:51 +00:00
|
|
|
.appendTo($("#usercount"));
|
2013-08-08 14:39:58 +00:00
|
|
|
|
|
|
|
var contents = "";
|
|
|
|
for(var key in breakdown) {
|
|
|
|
contents += "<strong>" + key + ": </strong>" + breakdown[key];
|
|
|
|
contents += "<br>"
|
|
|
|
}
|
|
|
|
|
|
|
|
popup.html(contents);
|
|
|
|
});
|
|
|
|
|
2013-09-21 07:22:51 +00:00
|
|
|
$("#usercount").mousemove(function (ev) {
|
|
|
|
var popup = $("#usercount").find(".profile-box");
|
2013-08-08 14:39:58 +00:00
|
|
|
if(popup.length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
popup.css("top", (ev.pageY + 5) + "px");
|
|
|
|
popup.css("left", (ev.pageX) + "px");
|
|
|
|
});
|
|
|
|
|
2013-09-21 07:22:51 +00:00
|
|
|
$("#usercount").mouseleave(function () {
|
|
|
|
$("#usercount").find(".profile-box").remove();
|
2013-08-08 14:39:58 +00:00
|
|
|
});
|
|
|
|
|
2013-06-20 04:42:20 +00:00
|
|
|
$("#messagebuffer").mouseenter(function() { SCROLLCHAT = false; });
|
|
|
|
$("#messagebuffer").mouseleave(function() { SCROLLCHAT = true; });
|
|
|
|
|
2013-06-09 18:03:41 +00:00
|
|
|
$("#chatline").keydown(function(ev) {
|
2013-06-07 03:13:24 +00:00
|
|
|
if(ev.keyCode == 13) {
|
|
|
|
var msg = $("#chatline").val();
|
|
|
|
if(msg.trim()) {
|
2013-11-17 19:12:56 +00:00
|
|
|
var meta = {};
|
2013-09-21 07:22:51 +00:00
|
|
|
if (USEROPTS.adminhat && CLIENT.rank >= 255) {
|
|
|
|
msg = "/a " + msg;
|
2013-11-17 19:12:56 +00:00
|
|
|
} else if (USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) {
|
|
|
|
meta.modflair = CLIENT.rank;
|
2013-06-07 03:13:24 +00:00
|
|
|
}
|
2013-11-17 19:12:56 +00:00
|
|
|
if (CLIENT.rank >= 2 && msg.indexOf("/m ") === 0) {
|
|
|
|
meta.modflair = CLIENT.rank;
|
|
|
|
msg = msg.substring(4);
|
|
|
|
}
|
|
|
|
|
2013-06-07 03:13:24 +00:00
|
|
|
socket.emit("chatMsg", {
|
2013-11-17 19:12:56 +00:00
|
|
|
msg: msg,
|
|
|
|
meta: meta
|
2013-06-07 03:13:24 +00:00
|
|
|
});
|
|
|
|
CHATHIST.push($("#chatline").val());
|
2013-06-19 21:54:27 +00:00
|
|
|
CHATHISTIDX = CHATHIST.length;
|
2013-06-07 03:13:24 +00:00
|
|
|
$("#chatline").val("");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(ev.keyCode == 9) {
|
|
|
|
var words = $("#chatline").val().split(" ");
|
|
|
|
var current = words[words.length - 1].toLowerCase();
|
|
|
|
var users = $("#userlist").children();
|
|
|
|
var match = null;
|
|
|
|
for(var i = 0; i < users.length; i++) {
|
|
|
|
var name = users[i].children[1].innerHTML.toLowerCase();
|
|
|
|
if(name.indexOf(current) == 0 && match == null) {
|
|
|
|
match = users[i].children[1].innerHTML;
|
|
|
|
}
|
|
|
|
else if(name.indexOf(current) == 0) {
|
|
|
|
match = null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(match != null) {
|
|
|
|
words[words.length - 1] = match;
|
|
|
|
if(words.length == 1)
|
|
|
|
words[0] += ": ";
|
|
|
|
else
|
|
|
|
words[words.length - 1] += " ";
|
|
|
|
$("#chatline").val(words.join(" "));
|
|
|
|
}
|
|
|
|
ev.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(ev.keyCode == 38) {
|
|
|
|
if(CHATHISTIDX == CHATHIST.length) {
|
|
|
|
CHATHIST.push($("#chatline").val());
|
|
|
|
}
|
|
|
|
if(CHATHISTIDX > 0) {
|
|
|
|
CHATHISTIDX--;
|
|
|
|
$("#chatline").val(CHATHIST[CHATHISTIDX]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ev.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(ev.keyCode == 40) {
|
|
|
|
if(CHATHISTIDX < CHATHIST.length - 1) {
|
|
|
|
CHATHISTIDX++;
|
|
|
|
$("#chatline").val(CHATHIST[CHATHISTIDX]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ev.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/* poll controls */
|
|
|
|
$("#newpollbtn").click(showPollMenu);
|
|
|
|
|
|
|
|
/* search controls */
|
|
|
|
$("#library_search").click(function() {
|
|
|
|
socket.emit("searchMedia", {
|
|
|
|
source: "library",
|
|
|
|
query: $("#library_query").val().toLowerCase()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#library_query").keydown(function(ev) {
|
|
|
|
if(ev.keyCode == 13) {
|
|
|
|
socket.emit("searchMedia", {
|
|
|
|
source: "library",
|
|
|
|
query: $("#library_query").val().toLowerCase()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-07 17:34:14 +00:00
|
|
|
$("#youtube_search").click(function () {
|
|
|
|
var query = $("#library_query").val().toLowerCase();
|
|
|
|
if(parseMediaLink(query).type !== null) {
|
|
|
|
makeAlert("Media Link", "If you already have the link, paste it " +
|
|
|
|
"in the 'Media URL' box under Playlist Controls. This "+
|
|
|
|
"searchbar works like YouTube's search function.",
|
|
|
|
"alert-error")
|
|
|
|
.addClass("span12")
|
|
|
|
.insertBefore($("#library"));
|
|
|
|
}
|
|
|
|
|
2013-06-07 03:13:24 +00:00
|
|
|
socket.emit("searchMedia", {
|
|
|
|
source: "yt",
|
2013-08-07 17:34:14 +00:00
|
|
|
query: query
|
2013-06-07 03:13:24 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/* user playlists */
|
|
|
|
|
|
|
|
$("#userpltoggle").click(function() {
|
|
|
|
socket.emit("listPlaylists");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#userpl_save").click(function() {
|
|
|
|
if($("#userpl_name").val().trim() == "") {
|
|
|
|
makeAlert("Invalid Name", "Playlist name cannot be empty", "alert-error")
|
|
|
|
.addClass("span12")
|
|
|
|
.insertAfter($("#userpl_save").parent());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
socket.emit("savePlaylist", {
|
|
|
|
name: $("#userpl_name").val()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-06-23 18:21:21 +00:00
|
|
|
/* video controls */
|
2013-08-15 04:26:50 +00:00
|
|
|
function selectQuality(select, preset) {
|
|
|
|
|
|
|
|
}
|
2013-06-23 18:21:21 +00:00
|
|
|
(function() {
|
|
|
|
function qualHandler(select, preset) {
|
|
|
|
$(select).click(function() {
|
|
|
|
VIDEOQUALITY = preset;
|
2013-08-15 04:26:50 +00:00
|
|
|
USEROPTS.default_quality = select;
|
|
|
|
saveOpts();
|
2013-06-23 18:21:21 +00:00
|
|
|
var btn = $("#qualitywrap .btn.dropdown-toggle");
|
|
|
|
var caret = btn.find(".caret").detach();
|
|
|
|
btn.text($(select).text());
|
|
|
|
caret.appendTo(btn);
|
2013-06-30 19:56:41 +00:00
|
|
|
if(PLAYER.type == "yt" && PLAYER.player.setPlaybackQuality)
|
|
|
|
PLAYER.player.setPlaybackQuality(VIDEOQUALITY);
|
2013-06-23 18:21:21 +00:00
|
|
|
});
|
|
|
|
}
|
2013-08-15 04:26:50 +00:00
|
|
|
qualHandler("#quality_auto", "");
|
2013-06-23 18:21:21 +00:00
|
|
|
qualHandler("#quality_240p", "small");
|
|
|
|
qualHandler("#quality_360p", "medium");
|
|
|
|
qualHandler("#quality_480p", "large");
|
|
|
|
qualHandler("#quality_720p", "hd720");
|
|
|
|
qualHandler("#quality_1080p", "hd1080");
|
2013-08-15 04:26:50 +00:00
|
|
|
if($(USEROPTS.default_quality).length > 0)
|
|
|
|
$(USEROPTS.default_quality).click();
|
2013-06-23 18:21:21 +00:00
|
|
|
})();
|
|
|
|
|
2013-06-30 19:56:41 +00:00
|
|
|
$("#mediarefresh").click(function() {
|
|
|
|
PLAYER.type = "";
|
|
|
|
PLAYER.id = "";
|
|
|
|
socket.emit("playerReady");
|
|
|
|
});
|
|
|
|
|
2013-06-07 03:13:24 +00:00
|
|
|
/* playlist controls */
|
2013-06-07 22:09:36 +00:00
|
|
|
|
2013-06-11 19:41:03 +00:00
|
|
|
$("#queue").sortable({
|
|
|
|
start: function(ev, ui) {
|
2013-06-29 22:09:20 +00:00
|
|
|
PL_FROM = ui.item.data("uid");
|
2013-06-11 19:41:03 +00:00
|
|
|
},
|
|
|
|
update: function(ev, ui) {
|
2013-06-27 22:15:29 +00:00
|
|
|
var prev = ui.item.prevAll();
|
|
|
|
if(prev.length == 0)
|
2013-06-29 22:09:20 +00:00
|
|
|
PL_AFTER = "prepend";
|
2013-06-27 22:15:29 +00:00
|
|
|
else
|
2013-06-29 22:09:20 +00:00
|
|
|
PL_AFTER = $(prev[0]).data("uid");
|
2013-06-27 22:15:29 +00:00
|
|
|
socket.emit("moveMedia", {
|
|
|
|
from: PL_FROM,
|
|
|
|
after: PL_AFTER
|
|
|
|
});
|
2013-10-04 03:11:47 +00:00
|
|
|
$("#queue").sortable("cancel");
|
2013-06-11 19:41:03 +00:00
|
|
|
}
|
2013-06-09 18:03:41 +00:00
|
|
|
});
|
2013-06-11 19:41:03 +00:00
|
|
|
$("#queue").disableSelection();
|
2013-06-09 18:03:41 +00:00
|
|
|
|
2013-06-07 22:09:36 +00:00
|
|
|
function queue(pos) {
|
2013-08-03 19:10:06 +00:00
|
|
|
if($("#customembed_code").val()) {
|
2013-08-22 22:33:03 +00:00
|
|
|
var title = false;
|
|
|
|
if($("#customembed_title").val()) {
|
|
|
|
title = $("#customembed_title").val();
|
|
|
|
}
|
2013-08-03 19:10:06 +00:00
|
|
|
socket.emit("queue", {
|
|
|
|
id: $("#customembed_code").val(),
|
2013-08-22 22:33:03 +00:00
|
|
|
title: title,
|
2013-08-03 19:10:06 +00:00
|
|
|
type: "cu",
|
|
|
|
pos: pos
|
|
|
|
});
|
|
|
|
$("#customembed_code").val("");
|
2013-08-22 22:33:03 +00:00
|
|
|
$("#customembed_title").val("");
|
2013-08-03 19:10:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-06-07 22:09:36 +00:00
|
|
|
var links = $("#mediaurl").val().split(",");
|
2013-06-20 03:20:56 +00:00
|
|
|
var parsed = [];
|
2013-06-07 22:09:36 +00:00
|
|
|
links.forEach(function(link) {
|
|
|
|
var data = parseMediaLink(link);
|
2013-06-12 03:37:12 +00:00
|
|
|
if(data.id === null || data.type === null) {
|
|
|
|
makeAlert("Error", "Invalid link. Please double check it and remove extraneous information", "alert-error")
|
|
|
|
.addClass("span12")
|
|
|
|
.insertBefore($("#extended_controls"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#mediaurl").val("");
|
|
|
|
}
|
2013-06-20 03:20:56 +00:00
|
|
|
parsed.push({
|
2013-06-07 22:09:36 +00:00
|
|
|
id: data.id,
|
2013-06-20 03:20:56 +00:00
|
|
|
type: data.type
|
2013-06-07 22:09:36 +00:00
|
|
|
});
|
|
|
|
});
|
2013-06-20 03:20:56 +00:00
|
|
|
|
|
|
|
if(parsed.length > 1) {
|
|
|
|
socket.emit("queue", {
|
|
|
|
id: false,
|
|
|
|
list: parsed,
|
|
|
|
type: "list",
|
|
|
|
pos: pos
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
parsed[0].pos = pos;
|
|
|
|
socket.emit("queue", parsed[0]);
|
|
|
|
}
|
2013-06-07 22:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#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");
|
|
|
|
});
|
|
|
|
|
2013-06-18 20:18:41 +00:00
|
|
|
$("#voteskip").click(function() {
|
|
|
|
socket.emit("voteskip");
|
2013-07-24 19:11:50 +00:00
|
|
|
$("#voteskip").attr("disabled", true);
|
2013-06-18 20:18:41 +00:00
|
|
|
});
|
|
|
|
|
2013-08-03 19:10:06 +00:00
|
|
|
$("#customembed_btn").click(function () {
|
|
|
|
if($("#customembed_entry").css("display") == "none")
|
|
|
|
$("#customembed_entry").show("blind");
|
|
|
|
else
|
|
|
|
$("#customembed_entry").hide("blind");
|
|
|
|
});
|
|
|
|
|
2013-06-07 22:09:36 +00:00
|
|
|
$("#getplaylist").click(function() {
|
|
|
|
var callback = function(data) {
|
2013-08-08 01:05:30 +00:00
|
|
|
hidePlayer();
|
2013-06-07 22:09:36 +00:00
|
|
|
socket.listeners("playlist").splice(
|
|
|
|
socket.listeners("playlist").indexOf(callback)
|
|
|
|
);
|
|
|
|
var list = [];
|
2013-06-11 19:41:03 +00:00
|
|
|
for(var i = 0; i < data.length; i++) {
|
2013-07-12 20:10:06 +00:00
|
|
|
var entry = formatURL(data[i].media);
|
2013-06-07 22:09:36 +00:00
|
|
|
list.push(entry);
|
|
|
|
}
|
|
|
|
var urls = list.join(",");
|
|
|
|
|
|
|
|
var modal = $("<div/>").addClass("modal hide fade")
|
|
|
|
.appendTo($("body"));
|
|
|
|
var head = $("<div/>").addClass("modal-header")
|
|
|
|
.appendTo(modal);
|
|
|
|
$("<button/>").addClass("close")
|
|
|
|
.attr("data-dismiss", "modal")
|
|
|
|
.attr("aria-hidden", "true")
|
|
|
|
.html("×")
|
|
|
|
.appendTo(head);
|
|
|
|
$("<h3/>").text("Playlist URLs").appendTo(head);
|
|
|
|
var body = $("<div/>").addClass("modal-body").appendTo(modal);
|
|
|
|
$("<input/>").attr("type", "text")
|
|
|
|
.val(urls)
|
|
|
|
.appendTo(body);
|
|
|
|
$("<div/>").addClass("modal-footer").appendTo(modal);
|
|
|
|
modal.on("hidden", function() {
|
|
|
|
modal.remove();
|
2013-08-08 01:05:30 +00:00
|
|
|
unhidePlayer();
|
2013-06-07 22:09:36 +00:00
|
|
|
});
|
|
|
|
modal.modal();
|
|
|
|
}
|
|
|
|
socket.on("playlist", callback);
|
|
|
|
socket.emit("requestPlaylist");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#clearplaylist").click(function() {
|
|
|
|
var clear = confirm("Are you sure you want to clear the playlist?");
|
|
|
|
if(clear) {
|
|
|
|
socket.emit("clearPlaylist");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#shuffleplaylist").click(function() {
|
2013-06-11 19:41:03 +00:00
|
|
|
var shuffle = confirm("Are you sure you want to shuffle the playlist?");
|
|
|
|
if(shuffle) {
|
2013-06-07 22:09:36 +00:00
|
|
|
socket.emit("shufflePlaylist");
|
|
|
|
}
|
|
|
|
});
|
2013-06-11 15:29:21 +00:00
|
|
|
|
|
|
|
/* layout stuff */
|
|
|
|
$(window).resize(function() {
|
2013-08-04 15:44:48 +00:00
|
|
|
VWIDTH = $("#videowidth").css("width").replace("px", "");
|
2013-07-04 22:50:15 +00:00
|
|
|
VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
|
2013-06-11 15:29:21 +00:00
|
|
|
$("#messagebuffer").css("height", (VHEIGHT - 31) + "px");
|
|
|
|
$("#userlist").css("height", (VHEIGHT - 31) + "px");
|
2013-07-04 22:50:15 +00:00
|
|
|
if($("#ytapiplayer").length > 0) {
|
|
|
|
$("#ytapiplayer").attr("width", VWIDTH);
|
|
|
|
$("#ytapiplayer").attr("height", VHEIGHT);
|
|
|
|
}
|
2013-06-11 15:29:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/* load channel */
|
|
|
|
|
|
|
|
var loc = document.location+"";
|
|
|
|
var m = loc.match(/\/r\/([a-zA-Z0-9-_]+)$/);
|
|
|
|
if(m) {
|
|
|
|
CHANNEL.name = m[1];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var main = $("#main");
|
|
|
|
var container = $("<div/>").addClass("container").insertBefore(main);
|
|
|
|
var row = $("<div/>").addClass("row").appendTo(container);
|
|
|
|
var div = $("<div/>").addClass("span6").appendTo(row);
|
|
|
|
main.css("display", "none");
|
|
|
|
var label = $("<label/>").text("Enter Channel:").appendTo(div);
|
|
|
|
var entry = $("<input/>").attr("type", "text").appendTo(div);
|
|
|
|
entry.keydown(function(ev) {
|
2013-09-09 22:16:41 +00:00
|
|
|
var host = document.protocol + "//" + document.host + "/";
|
2013-06-11 15:29:21 +00:00
|
|
|
if(ev.keyCode == 13) {
|
2013-09-09 22:16:41 +00:00
|
|
|
document.location = host + "r/" + entry.val();
|
2013-06-11 15:29:21 +00:00
|
|
|
container.remove();
|
|
|
|
main.css("display", "");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-06-19 21:54:27 +00:00
|
|
|
|
2013-07-13 04:53:32 +00:00
|
|
|
/* custom footer */
|
|
|
|
$("#sitefooter").load("footer.html");
|
|
|
|
|
2013-06-19 21:54:27 +00:00
|
|
|
/* oh internet explorer, how I hate thee */
|
|
|
|
$(":input:not(textarea)").keypress(function(ev) {
|
|
|
|
return ev.keyCode != 13;
|
|
|
|
});
|
2013-09-11 03:43:43 +00:00
|
|
|
|
|
|
|
if (location.protocol === "https:") {
|
|
|
|
var title = "Warning";
|
|
|
|
var text = "You connected to this page via HTTPS. Due to browser "+
|
|
|
|
"security policy, certain media players may throw warnings,"+
|
|
|
|
" while others may not work at all due to only being "+
|
|
|
|
"available over plain HTTP.<br>To encrypt your websocket "+
|
|
|
|
"traffic and API calls (logins, account management, etc) "+
|
|
|
|
"while loading this page over plain HTTP, enable the SSL "+
|
|
|
|
"option from the Options menu.";
|
|
|
|
makeAlert(title, text, "alert-warning")
|
|
|
|
.appendTo($("#announcements"));
|
|
|
|
}
|