mirror of https://github.com/calzoneman/sync.git
Fix polls, MOTD/CSS/JS text
This commit is contained in:
parent
db1682fc35
commit
e52307cdfa
|
@ -1446,7 +1446,7 @@ Channel.prototype.tryVote = function(user, data) {
|
|||
if(!this.hasPermission(user, "pollvote")) {
|
||||
return;
|
||||
}
|
||||
if(data.option == undefined) {
|
||||
if(typeof data.option !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,9 @@ Callbacks = {
|
|||
},
|
||||
|
||||
setMotd: function(data) {
|
||||
CHANNEL.motd = data.html;
|
||||
$("#motd").html(data.html);
|
||||
$("#motdtext").val(CHANNEL.motd);
|
||||
if(data.motd != "")
|
||||
$("#motd").show();
|
||||
else
|
||||
|
@ -336,6 +338,9 @@ Callbacks = {
|
|||
$("#chancss").remove();
|
||||
$("#chanjs").remove();
|
||||
|
||||
CHANNEL.css = data.css;
|
||||
CHANNEL.js = data.js;
|
||||
|
||||
$("#csstext").val(data.css);
|
||||
$("#jstext").val(data.js);
|
||||
|
||||
|
@ -811,6 +816,7 @@ Callbacks = {
|
|||
for(var i = 0; i < data.options.length; i++) {
|
||||
(function(i) {
|
||||
var callback = function() {
|
||||
console.log("vote", i);
|
||||
socket.emit("vote", {
|
||||
option: i
|
||||
});
|
||||
|
@ -830,7 +836,7 @@ Callbacks = {
|
|||
},
|
||||
|
||||
updatePoll: function(data) {
|
||||
var poll = $("#pollcontainer .active");
|
||||
var poll = $("#pollwrap .active");
|
||||
var i = 0;
|
||||
poll.find(".option button").each(function() {
|
||||
$(this).text(data.counts[i]);
|
||||
|
|
|
@ -9,119 +9,122 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
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 CL_VERSION = "2.0.0";
|
||||
|
||||
var CLIENT = {
|
||||
rank: -1,
|
||||
leader: false,
|
||||
name: "",
|
||||
logged_in: false,
|
||||
profile: {
|
||||
image: "",
|
||||
text: ""
|
||||
}
|
||||
};
|
||||
|
||||
var CHANNEL = {
|
||||
opts: {},
|
||||
openqueue: false,
|
||||
perms: {},
|
||||
name: false // TODO load name from URL
|
||||
};
|
||||
|
||||
var PLAYER = false;
|
||||
var FLUIDLAYOUT = false;
|
||||
var VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
|
||||
var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
|
||||
var POSITION = -1;
|
||||
var socket = {
|
||||
emit: function() {
|
||||
console.log("socket not initialized");
|
||||
console.log(arguments);
|
||||
}
|
||||
};
|
||||
var IGNORED = [];
|
||||
var CHATHIST = [];
|
||||
var CHATHISTIDX = 0;
|
||||
var SCROLLCHAT = true;
|
||||
var LASTCHATNAME = "";
|
||||
var LASTCHATTIME = 0;
|
||||
var FOCUSED = true;
|
||||
var PAGETITLE = "CyTube";
|
||||
var TITLE_BLINK;
|
||||
var KICKED = false;
|
||||
var NAME = readCookie("cytube_uname");
|
||||
var SESSION = readCookie("cytube_session");
|
||||
var LEADTMR = false;
|
||||
var PL_FROM = 0;
|
||||
var PL_TO = 0;
|
||||
var FILTER_FROM = 0;
|
||||
var FILTER_TO = 0;
|
||||
|
||||
function getOrDefault(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),
|
||||
joinmessage : getOrDefault("joinmessage", true)
|
||||
};
|
||||
|
||||
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() { }
|
||||
var CL_VERSION = "2.0.0";
|
||||
|
||||
var CLIENT = {
|
||||
rank: -1,
|
||||
leader: false,
|
||||
name: "",
|
||||
logged_in: false,
|
||||
profile: {
|
||||
image: "",
|
||||
text: ""
|
||||
}
|
||||
};
|
||||
|
||||
var CHANNEL = {
|
||||
opts: {},
|
||||
openqueue: false,
|
||||
perms: {},
|
||||
css: "",
|
||||
js: "",
|
||||
motd: "",
|
||||
name: false
|
||||
};
|
||||
|
||||
var PLAYER = false;
|
||||
var FLUIDLAYOUT = false;
|
||||
var VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
|
||||
var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
|
||||
var POSITION = -1;
|
||||
var socket = {
|
||||
emit: function() {
|
||||
console.log("socket not initialized");
|
||||
console.log(arguments);
|
||||
}
|
||||
};
|
||||
var IGNORED = [];
|
||||
var CHATHIST = [];
|
||||
var CHATHISTIDX = 0;
|
||||
var SCROLLCHAT = true;
|
||||
var LASTCHATNAME = "";
|
||||
var LASTCHATTIME = 0;
|
||||
var FOCUSED = true;
|
||||
var PAGETITLE = "CyTube";
|
||||
var TITLE_BLINK;
|
||||
var KICKED = false;
|
||||
var NAME = readCookie("cytube_uname");
|
||||
var SESSION = readCookie("cytube_session");
|
||||
var LEADTMR = false;
|
||||
var PL_FROM = 0;
|
||||
var PL_TO = 0;
|
||||
var FILTER_FROM = 0;
|
||||
var FILTER_TO = 0;
|
||||
|
||||
function getOrDefault(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),
|
||||
joinmessage : getOrDefault("joinmessage", true)
|
||||
};
|
||||
|
||||
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() { }
|
||||
|
|
|
@ -65,7 +65,6 @@ function formatUserlistItem(div, data) {
|
|||
name.addClass(getNameColor(data.rank));
|
||||
div.find(".profile-box").remove();
|
||||
|
||||
// TODO might remove this
|
||||
var profile;
|
||||
name.mouseenter(function(ev) {
|
||||
profile = $("<div/>")
|
||||
|
@ -681,6 +680,9 @@ function handlePermissionChange() {
|
|||
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
|
||||
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
|
||||
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
|
||||
$("#csstext").val(CHANNEL.css);
|
||||
$("#jstext").val(CHANNEL.js);
|
||||
$("#motdtext").val(CHANNEL.motd);
|
||||
setVisible("#permedit_tab", CLIENT.rank >= 3);
|
||||
setVisible("#banlist_tab", hasPermission("ban"));
|
||||
setVisible("#motdedit_tab", hasPermission("motdedit"));
|
||||
|
|
Loading…
Reference in New Issue