Fix polls, MOTD/CSS/JS text

This commit is contained in:
calzoneman 2013-06-19 19:39:40 -04:00
parent db1682fc35
commit e52307cdfa
4 changed files with 130 additions and 119 deletions

View File

@ -1446,7 +1446,7 @@ Channel.prototype.tryVote = function(user, data) {
if(!this.hasPermission(user, "pollvote")) { if(!this.hasPermission(user, "pollvote")) {
return; return;
} }
if(data.option == undefined) { if(typeof data.option !== "number") {
return; return;
} }

View File

@ -99,7 +99,9 @@ Callbacks = {
}, },
setMotd: function(data) { setMotd: function(data) {
CHANNEL.motd = data.html;
$("#motd").html(data.html); $("#motd").html(data.html);
$("#motdtext").val(CHANNEL.motd);
if(data.motd != "") if(data.motd != "")
$("#motd").show(); $("#motd").show();
else else
@ -336,6 +338,9 @@ Callbacks = {
$("#chancss").remove(); $("#chancss").remove();
$("#chanjs").remove(); $("#chanjs").remove();
CHANNEL.css = data.css;
CHANNEL.js = data.js;
$("#csstext").val(data.css); $("#csstext").val(data.css);
$("#jstext").val(data.js); $("#jstext").val(data.js);
@ -811,6 +816,7 @@ Callbacks = {
for(var i = 0; i < data.options.length; i++) { for(var i = 0; i < data.options.length; i++) {
(function(i) { (function(i) {
var callback = function() { var callback = function() {
console.log("vote", i);
socket.emit("vote", { socket.emit("vote", {
option: i option: i
}); });
@ -830,7 +836,7 @@ Callbacks = {
}, },
updatePoll: function(data) { updatePoll: function(data) {
var poll = $("#pollcontainer .active"); var poll = $("#pollwrap .active");
var i = 0; var i = 0;
poll.find(".option button").each(function() { poll.find(".option button").each(function() {
$(this).text(data.counts[i]); $(this).text(data.counts[i]);

View File

@ -26,7 +26,10 @@ var CHANNEL = {
opts: {}, opts: {},
openqueue: false, openqueue: false,
perms: {}, perms: {},
name: false // TODO load name from URL css: "",
js: "",
motd: "",
name: false
}; };
var PLAYER = false; var PLAYER = false;

View File

@ -65,7 +65,6 @@ function formatUserlistItem(div, data) {
name.addClass(getNameColor(data.rank)); name.addClass(getNameColor(data.rank));
div.find(".profile-box").remove(); div.find(".profile-box").remove();
// TODO might remove this
var profile; var profile;
name.mouseenter(function(ev) { name.mouseenter(function(ev) {
profile = $("<div/>") profile = $("<div/>")
@ -681,6 +680,9 @@ function handlePermissionChange() {
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex); $("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip); $("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio); $("#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("#permedit_tab", CLIENT.rank >= 3);
setVisible("#banlist_tab", hasPermission("ban")); setVisible("#banlist_tab", hasPermission("ban"));
setVisible("#motdedit_tab", hasPermission("motdedit")); setVisible("#motdedit_tab", hasPermission("motdedit"));