Remove old files

This commit is contained in:
calzoneman 2013-06-19 17:56:52 -04:00
parent f85e7fdc16
commit 823e9bef33
5 changed files with 0 additions and 2962 deletions

View file

@ -1,135 +0,0 @@
/*
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.
*/
var RANK = 0;
var uname = readCookie("sync_uname");
var pw = readCookie("sync_pw");
var manageChannel = false;
var Rank = {
Guest: 0,
Member: 1,
Moderator: 2,
Owner: 3,
Siteadmin: 255
};
var socket = io.connect(IO_URL);
initCallbacks();
function initCallbacks() {
socket.on("adm", function(data) {
console.log(data);
if(data.cmd == "listchannels")
handleChannelList(data);
});
socket.on("login", function(data) {
if(data.success && $("#password").val()) {
createCookie("sync_uname", uname, 1);
createCookie("sync_pw", pw, 1);
}
if(data.success) {
$("#loggedin").css("display", "");
$("#logoutform").css("display", "");
$("#loginform").css("display", "none");
}
setInterval(function() {
socket.emit("adm", {
cmd: "listchannels"
});
}, 10000);
socket.emit("adm", {
cmd: "listchannels"
});
});
}
function handleChannelList(data) {
if($("#chanlist").children.length > 1)
$($("#chanlist").children()[1]).remove();
for(var i = 0; i < data.chans.length; i++) {
var row = $("<tr/>").appendTo($("#chanlist"));
var name = $("<td/>").appendTo(row).text(data.chans[i].name);
var usercount = $("<td/>").appendTo(row).text(data.chans[i].usercount);
var nowplaying = $("<td/>").appendTo(row).text(data.chans[i].nowplaying);
}
}
var params = {};
if(window.location.search) {
var parameters = window.location.search.substring(1).split("&");
for(var i = 0; i < parameters.length; i++) {
var s = parameters[i].split("=");
if(s.length != 2)
continue;
params[s[0]] = s[1];
}
}
if(uname != null && pw != null && pw != "false") {
socket.emit("login", {
name: uname,
pw: pw
});
}
function loginClick() {
uname = $("#username").val();
pw = $("#password").val();
socket.emit("login", {
name: uname,
pw: pw
});
};
$("#login").click(loginClick);
$("#username").keydown(function(ev) {
if(ev.key == 13)
loginClick();
});
$("#password").keydown(function(ev) {
if(ev.key == 13)
loginClick();
});
$("#logout").click(function() {
eraseCookie("sync_uname");
eraseCookie("sync_pw");
document.location.reload(true);
});
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);
}

View file

@ -1,756 +0,0 @@
/*
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.
*/
var socket;
var LEADER = false;
var PLAYER = new Media();
var MEDIATYPE = "null";
var POSITION = -1;
var RANK = -1;
var OPENQUEUE = false;
var CHANNELOPTS = {};
var CHANPERMS = {};
var GRABBEDLI = null;
var OLDINDEX = -1;
var CHATHIST = [];
var CHATHISTIDX = 0;
var FOCUSED = true;
var SCROLLCHAT = true;
var LASTCHATNAME = "";
var LASTCHATTIME = 0;
var PAGETITLE = "Sync";
var TITLE_BLINK;
var VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//670
var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
$("#messagebuffer").css("height", (VHEIGHT - 31) + "px");
$("#userlist").css("height", (VHEIGHT - 31) + "px");
var IGNORED = [];
var KICKED = false;
var CHANNEL = "";
var CUSTOMJS = "";
var uname = readCookie("sync_uname");
var session = readCookie("sync_session");
var PROFILE = {
image: "",
text: ""
};
function parseBool(x) {
if(typeof x == "boolean")
return x;
else if(x == "true")
return true;
else if(x == "false")
return false;
else return Boolean(x);
}
getOrDefault = function(k, def) {
var v = localStorage.getItem(k);
if(v === null)
return def;
if(v === "true")
return true;
if(v === "false")
return false;
if(v.match(/[0-9]+/))
return parseInt(v);
if(v.match(/[0-9\.]+/))
return parseFloat(v);
return v;
}
var USEROPTS = {
theme : getOrDefault("theme", "default"),
css : getOrDefault("css", ""),
layout : getOrDefault("layout", "default"),
synch : getOrDefault("synch", true),
hidevid : getOrDefault("hidevid", false),
show_timestamps : getOrDefault("show_timestamps", true),
modhat : getOrDefault("modhat", false),
blink_title : getOrDefault("blink_title", false),
sync_accuracy : getOrDefault("sync_accuracy", 2),
chatbtn : getOrDefault("chatbtn", false),
altsocket : getOrDefault("altsocket", false)
};
applyOpts();
$("#optlink").click(showUserOpts);
$("#sitefooter").load("footer.html");
var Rank = {
Guest: 0,
Member: 1,
Moderator: 2,
Owner: 3,
Siteadmin: 255
};
$(window).focus(function() {
FOCUSED = true;
onWindowFocus();
})
.blur(function() {
FOCUSED = false;
});
$(window).resize(function() {
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
$("#messagebuffer").css("height", (VHEIGHT - 31) + "px");
$("#userlist").css("height", (VHEIGHT - 31) + "px");
$("#ytapiplayer").attr("width", VWIDTH);
$("#ytapiplayer").attr("height", VHEIGHT);
});
// 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) {
CHANNEL = m[1];
}
else {
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) {
var host = ""+document.location;
host = host.replace("http://", "");
host = host.substring(0, host.indexOf("/"));
if(ev.keyCode == 13) {
document.location = "http://" + host + "/r/" + entry.val();
socket.emit("joinChannel", {
name: entry.val()
});
container.remove();
main.css("display", "");
}
});
}
// Load the youtube iframe API
if(!USEROPTS.hidevid) {
var tag = document.createElement("script");
tag.src = "http://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
$("#ulistchevron").click(function() {
var state = $("#userlist").css("display");
if(state == "none") {
$("#userlist").show();
$("#ulistchevron").removeClass().addClass("icon-chevron-up");
}
else {
$("#userlist").hide();
$("#ulistchevron").removeClass().addClass("icon-chevron-down");
}
});
var sendVideoUpdate = function() { }
setInterval(function() {
sendVideoUpdate();
}, 5000);
function queueEnd() {
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("");
}
if(type == "jw") {
makeAlert("JWPlayer",
"If you are queueing a file (not a livestream) with JWPlayer, please note it will only synchronize if you assign a leader.",
"alert-warning")
.insertAfter($("#playlist_controls"));
}
socket.emit("queue", {
id: id,
pos: "end",
type: type
});
}
}
$("#queue_end").click(queueEnd);
$("#mediaurl").keydown(function(ev) {
if(ev.keyCode == 13) {
queueEnd();
}
});
$("#queue_next").click(function() {
var urls = $("#mediaurl").val().split(",");
for(var i = urls.length - 1; i >= 0; i--) {
if(!urls[i].trim())
continue;
var parsed = parseVideoURL(urls[i].trim());
var id = parsed[0];
var type = parsed[1];
if(id) {
$("#mediaurl").val("");
}
if(type == "jw") {
makeAlert("JWPlayer",
"If you are queueing a file (not a livestream) with JWPlayer, please note it will only synchronize if you assign a leader.",
"alert-warning")
.insertAfter($("#playlist_controls"));
}
socket.emit("queue", {
id: id,
pos: "next",
type: type
});
}
});
$("#play_next").click(function() {
socket.emit("playNext");
});
$("#voteskip").click(function() {
socket.emit("voteskip");
$("#voteskip").attr("disabled", true);
});
$("#qlockbtn").click(function() {
socket.emit("queueLock", {
locked: OPENQUEUE
});
});
$("#login").click(showLoginFrame);
function guestLogin() {
uname = $("#guestname").val();
socket.emit("login", {
name: $("#guestname").val()
});
}
$("#guestlogin").click(guestLogin);
$("#guestname").keydown(function(ev) {
if(ev.keyCode == 13) {
guestLogin();
}
});
$("#logout").click(function() {
eraseCookie("sync_uname");
eraseCookie("sync_session");
document.location.reload(true);
});
$("#chatline").keydown(function(ev) {
if(ev.keyCode == 13 && $("#chatline").val() != "") {
if($("#chatline").val().trim() == "/poll") {
newPollMenu();
$("#chatline").val("");
}
else {
var msg = $("#chatline").val();
if(USEROPTS.modhat && RANK >= Rank.Moderator) {
msg = "/m " + msg
}
socket.emit("chatMsg", {
msg: msg
});
}
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;
}
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;
}
});
$("#messagebuffer").mouseenter(function() { SCROLLCHAT = false; });
$("#messagebuffer").mouseleave(function() { SCROLLCHAT = true; });
$("#clearplaylist").click(function() {
socket.emit("clearqueue");
});
$("#shuffleplaylist").click(function() {
socket.emit("shufflequeue");
});
$("#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 = idToURL(data.pl[i]);
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 = "&times;";
$("<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");
});
$("#opt_submit").click(function() {
var ptitle = $("#opt_pagetitle").val();
if(ptitle == "")
ptitle = $("#opt_pagetitle").attr("placeholder")
var css = $("#opt_customcss").val();
var ratio = +$("#opt_voteskip_ratio").val() || 0.5;
opts = {
allow_voteskip: $("#opt_allow_voteskip").prop("checked"),
voteskip_ratio: ratio,
pagetitle: ptitle,
customcss: css,
customjs: $("#opt_customjs").val(),
chat_antiflood: $("#opt_chat_antiflood").prop("checked"),
show_public: $("#opt_show_public").prop("checked"),
enable_link_regex: $("#opt_enable_link_regex").prop("checked")
};
socket.emit("channelOpts", opts);
});
$("#updatemotd").click(function() {
var motd = $("#motdtext").val();
socket.emit("updateMotd", {
motd: motd
});
});
$("#show_chancontrols").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_chancontrols").parent().addClass("active");
$("#chancontrols").show();
});
$("#show_chanperms").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_chanperms").parent().addClass("active");
$("#chanperms").show();
});
$("#show_banlist").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_banlist").parent().addClass("active");
$("#banlist").show();
});
$("#show_loginlog").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_loginlog").parent().addClass("active");
$("#loginlog").show();
socket.emit("requestSeenlogins");
});
$("#show_motdeditor").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_motdeditor").parent().addClass("active");
$("#motdeditor").show();
});
$("#show_csseditor").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_csseditor").parent().addClass("active");
$("#csseditor").show();
});
$("#updatecss").click(function() {
socket.emit("setChannelCSS", {
css: $("#csstext").val()
});
});
$("#show_jseditor").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_jseditor").parent().addClass("active");
$("#jseditor").show();
});
$("#updatejs").click(function() {
socket.emit("setChannelJS", {
js: $("#jstext").val()
});
});
$("#show_filtereditor").click(function() {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_filtereditor").parent().addClass("active");
$("#filtereditor").show();
});
$("#show_acl").click(function() {
if(RANK >= Rank.Owner) {
$("#modnav li").each(function() {
$(this).removeClass("active");
});
$(".modonly").hide();
$("#show_acl").parent().addClass("active");
$("#channelranks").show();
socket.emit("requestAcl");
}
else {
alert("Only channel administrators can use the ACL");
}
});
$("#drop_channel").click(function() {
var res = confirm("You are about to unregister your channel. This will PERMANENTLY delete your channel data, including ranks, bans, and library videos. This cannot be undone. Are you sure you want to continue?");
if(res) {
socket.emit("unregisterChannel");
}
});
function splitreEntry(str) {
var split = [];
var current = [];
for(var i = 0; i < str.length; i++) {
if(str[i] == "\\" && i+1 < str.length && str[i+1].match(/\s/)) {
current.push(str[i+1]);
i++;
continue;
}
else if(str[i].match(/\s/)) {
split.push(current.join(""));
current = [];
}
else {
current.push(str[i]);
}
}
split.push(current.join(""));
return split;
}
$("#multifilter").click(function() {
var input = $("#multifiltereditor").val();
var lines = input.split("\n");
for(var i = 0; i < lines.length; i++) {
var fields = splitreEntry(lines[i]);
var name = "";
var regex = "";
var flags = "";
var replace = "";
if(fields.length < 3) {
alert("Minimum of 3 fields per filter: (optional: name), regex, flags, replacement");
return;
}
else if(fields.length == 3) {
regex = fields[0];
flags = fields[1];
replace = fields[2];
}
else if(fields.length == 4) {
name = fields[0];
regex = fields[1];
flags = fields[2];
replace = fields[3];
}
else {
alert("Too many paramters: " + fields.join(" "));
return;
}
try {
new RegExp(regex, flags);
}
catch(e) {
alert("Invalid regex: " + e);
return;
}
socket.emit("chatFilter", {
cmd: "update",
filter: {
name: name,
source: regex,
flags: flags,
replace: replace,
active: true
}
});
}
});
function searchLibrary() {
socket.emit("searchLibrary", {
query: $("#library_query").val()
});
}
$("#library_search").click(searchLibrary);
$("#library_query").keydown(function(ev) {
if(ev.keyCode == 13)
searchLibrary();
});
function savePlaylist() {
if($("#userpl_name").val().trim() == "") {
makeAlert("Invalid Name", "Playlist name cannot be empty", "alert-error")
.addClass("span12")
.css("margin-left", "0")
.insertAfter($("#userpl_save").parent());
return;
}
socket.emit("savePlaylist", {
name: $("#userpl_name").val()
});
}
$("#userpl_save").click(savePlaylist);
$("#userpl_name").keydown(function(ev) {
if(ev.keyCode == 13) {
savePlaylist();
}
});
$("#show_userpl").click(function() {
$("#show_library").parent().removeClass("active");
$("#show_userpl").parent().addClass("active");
$("#libcontainer").hide();
$("#userplcontainer").show();
socket.emit("listPlaylists");
});
$("#show_library").click(function() {
$("#show_userpl").parent().removeClass("active");
$("#show_library").parent().addClass("active");
$("#userplcontainer").hide();
$("#libcontainer").show();
});
$("#youtube_search").click(function() {
socket.emit("searchLibrary", {
query: $("#library_query").val(),
yt: true
});
});
$("#search_clear").click(function() {
clearSearchResults();
});
function fluidLayout() {
$(".row").each(function() {
$(this).removeClass("row").addClass("row-fluid");
});
$(".container").each(function() {
$(this).removeClass("container").addClass("container-fluid");
});
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
$("#messagebuffer").css("height", (VHEIGHT - 31) + "px");
$("#userlist").css("height", (VHEIGHT - 31) + "px");
$("#ytapiplayer").attr("width", VWIDTH);
$("#ytapiplayer").attr("height", VHEIGHT);
$("#chatline").removeClass().addClass("span12");
}
function largeLayout() {
$("#videodiv").removeClass().addClass("span8 offset2");
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//770
VHEIGHT = "430";
$("#ytapiplayer").attr("width", VWIDTH).attr("height", "430");
var chat = $("#chatdiv").detach();
$("#layoutrow").remove();
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
r.attr("id", "layoutrow");
chat.removeClass().addClass("span8 offset2").appendTo(r);
$("#chatline").removeClass().addClass("span8");
$("#userlist").css("width", "200px");
}
function singleColumnLayout() {
$("#videodiv").removeClass().addClass("span12");
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
VHEIGHT = parseInt(VWIDTH) * 9 / 16;
$("#ytapiplayer").attr("width", VWIDTH).attr("height", VHEIGHT);
var chat = $("#chatdiv").detach();
$("#layoutrow").remove();
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
r.attr("id", "layoutrow");
chat.removeClass().addClass("span12").appendTo(r);
chat.css("height", "200px");
$("#messagebuffer").css("height", "100%");
$("#userlist").css("height", "100%");
$("#chatline").removeClass().addClass("span12");
$("#userlist").css("width", "200px");
var r2d2 = $("<div/>").addClass("row").insertBefore($("#queuerow"));
r2d2.css("margin-top", "60px");
var librow = $("#queuerow").attr("id", "");
librow.css("margin-top", "5px");
r2d2.attr("id", "queuerow");
$("#pollcontainer").detach().appendTo(r2d2).removeClass().addClass("span12");
$("#queuediv").detach().appendTo(r2d2).removeClass().addClass("span12");
$(librow.find(".span5")[0]).removeClass().addClass("span12");
}
function hugeLayout() {
$("#videodiv").removeClass().addClass("span12");
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//1170
VHEIGHT = "658";
$("#ytapiplayer").attr("width", VWIDTH).attr("height", "658");
var chat = $("#chatdiv").detach();
$("#layoutrow").remove();
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
r.attr("id", "layoutrow");
chat.removeClass().addClass("span12").appendTo(r);
$("#chatline").removeClass().addClass("span12");
$("#userlist").css("width", "200px").css("height", "200px");
$("#messagebuffer").css("height", "200px");
}
function narrowLayout() {
VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");//570
VHEIGHT = "321";
$("#videodiv").removeClass().addClass("span6");
$("#ytapiplayer").attr("width", VWIDTH).attr("height", "321");
var chat = $("#chatdiv").detach();
$("#layoutrow").remove();
var r = $("<div />").addClass("row").insertAfter($("#videodiv").parent());
r.attr("id", "layoutrow");
chat.removeClass().addClass("span6").appendTo(r);
$("#chatline").removeClass().addClass("span6");
$("#userlist").css("width", "150px");
}
function synchtubeLayout() {
$("#videodiv").detach().insertBefore($("#chatdiv"));
$("#queuediv").detach().prependTo($("#queuerow"));
}
function onYouTubeIframeAPIReady() {
if(PLAYER.type == "null")
PLAYER = new Media({id: "", type: "yt"});
if(USEROPTS.layout == "fluid") {
fluidLayout();
}
}
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);
}

File diff suppressed because it is too large Load diff

View file

@ -1,556 +0,0 @@
/*
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.
*/
var Media = function(data) {
if(!data) {
data = {
id: "",
type: "null"
};
}
this.id = data.id;
this.type = data.type;
this.diff = 0;
switch(this.type) {
case "yt":
this.initYouTube();
break;
case "vi":
this.initVimeo();
break;
case "dm":
this.initDailymotion();
break;
case "sc":
this.initSoundcloud();
break;
case "li":
this.initLivestream();
break;
case "tw":
this.initTwitch();
break;
case "jt":
this.initJustinTV();
break;
case "rt":
this.initRTMP();
break;
case "jw":
this.initJWPlayer();
break;
case "us":
this.initUstream();
break;
case "im":
this.initImgur();
break;
default:
this.nullPlayer();
break;
}
}
Media.prototype.nullPlayer = function() {
this.player = null;
this.load = function(data) { }
this.play = function() { }
this.pause = function() { }
this.getTime = function(callback) { }
this.seek = function(time) { }
}
Media.prototype.initYouTube = function() {
this.removeOld();
this.player = new YT.Player("ytapiplayer", {
height: VHEIGHT,
width: VWIDTH,
videoId: this.id,
playerVars: {
"autoplay": 1,
"controls": 1,
},
events: {
onReady: function() {
socket.emit("playerReady");
},
onStateChange: function(ev) {
if(PLAYER.paused && ev.data != YT.PlayerState.PAUSED
|| !PLAYER.paused && ev.data == YT.PlayerState.PAUSED) {
PLAYER.paused = (ev.data == YT.PlayerState.PAUSED);
sendVideoUpdate();
}
else {
PLAYER.paused = (ev.data == YT.PlayerState.PAUSED);
}
if(LEADER && ev.data == YT.PlayerState.ENDED) {
socket.emit("playNext");
}
}
}
});
$("#ytapiplayer").css("border", "none");
this.load = function(data) {
if(this.player.loadVideoById) {
this.player.loadVideoById(data.id, data.currentTime);
this.id = data.id;
}
}
this.pause = function() {
this.player.pauseVideo();
}
this.play = function() {
this.player.playVideo();
}
this.getTime = function(callback) {
callback(this.player.getCurrentTime());
}
this.seek = function(time) {
this.player.seekTo(time, true);
}
}
Media.prototype.initVimeo = function() {
var iframe = $("<iframe/>").insertBefore($("#ytapiplayer"));
$("#ytapiplayer").remove();
iframe.attr("id", "ytapiplayer");
iframe.attr("width", VWIDTH);
iframe.attr("height", VHEIGHT);
iframe.attr("src", "http://player.vimeo.com/video/"+this.id+"?api=1&player_id=ytapiplayer");
iframe.attr("webkitAllowFullScreen", "");
iframe.attr("mozallowfullscreen", "");
iframe.attr("allowFullScreen", "");
iframe.css("border", "none");
this.player = $f(iframe[0]);
$f(iframe[0]).addEvent("ready", function() {
socket.emit("playerReady");
this.player = $f(iframe[0]);
this.player.api("play");
this.player.addEvent("finish", function() {
if(LEADER) {
socket.emit("playNext");
}
});
this.player.addEvent("pause", function() {
PLAYER.paused = true;
sendVideoUpdate();
});
this.player.addEvent("play", function() {
PLAYER.paused = false;
sendVideoUpdate();
});
}.bind(this));
this.load = function(data) {
this.id = data.id;
this.initVimeo();
}
this.pause = function() {
this.player.api("pause");
}
this.play = function() {
this.player.api("play");
}
this.getTime = function(callback) {
// Vimeo api returns time as a string because fuck logic
this.player.api("getCurrentTime", function(time) {
callback(parseFloat(time));
});
}
this.seek = function(time) {
this.player.api("seekTo", time);
}
}
Media.prototype.initDailymotion = function() {
this.removeOld();
this.player = DM.player("ytapiplayer", {
video: this.id,
width: parseInt(VWIDTH),
height: parseInt(VHEIGHT),
params: {autoplay: 1}
});
this.player.addEventListener("apiready", function(e) {
socket.emit("playerReady");
this.player.addEventListener("ended", function(e) {
if(LEADER) {
socket.emit("playNext");
}
});
this.player.addEventListener("pause", function(e) {
PLAYER.paused = true;
sendVideoUpdate();
});
this.player.addEventListener("playing", function(e) {
PLAYER.paused = false;
sendVideoUpdate();
});
}.bind(this));
this.load = function(data) {
this.id = data.id;
this.player.api("load", data.id);
}
this.pause = function() {
this.player.api("pause");
}
this.play = function() {
this.player.api("play");
}
this.getTime = function(callback) {
callback(this.player.currentTime);
}
this.seek = function(seconds) {
this.player.api("seek", seconds);
}
}
Media.prototype.initSoundcloud = function() {
unfixSoundcloudShit();
var iframe = $("<iframe/>").insertBefore($("#ytapiplayer"));
$("#ytapiplayer").remove();
iframe.attr("id", "ytapiplayer");
iframe.attr("src", "https://w.soundcloud.com/player/?url=" + this.id);
iframe.css("width", "100%").attr("height", "166");
iframe.css("border", "none");
this.player = SC.Widget("ytapiplayer");
this.player.bind(SC.Widget.Events.READY, function() {
socket.emit("playerReady");
this.player.load(this.id, {auto_play: true});
this.player.bind(SC.Widget.Events.PAUSE, function() {
PLAYER.paused = true;
sendVideoUpdate();
});
this.player.bind(SC.Widget.Events.PLAY, function() {
PLAYER.paused = false;
sendVideoUpdate();
});
this.player.bind(SC.Widget.Events.FINISH, function() {
if(LEADER) {
socket.emit("playNext");
}
});
}.bind(this));
this.load = function(data) {
this.id = data.id;
this.player.load(data.id, {auto_play: true});
}
this.pause = function() {
this.player.pause();
}
this.play = function() {
this.player.play();
}
this.getTime = function(callback) {
this.player.getPosition(function(pos) {
callback(pos / 1000);
});
}
this.seek = function(seconds) {
this.player.seekTo(seconds * 1000);
}
}
Media.prototype.initLivestream = function() {
this.removeOld();
var flashvars = {channel: this.id};
var params = {AllowScriptAccess: "always"};
swfobject.embedSWF("http://cdn.livestream.com/chromelessPlayer/v20/playerapi.swf", "ytapiplayer", VWIDTH, VHEIGHT, "9.0.0", "expressInstall.swf", flashvars, params);
this.load = function(data) {
this.id = data.id;
this.initLivestream();
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.initTwitch = function() {
this.removeOld();
var url = "http://www.twitch.tv/widgets/live_embed_player.swf?channel="+this.id;
var params = {
allowFullScreen:"true",
allowScriptAccess:"always",
allowNetworking:"all",
movie:"http://www.twitch.tv/widgets/live_embed_player.swf",
id: "live_embed_player_flash",
flashvars:"hostname=www.twitch.tv&channel="+this.id+"&auto_play=true&start_volume=100"
};
swfobject.embedSWF( url, "ytapiplayer", VWIDTH, VHEIGHT, "8", null, null, params, {} );
this.load = function(data) {
this.id = data.id;
this.initTwitch();
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.initJustinTV = function() {
this.removeOld();
var url = "http://www.justin.tv/widgets/live_embed_player.swf?channel="+this.id;
var params = {
allowFullScreen:"true",
allowScriptAccess:"always",
allowNetworking:"all",
movie:"http://www.justin.tv/widgets/live_embed_player.swf",
id: "live_embed_player_flash",
flashvars:"hostname=www.justin.tv&channel="+this.id+"&auto_play=true&start_volume=100"
};
swfobject.embedSWF( url, "ytapiplayer", VWIDTH, VHEIGHT, "8", null, null, params, {} );
this.load = function(data) {
this.id = data.id;
this.initTwitch();
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.initRTMP = function() {
this.removeOld();
var url = "http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf";
var src = encodeURIComponent(this.id);
var params = {
allowFullScreen:"true",
allowScriptAccess:"always",
allowNetworking:"all",
wMode:"direct",
movie:"http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf",
flashvars:"src="+src+"&streamType=live&autoPlay=true"
};
swfobject.embedSWF(url, "ytapiplayer", VWIDTH, VHEIGHT, "8", null, null, params, {} );
this.load = function(data) {
this.id = data.id;
this.initTwitch();
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.initJWPlayer = function() {
if(typeof jwplayer == "undefined") {
setTimeout(function() {
this.initJWPlayer();
}.bind(this), 100);
return;
}
this.removeOld();
jwplayer("ytapiplayer").setup({
file: this.id,
width: VWIDTH,
height: VHEIGHT,
autostart: true
});
jwplayer().onPlay(function() {
this.paused = false;
}.bind(this));
jwplayer().onPause(function() {
this.paused = true;
}.bind(this));
jwplayer().onComplete(function() {
socket.emit("playNext");
});
this.load = function(data) {
this.id = data.id;
this.initJWPlayer();
}
this.pause = function() {
jwplayer().pause(true);
}
this.play = function() {
jwplayer().play(true);
}
this.getTime = function(callback) {
// Only return time for non-live media
if(jwplayer().getDuration() != -1) {
callback(jwplayer().getPosition());
}
}
this.seek = function(time) {
jwplayer().seek(time);
}
}
Media.prototype.initUstream = function() {
var iframe = $("<iframe/>").insertBefore($("#ytapiplayer"));
$("#ytapiplayer").remove();
iframe.attr("id", "ytapiplayer");
iframe.attr("width", VWIDTH);
iframe.attr("height", VHEIGHT);
iframe.attr("src", "http://www.ustream.tv/embed/"+this.id+"?v=3&wmode=direct");
iframe.attr("frameborder", "0");
iframe.attr("scrolling", "no");
iframe.css("border", "none");
this.load = function(data) {
this.id = data.id;
this.initUstream();
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.initImgur = function() {
var iframe = $("<iframe/>").insertBefore($("#ytapiplayer"));
$("#ytapiplayer").remove();
iframe.attr("id", "ytapiplayer");
iframe.attr("width", VWIDTH);
iframe.attr("height", VHEIGHT);
iframe.attr("src", "http://imgur.com/a/"+this.id+"/embed");
iframe.attr("frameborder", "0");
iframe.attr("scrolling", "no");
iframe.css("border", "none");
this.load = function(data) {
this.id = data.id;
this.initImgur()
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.update = function(data) {
if(data.id && data.id != this.id) {
if(data.currentTime < 0) {
data.currentTime = 0;
}
this.load(data);
}
if(!USEROPTS.synch) {
return;
}
if(data.paused) {
this.seek(data.currentTime);
this.pause();
}
else {
this.play();
}
if(LEADER) {
return;
}
this.getTime(function(seconds) {
var time = data.currentTime;
var diff = time - seconds || time;
if(diff > USEROPTS.sync_accuracy) {
this.seek(time);
}
else if(diff < -USEROPTS.sync_accuracy) {
this.seek(time + 1);
}
}.bind(this));
}
Media.prototype.removeOld = function() {
var old = $("#ytapiplayer");
var placeholder = $("<div/>").insertBefore(old);
old.remove();
placeholder.attr("id", "ytapiplayer");
}
Media.prototype.hide = function() {
if(!/chrome/ig.test(navigator.userAgent)) {
return;
}
this.size = {
width: $("#ytapiplayer").attr("width"),
height: $("#ytapiplayer").attr("height")
};
$("#ytapiplayer").attr("width", 1)
.attr("height", 1);
}
Media.prototype.unhide = function() {
if(!/chrome/ig.test(navigator.userAgent)) {
return;
}
$("#ytapiplayer").attr("width", this.size.width)
.attr("height", this.size.height);
}

View file

@ -1,127 +0,0 @@
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
**/
function SHA256(s){
var chrsz = 8;
var hexcase = 0;
function safe_add (x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function S (X, n) { return ( X >>> n ) | (X << (32 - n)); }
function R (X, n) { return ( X >>> n ); }
function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); }
function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); }
function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); }
function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); }
function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); }
function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); }
function core_sha256 (m, l) {
var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2);
var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
var W = new Array(64);
var a, b, c, d, e, f, g, h, i, j;
var T1, T2;
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >> 9) << 4) + 15] = l;
for ( var i = 0; i<m.length; i+=16 ) {
a = HASH[0];
b = HASH[1];
c = HASH[2];
d = HASH[3];
e = HASH[4];
f = HASH[5];
g = HASH[6];
h = HASH[7];
for ( var j = 0; j<64; j++) {
if (j < 16) W[j] = m[j + i];
else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
T2 = safe_add(Sigma0256(a), Maj(a, b, c));
h = g;
g = f;
f = e;
e = safe_add(d, T1);
d = c;
c = b;
b = a;
a = safe_add(T1, T2);
}
HASH[0] = safe_add(a, HASH[0]);
HASH[1] = safe_add(b, HASH[1]);
HASH[2] = safe_add(c, HASH[2]);
HASH[3] = safe_add(d, HASH[3]);
HASH[4] = safe_add(e, HASH[4]);
HASH[5] = safe_add(f, HASH[5]);
HASH[6] = safe_add(g, HASH[6]);
HASH[7] = safe_add(h, HASH[7]);
}
return HASH;
}
function str2binb (str) {
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz) {
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
}
return bin;
}
function Utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
function binb2hex (binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++) {
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
s = Utf8Encode(s);
return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
}