2013-06-19 21:56:05 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
Copyright (c) 2013 Calvin Montgomery
|
2013-12-31 16:09:30 +00:00
|
|
|
|
2013-06-19 21:56:05 +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-12-31 16:09:30 +00:00
|
|
|
|
2013-06-19 21:56:05 +00:00
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
2013-12-31 16:09:30 +00:00
|
|
|
|
2013-06-19 21:56:05 +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-10-01 18:35:29 +00:00
|
|
|
var CL_VERSION = "2.4.3";
|
2013-06-19 23:39:40 +00:00
|
|
|
|
|
|
|
var CLIENT = {
|
|
|
|
rank: -1,
|
|
|
|
leader: false,
|
|
|
|
name: "",
|
|
|
|
logged_in: false,
|
|
|
|
profile: {
|
|
|
|
image: "",
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
};
|
2013-07-13 20:15:57 +00:00
|
|
|
var SUPERADMIN = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
|
|
|
|
var CHANNEL = {
|
|
|
|
opts: {},
|
|
|
|
openqueue: false,
|
|
|
|
perms: {},
|
|
|
|
css: "",
|
|
|
|
js: "",
|
|
|
|
motd: "",
|
2013-07-02 19:42:26 +00:00
|
|
|
motd_text: "",
|
2013-09-04 22:47:24 +00:00
|
|
|
name: false,
|
|
|
|
usercount: 0
|
2013-06-19 23:39:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var PLAYER = false;
|
2013-06-23 18:21:21 +00:00
|
|
|
var VIDEOQUALITY = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var FLUIDLAYOUT = false;
|
2013-08-05 04:51:28 +00:00
|
|
|
var VWIDTH;
|
|
|
|
var VHEIGHT;
|
|
|
|
if($("#videowidth").length > 0) {
|
|
|
|
VWIDTH = $("#videowidth").css("width").replace("px", "");
|
|
|
|
VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
|
|
|
|
}
|
2013-06-25 02:45:44 +00:00
|
|
|
var REBUILDING = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var socket = {
|
|
|
|
emit: function() {
|
|
|
|
console.log("socket not initialized");
|
|
|
|
console.log(arguments);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var IGNORED = [];
|
|
|
|
var CHATHIST = [];
|
|
|
|
var CHATHISTIDX = 0;
|
2013-11-19 21:14:40 +00:00
|
|
|
var CHATTHROTTLE = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var SCROLLCHAT = true;
|
|
|
|
var LASTCHATNAME = "";
|
|
|
|
var LASTCHATTIME = 0;
|
|
|
|
var FOCUSED = true;
|
|
|
|
var PAGETITLE = "CyTube";
|
|
|
|
var TITLE_BLINK;
|
2013-08-28 21:03:31 +00:00
|
|
|
var CHATSOUND = new Audio("assets/sounds/boop.wav");
|
2013-06-19 23:39:40 +00:00
|
|
|
var KICKED = false;
|
|
|
|
var NAME = readCookie("cytube_uname");
|
|
|
|
var SESSION = readCookie("cytube_session");
|
|
|
|
var LEADTMR = false;
|
2013-06-27 22:15:29 +00:00
|
|
|
var PL_FROM = "";
|
|
|
|
var PL_AFTER = "";
|
2013-09-11 03:43:43 +00:00
|
|
|
var PL_CURRENT = -1;
|
2013-07-27 14:30:12 +00:00
|
|
|
var PL_WAIT_SCROLL = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var FILTER_FROM = 0;
|
|
|
|
var FILTER_TO = 0;
|
2013-07-03 02:40:40 +00:00
|
|
|
var NO_STORAGE = typeof localStorage == "undefined" || localStorage === null;
|
|
|
|
|
|
|
|
function getOpt(k) {
|
|
|
|
return NO_STORAGE ? readCookie(k) : localStorage.getItem(k);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setOpt(k, v) {
|
|
|
|
NO_STORAGE ? createCookie(k, v, 1000) : localStorage.setItem(k, v);
|
|
|
|
}
|
2013-06-19 23:39:40 +00:00
|
|
|
|
|
|
|
function getOrDefault(k, def) {
|
2013-07-03 02:40:40 +00:00
|
|
|
var v = getOpt(k);
|
2013-06-19 23:39:40 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-01-08 01:24:03 +00:00
|
|
|
function default_noh264() {
|
|
|
|
var ua = navigator.userAgent + "";
|
|
|
|
if (ua.match(/Firefox\/29.0|Chrome|Chromium/)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-19 23:39:40 +00:00
|
|
|
var USEROPTS = {
|
2013-06-20 20:50:12 +00:00
|
|
|
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),
|
2013-08-06 15:42:20 +00:00
|
|
|
wmode_transparent : getOrDefault("wmode_transparent", true),
|
2013-06-20 20:50:12 +00:00
|
|
|
chatbtn : getOrDefault("chatbtn", false),
|
|
|
|
altsocket : getOrDefault("altsocket", false),
|
|
|
|
joinmessage : getOrDefault("joinmessage", true),
|
|
|
|
qbtn_hide : getOrDefault("qbtn_hide", false),
|
2013-06-20 22:15:35 +00:00
|
|
|
qbtn_idontlikechange : getOrDefault("qbtn_idontlikechange", false),
|
2013-06-26 02:03:14 +00:00
|
|
|
first_visit : getOrDefault("first_visit", true),
|
|
|
|
ignore_channelcss : getOrDefault("ignore_channelcss", false),
|
2013-08-11 21:39:10 +00:00
|
|
|
ignore_channeljs : getOrDefault("ignore_channeljs", false),
|
|
|
|
sort_rank : getOrDefault("sort_rank", false),
|
2013-08-15 04:26:50 +00:00
|
|
|
sort_afk : getOrDefault("sort_afk", false),
|
2013-08-28 21:03:31 +00:00
|
|
|
default_quality : getOrDefault("default_quality", "#quality_auto"),
|
2013-09-11 03:43:43 +00:00
|
|
|
boop : getOrDefault("boop", false),
|
2014-01-08 01:24:03 +00:00
|
|
|
secure_connection : getOrDefault("secure_connection", false),
|
|
|
|
no_h264 : getOrDefault("no_h264", default_noh264())
|
2013-06-19 23:39:40 +00:00
|
|
|
};
|
|
|
|
|
2014-01-02 05:13:45 +00:00
|
|
|
var VOLUME = getOrDefault("volume", 1);
|
|
|
|
|
2013-07-13 20:15:57 +00:00
|
|
|
var NO_WEBSOCKETS = USEROPTS.altsocket;
|
|
|
|
|
2013-06-19 23:39:40 +00:00
|
|
|
var Rank = {
|
|
|
|
Guest: 0,
|
|
|
|
Member: 1,
|
|
|
|
Leader: 1.5,
|
|
|
|
Moderator: 2,
|
|
|
|
Admin: 3,
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* to be implemented in callbacks.js */
|
|
|
|
function setupCallbacks() { }
|