2013-03-24 02:28:20 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
Copyright (c) 2013 Calvin Montgomery
|
2013-04-11 17:51:08 +00:00
|
|
|
|
2013-03-24 02:28:20 +00:00
|
|
|
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:
|
2013-04-11 17:51:08 +00:00
|
|
|
|
2013-03-24 02:28:20 +00:00
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
2013-04-11 17:51:08 +00:00
|
|
|
|
2013-03-24 02:28:20 +00:00
|
|
|
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-02-16 17:19:59 +00:00
|
|
|
|
2013-02-16 05:02:42 +00:00
|
|
|
const SYNC_THRESHOLD = 2;
|
|
|
|
var LEADER = false;
|
|
|
|
var PLAYER = false;
|
|
|
|
var MEDIATYPE = "yt";
|
|
|
|
var POSITION = -1;
|
|
|
|
var RANK = 0;
|
2013-03-16 20:39:58 +00:00
|
|
|
var OPENQUEUE = false;
|
2013-03-22 20:04:04 +00:00
|
|
|
var CHANNELOPTS = {};
|
2013-03-28 23:51:08 +00:00
|
|
|
var GRABBEDLI = null;
|
|
|
|
var OLDINDEX = -1;
|
2013-03-29 18:15:46 +00:00
|
|
|
var CHATHIST = [];
|
|
|
|
var CHATHISTIDX = 0;
|
2013-03-30 05:49:41 +00:00
|
|
|
var FOCUSED = true;
|
2013-03-30 05:55:25 +00:00
|
|
|
var SCROLLCHAT = true;
|
2013-03-30 05:49:41 +00:00
|
|
|
var PAGETITLE = "Sync";
|
|
|
|
var TITLE_BLINK;
|
2013-04-19 19:00:10 +00:00
|
|
|
var VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//670
|
2013-03-31 22:30:46 +00:00
|
|
|
var VHEIGHT = "377";
|
2013-04-11 17:51:08 +00:00
|
|
|
var IGNORED = [];
|
2013-04-14 17:38:00 +00:00
|
|
|
var KICKED = false;
|
2013-03-24 17:23:48 +00:00
|
|
|
var uname = readCookie("sync_uname");
|
2013-04-26 03:50:12 +00:00
|
|
|
var session = readCookie("sync_session");
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
|
|
var Rank = {
|
|
|
|
Guest: 0,
|
|
|
|
Member: 1,
|
2013-03-05 23:06:25 +00:00
|
|
|
Moderator: 2,
|
|
|
|
Owner: 3,
|
2013-02-16 05:02:42 +00:00
|
|
|
Siteadmin: 255
|
|
|
|
};
|
|
|
|
|
2013-04-06 20:47:27 +00:00
|
|
|
try {
|
|
|
|
var socket = io.connect(IO_URL);
|
|
|
|
initCallbacks();
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
handleDisconnect();
|
|
|
|
}
|
2013-02-16 05:02:42 +00:00
|
|
|
|
2013-04-11 17:51:08 +00:00
|
|
|
$(window).focus(function() {
|
2013-03-30 05:49:41 +00:00
|
|
|
FOCUSED = true;
|
|
|
|
onWindowFocus();
|
|
|
|
})
|
|
|
|
.blur(function() {
|
2013-04-06 20:47:27 +00:00
|
|
|
FOCUSED = false;
|
2013-03-30 05:49:41 +00:00
|
|
|
});
|
|
|
|
|
2013-04-19 19:00:10 +00:00
|
|
|
$(window).resize(function() {
|
|
|
|
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
|
|
|
|
$("#ytapiplayer").attr("width", VWIDTH);
|
|
|
|
});
|
|
|
|
|
2013-02-16 05:02:42 +00:00
|
|
|
var params = {};
|
|
|
|
if(window.location.search) {
|
2013-03-24 17:23:48 +00:00
|
|
|
var parameters = window.location.search.substring(1).split("&");
|
2013-02-16 05:02:42 +00:00
|
|
|
for(var i = 0; i < parameters.length; i++) {
|
2013-03-24 17:23:48 +00:00
|
|
|
var s = parameters[i].split("=");
|
2013-02-16 05:02:42 +00:00
|
|
|
if(s.length != 2)
|
|
|
|
continue;
|
|
|
|
params[s[0]] = s[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
if(params["novideo"] != undefined) {
|
2013-04-01 01:10:57 +00:00
|
|
|
$("#videodiv").remove();
|
2013-03-17 19:47:32 +00:00
|
|
|
}
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
if(params["channel"] == undefined) {
|
2013-04-19 19:21:51 +00:00
|
|
|
// Match URLs of the form http://site.tld/r/channel
|
|
|
|
var loc = document.location+"";
|
|
|
|
var m = loc.match(/\/r\/([a-zA-Z0-9]+)/);
|
|
|
|
if(m) {
|
|
|
|
socket.emit("joinChannel", {
|
|
|
|
name: m[1]
|
|
|
|
});
|
|
|
|
}
|
2013-04-19 19:24:33 +00:00
|
|
|
else {
|
2013-04-19 19:21:51 +00:00
|
|
|
|
2013-04-19 19:24:33 +00:00
|
|
|
var main = $($(".container")[1]);
|
|
|
|
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) {
|
|
|
|
if(ev.keyCode == 13) { document.location = document.location + "?channel=" + entry.val();
|
|
|
|
socket.emit("joinChannel", {
|
|
|
|
name: entry.val()
|
|
|
|
});
|
|
|
|
container.remove();
|
|
|
|
main.css("display", "");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-02-16 05:02:42 +00:00
|
|
|
}
|
2013-03-24 17:23:48 +00:00
|
|
|
else if(!params["channel"].match(/^[a-zA-Z0-9]+$/)) {
|
|
|
|
$("<div/>").addClass("alert alert-error")
|
|
|
|
.insertAfter($(".row")[0])[0]
|
2013-03-20 23:10:23 +00:00
|
|
|
.innerHTML = "<h3>Invalid Channel Name</h3><p>Channel names must conain only numbers and letters</p>";
|
|
|
|
|
|
|
|
}
|
2013-04-06 20:47:27 +00:00
|
|
|
|
|
|
|
socket.on("connect", function() {
|
2013-03-24 17:23:48 +00:00
|
|
|
socket.emit("joinChannel", {
|
|
|
|
name: params["channel"]
|
2013-02-16 05:02:42 +00:00
|
|
|
});
|
2013-04-26 03:50:12 +00:00
|
|
|
if(uname && session) {
|
2013-04-06 20:47:27 +00:00
|
|
|
socket.emit("login", {
|
|
|
|
name: uname,
|
2013-04-26 03:50:12 +00:00
|
|
|
session: session
|
2013-04-06 20:47:27 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
$("<div/>").addClass("server-msg-reconnect")
|
|
|
|
.text("Connected")
|
|
|
|
.appendTo($("#messagebuffer"));
|
2013-04-23 19:17:42 +00:00
|
|
|
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
2013-04-06 20:47:27 +00:00
|
|
|
setTimeout(function() { $("#reconnect_box").remove(); }, 3000);
|
|
|
|
});
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Load the youtube iframe API
|
2013-03-24 17:23:48 +00:00
|
|
|
var tag = document.createElement("script");
|
2013-02-16 05:02:42 +00:00
|
|
|
tag.src = "http://www.youtube.com/iframe_api";
|
2013-03-24 17:23:48 +00:00
|
|
|
var firstScriptTag = document.getElementsByTagName("script")[0];
|
2013-02-16 05:02:42 +00:00
|
|
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
|
|
|
|
|
|
|
var sendVideoUpdate = function() { }
|
|
|
|
setInterval(function() {
|
|
|
|
sendVideoUpdate();
|
|
|
|
}, 5000);
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#queue_end").click(function() {
|
2013-04-12 18:02:57 +00:00
|
|
|
var urls = $("#mediaurl").val().split(",");
|
|
|
|
for(var i = 0; i < urls.length; i++) {
|
|
|
|
if(!urls[i].trim())
|
|
|
|
continue;
|
|
|
|
var parsed = parseVideoURL(urls[i].trim());
|
|
|
|
var id = parsed[0];
|
|
|
|
var type = parsed[1];
|
|
|
|
if(id) {
|
|
|
|
$("#mediaurl").val("");
|
|
|
|
}
|
|
|
|
socket.emit("queue", {
|
|
|
|
id: id,
|
|
|
|
pos: "end",
|
|
|
|
type: type
|
|
|
|
});
|
2013-02-16 05:02:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#queue_next").click(function() {
|
2013-04-12 18:02:57 +00:00
|
|
|
var urls = $("#mediaurl").val().split(",");
|
|
|
|
for(var i = 0; i < urls.length; i++) {
|
|
|
|
if(!urls[i].trim())
|
|
|
|
continue;
|
|
|
|
var parsed = parseVideoURL(urls[i].trim());
|
|
|
|
var id = parsed[0];
|
|
|
|
var type = parsed[1];
|
|
|
|
if(id) {
|
|
|
|
$("#mediaurl").val("");
|
|
|
|
}
|
|
|
|
socket.emit("queue", {
|
|
|
|
id: id,
|
|
|
|
pos: "next",
|
|
|
|
type: type
|
|
|
|
});
|
2013-02-16 05:02:42 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#play_next").click(function() {
|
|
|
|
socket.emit("playNext");
|
2013-02-16 05:02:42 +00:00
|
|
|
});
|
|
|
|
|
2013-04-02 19:07:22 +00:00
|
|
|
$("#voteskip").click(function() {
|
|
|
|
socket.emit("voteskip");
|
|
|
|
$("#voteskip").attr("disabled", true);
|
|
|
|
});
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#qlockbtn").click(function() {
|
|
|
|
socket.emit("queueLock", {
|
2013-03-16 20:39:58 +00:00
|
|
|
locked: OPENQUEUE
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-04-26 03:50:12 +00:00
|
|
|
$("#login").click(showLoginFrame);
|
2013-02-16 05:02:42 +00:00
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#logout").click(function() {
|
|
|
|
eraseCookie("sync_uname");
|
2013-04-26 03:50:12 +00:00
|
|
|
eraseCookie("sync_session");
|
2013-02-16 05:02:42 +00:00
|
|
|
document.location.reload(true);
|
|
|
|
});
|
|
|
|
|
2013-04-01 01:29:39 +00:00
|
|
|
$("#chatline").keydown(function(ev) {
|
|
|
|
if(ev.keyCode == 13 && $("#chatline").val() != "") {
|
2013-04-18 16:42:07 +00:00
|
|
|
if($("#chatline").val().trim() == "/poll") {
|
|
|
|
newPollMenu();
|
|
|
|
$("#chatline").val("");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
socket.emit("chatMsg", {
|
|
|
|
msg: $("#chatline").val()
|
|
|
|
});
|
|
|
|
}
|
2013-04-01 01:29:39 +00:00
|
|
|
CHATHIST.push($("#chatline").val());
|
|
|
|
if(CHATHIST.length > 10)
|
|
|
|
CHATHIST.shift();
|
|
|
|
CHATHISTIDX = CHATHIST.length;
|
|
|
|
$("#chatline").val("");
|
|
|
|
}
|
|
|
|
else if(ev.keyCode == 9) { // Tab completion
|
|
|
|
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;
|
2013-03-18 01:24:28 +00:00
|
|
|
}
|
2013-04-01 01:29:39 +00:00
|
|
|
else if(name.indexOf(current) == 0) {
|
|
|
|
match = null;
|
|
|
|
break;
|
2013-03-18 01:24:28 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-01 01:29:39 +00:00
|
|
|
if(match != null) {
|
|
|
|
words[words.length - 1] = match;
|
|
|
|
if(words.length == 1)
|
|
|
|
words[0] += ": ";
|
|
|
|
else
|
|
|
|
words[words.length - 1] += " ";
|
|
|
|
$("#chatline").val(words.join(" "));
|
2013-03-29 18:15:46 +00:00
|
|
|
}
|
2013-04-01 01:29:39 +00:00
|
|
|
ev.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(ev.keyCode == 38) {
|
|
|
|
if(CHATHISTIDX == CHATHIST.length) {
|
|
|
|
CHATHIST.push($("#chatline").val());
|
2013-03-29 18:15:46 +00:00
|
|
|
}
|
2013-04-01 01:29:39 +00:00
|
|
|
if(CHATHISTIDX > 0) {
|
|
|
|
CHATHISTIDX--;
|
|
|
|
$("#chatline").val(CHATHIST[CHATHISTIDX]);
|
|
|
|
}
|
2013-04-11 17:51:08 +00:00
|
|
|
|
2013-04-01 01:29:39 +00:00
|
|
|
ev.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(ev.keyCode == 40) {
|
|
|
|
if(CHATHISTIDX < CHATHIST.length - 1) {
|
|
|
|
CHATHISTIDX++;
|
|
|
|
$("#chatline").val(CHATHIST[CHATHISTIDX]);
|
|
|
|
}
|
2013-04-11 17:51:08 +00:00
|
|
|
|
2013-04-01 01:29:39 +00:00
|
|
|
ev.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#messagebuffer").mouseenter(function() { SCROLLCHAT = false; });
|
|
|
|
$("#messagebuffer").mouseleave(function() { SCROLLCHAT = true; });
|
2013-02-16 05:02:42 +00:00
|
|
|
|
2013-04-22 20:37:42 +00:00
|
|
|
$("#clearplaylist").click(function() {
|
|
|
|
socket.emit("clearqueue");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#shuffleplaylist").click(function() {
|
|
|
|
socket.emit("shufflequeue");
|
|
|
|
});
|
|
|
|
|
2013-04-17 19:05:45 +00:00
|
|
|
$("#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;
|
|
|
|
switch(data.pl[i].type) {
|
|
|
|
case "yt":
|
|
|
|
entry = "http://youtube.com/watch?v="+data.pl[i].id;
|
|
|
|
break;
|
|
|
|
case "vi":
|
|
|
|
entry = "http://vimeo.com/"+data.pl[i].id;
|
|
|
|
break;
|
|
|
|
case "dm":
|
|
|
|
entry = "http://dailymotion.com/video/"+data.pl[i].id;
|
|
|
|
break;
|
|
|
|
case "sc":
|
|
|
|
entry = data.pl[i].id;
|
|
|
|
break;
|
|
|
|
case "li":
|
|
|
|
entry = "http://livestream.com/"+data.pl[i].id;
|
|
|
|
break;
|
|
|
|
case "tw":
|
|
|
|
entry = "http://twitch.tv/"+data.pl[i].id;
|
|
|
|
break;
|
|
|
|
case "rt":
|
|
|
|
entry = data.pl[i].id;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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")
|
|
|
|
.appendTo(head)[0].innerHTML = "×";
|
|
|
|
$("<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();
|
|
|
|
});
|
|
|
|
modal.modal();
|
|
|
|
}
|
|
|
|
socket.on("playlist", callback);
|
|
|
|
socket.emit("requestPlaylist");
|
|
|
|
});
|
2013-03-30 05:55:25 +00:00
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#opt_submit").click(function() {
|
|
|
|
var ptitle = $("#opt_pagetitle").val();
|
|
|
|
if(ptitle == "")
|
|
|
|
ptitle = $("#opt_pagetitle").attr("placeholder")
|
2013-03-28 23:51:08 +00:00
|
|
|
var css = $("#opt_customcss").val();
|
2013-04-21 01:17:38 +00:00
|
|
|
var ratio = +$("#opt_voteskip_ratio").val() || 0.5;
|
2013-03-22 20:04:04 +00:00
|
|
|
opts = {
|
2013-03-24 17:23:48 +00:00
|
|
|
qopen_allow_qnext: $("#opt_qopen_allow_qnext").prop("checked"),
|
|
|
|
qopen_allow_move: $("#opt_qopen_allow_move").prop("checked"),
|
|
|
|
qopen_allow_delete: $("#opt_qopen_allow_delete").prop("checked"),
|
|
|
|
qopen_allow_playnext: $("#opt_qopen_allow_playnext").prop("checked"),
|
2013-04-02 19:07:22 +00:00
|
|
|
allow_voteskip: $("#opt_allow_voteskip").prop("checked"),
|
2013-04-21 01:17:38 +00:00
|
|
|
voteskip_ratio: ratio,
|
2013-03-22 20:04:04 +00:00
|
|
|
pagetitle: ptitle,
|
2013-04-16 16:11:10 +00:00
|
|
|
customcss: css,
|
2013-04-23 19:17:42 +00:00
|
|
|
customjs: $("#opt_customjs").val(),
|
|
|
|
chat_antiflood: $("#opt_chat_antiflood").prop("checked")
|
2013-03-22 20:04:04 +00:00
|
|
|
};
|
2013-03-24 17:23:48 +00:00
|
|
|
socket.emit("channelOpts", opts);
|
2013-03-22 20:04:04 +00:00
|
|
|
});
|
|
|
|
|
2013-04-01 21:02:09 +00:00
|
|
|
$("#updatemotd").click(function() {
|
|
|
|
var motd = $("#motdtext").val();
|
|
|
|
socket.emit("updateMotd", {
|
|
|
|
motd: motd
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#show_chancontrols").click(function() {
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#modnav li").each(function() {
|
|
|
|
$(this).removeClass("active");
|
|
|
|
});
|
2013-04-01 21:02:09 +00:00
|
|
|
$(".modonly").hide();
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#show_chancontrols").parent().addClass("active");
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#chancontrols").show();
|
2013-03-24 03:45:10 +00:00
|
|
|
});
|
|
|
|
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#show_banlist").click(function() {
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#modnav li").each(function() {
|
|
|
|
$(this).removeClass("active");
|
|
|
|
});
|
2013-04-01 21:02:09 +00:00
|
|
|
$(".modonly").hide();
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#show_banlist").parent().addClass("active");
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#banlist").show();
|
2013-04-01 21:02:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#show_motdeditor").click(function() {
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#modnav li").each(function() {
|
|
|
|
$(this).removeClass("active");
|
|
|
|
});
|
2013-04-01 21:02:09 +00:00
|
|
|
$(".modonly").hide();
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#show_motdeditor").parent().addClass("active");
|
2013-04-01 21:02:09 +00:00
|
|
|
$("#motdeditor").show();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#show_filtereditor").click(function() {
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#modnav li").each(function() {
|
|
|
|
$(this).removeClass("active");
|
|
|
|
});
|
2013-04-01 21:02:09 +00:00
|
|
|
$(".modonly").hide();
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#show_filtereditor").parent().addClass("active");
|
2013-04-01 21:02:09 +00:00
|
|
|
$("#filtereditor").show();
|
2013-03-24 03:45:10 +00:00
|
|
|
});
|
2013-02-16 05:02:42 +00:00
|
|
|
|
2013-04-22 18:28:40 +00:00
|
|
|
$("#show_acl").click(function() {
|
|
|
|
$("#modnav li").each(function() {
|
|
|
|
$(this).removeClass("active");
|
|
|
|
});
|
|
|
|
$(".modonly").hide();
|
|
|
|
$("#show_acl").parent().addClass("active");
|
|
|
|
$("#channelranks").show();
|
2013-04-23 18:47:09 +00:00
|
|
|
socket.emit("requestAcl");
|
2013-04-22 18:28:40 +00:00
|
|
|
});
|
|
|
|
|
2013-02-16 05:02:42 +00:00
|
|
|
function searchLibrary() {
|
2013-03-24 17:23:48 +00:00
|
|
|
socket.emit("searchLibrary", {
|
|
|
|
query: $("#library_query").val()
|
2013-02-16 05:02:42 +00:00
|
|
|
});
|
|
|
|
}
|
2013-03-24 17:23:48 +00:00
|
|
|
$("#library_search").click(searchLibrary);
|
|
|
|
$("#library_query").keydown(function(ev) {
|
2013-04-04 16:39:43 +00:00
|
|
|
if(ev.keyCode == 13)
|
2013-02-16 05:02:42 +00:00
|
|
|
searchLibrary();
|
|
|
|
});
|
|
|
|
|
2013-04-04 16:39:43 +00:00
|
|
|
$("#youtube_search").click(function() {
|
|
|
|
socket.emit("searchLibrary", {
|
|
|
|
query: $("#library_query").val(),
|
|
|
|
yt: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#largelayout").click(largeLayout);
|
|
|
|
$("#hugelayout").click(hugeLayout);
|
|
|
|
$("#narrowlayout").click(narrowLayout);
|
|
|
|
$("#stlayout").click(synchtubeLayout);
|
|
|
|
|
|
|
|
function largeLayout() {
|
|
|
|
$("#videodiv").removeClass().addClass("span8 offset2");
|
2013-04-19 19:00:10 +00:00
|
|
|
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//770
|
2013-03-31 22:30:46 +00:00
|
|
|
VHEIGHT = "430";
|
2013-04-19 19:00:10 +00:00
|
|
|
$("#ytapiplayer").attr("width", VWIDTH).attr("height", "430");
|
2013-04-01 01:29:39 +00:00
|
|
|
var chat = $("#chatdiv").detach();
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#layoutrow").remove();
|
2013-04-06 21:02:20 +00:00
|
|
|
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
|
2013-03-31 22:30:46 +00:00
|
|
|
r.attr("id", "layoutrow");
|
|
|
|
chat.removeClass().addClass("span8 offset2").appendTo(r);
|
2013-04-06 21:02:20 +00:00
|
|
|
$("#chatline").removeClass().addClass("span8");
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#userlist").css("width", "200px");
|
|
|
|
}
|
|
|
|
|
|
|
|
function hugeLayout() {
|
|
|
|
$("#videodiv").removeClass().addClass("span12");
|
2013-04-19 19:00:10 +00:00
|
|
|
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//1170
|
|
|
|
VHEIGHT = "658";
|
|
|
|
$("#ytapiplayer").attr("width", VWIDTH).attr("height", "658");
|
2013-04-01 01:29:39 +00:00
|
|
|
var chat = $("#chatdiv").detach();
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#layoutrow").remove();
|
2013-04-06 21:02:20 +00:00
|
|
|
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
|
2013-03-31 22:30:46 +00:00
|
|
|
r.attr("id", "layoutrow");
|
|
|
|
chat.removeClass().addClass("span12").appendTo(r);
|
2013-04-06 21:02:20 +00:00
|
|
|
$("#chatline").removeClass().addClass("span12");
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#userlist").css("width", "200px").css("height", "200px");
|
|
|
|
$("#messagebuffer").css("height", "200px");
|
|
|
|
}
|
|
|
|
|
|
|
|
function narrowLayout() {
|
2013-04-19 19:00:10 +00:00
|
|
|
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//570
|
2013-03-31 22:30:46 +00:00
|
|
|
VHEIGHT = "321";
|
|
|
|
$("#videodiv").removeClass().addClass("span6");
|
2013-04-19 19:00:10 +00:00
|
|
|
$("#ytapiplayer").attr("width", VWIDTH).attr("height", "321");
|
2013-04-01 01:29:39 +00:00
|
|
|
var chat = $("#chatdiv").detach();
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#layoutrow").remove();
|
2013-04-06 21:02:20 +00:00
|
|
|
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
|
2013-03-31 22:30:46 +00:00
|
|
|
r.attr("id", "layoutrow");
|
|
|
|
chat.removeClass().addClass("span6").appendTo(r);
|
2013-04-06 21:02:20 +00:00
|
|
|
$("#chatline").removeClass().addClass("span6");
|
2013-03-31 22:30:46 +00:00
|
|
|
$("#userlist").css("width", "150px");
|
|
|
|
}
|
|
|
|
|
|
|
|
function synchtubeLayout() {
|
2013-04-01 01:29:39 +00:00
|
|
|
$("#videodiv").detach().insertBefore($("#chatdiv"));
|
2013-03-31 22:30:46 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 05:02:42 +00:00
|
|
|
function onYouTubeIframeAPIReady() {
|
2013-04-07 19:38:50 +00:00
|
|
|
if(!PLAYER)
|
|
|
|
PLAYER = new Media({id: "", type: "yt"});
|
2013-02-16 05:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 + "=";
|
2013-03-24 17:23:48 +00:00
|
|
|
var ca = document.cookie.split(";");
|
2013-02-16 05:02:42 +00:00
|
|
|
for(var i=0;i < ca.length;i++) {
|
|
|
|
var c = ca[i];
|
2013-03-24 17:23:48 +00:00
|
|
|
while (c.charAt(0)==" ") c = c.substring(1,c.length);
|
2013-02-16 05:02:42 +00:00
|
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function eraseCookie(name) {
|
|
|
|
createCookie(name,"",-1);
|
|
|
|
}
|