sync/www/js/ui.js

711 lines
20 KiB
JavaScript
Raw Normal View History

2013-06-19 21:56:05 +00:00
/*
The MIT License (MIT)
Copyright (c) 2013 Calvin Montgomery
2014-01-26 06:01:36 +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:
2014-01-26 06:01:36 +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.
2014-01-26 06:01:36 +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-06-20 04:42:20 +00:00
/* window focus/blur */
$(window).focus(function() {
FOCUSED = true;
clearInterval(TITLE_BLINK);
TITLE_BLINK = false;
document.title = PAGETITLE;
}).blur(function() {
FOCUSED = false;
});
2013-10-03 03:26:28 +00:00
$("#togglemotd").click(function () {
var hidden = $("#motd").css("display") === "none";
$("#motd").toggle();
if (hidden) {
$("#togglemotd").find(".glyphicon-plus")
.removeClass("glyphicon-plus")
.addClass("glyphicon-minus");
2013-10-03 03:26:28 +00:00
} else {
$("#togglemotd").find(".glyphicon-minus")
.removeClass("glyphicon-minus")
.addClass("glyphicon-plus");
2013-10-03 03:26:28 +00:00
}
});
2013-06-07 03:13:24 +00:00
/* chatbox */
$("#modflair").click(function () {
var m = $("#modflair");
if (m.hasClass("label-success")) {
USEROPTS.modhat = false;
m.removeClass("label-success")
.addClass("label-default");
} else {
USEROPTS.modhat = true;
m.removeClass("label-default")
.addClass("label-success");
}
});
$("#adminflair").click(function () {
var m = $("#adminflair");
2013-12-19 17:14:48 +00:00
if (m.hasClass("label-danger")) {
USEROPTS.adminhat = false;
2013-12-19 17:14:48 +00:00
m.removeClass("label-danger")
.addClass("label-default");
} else {
USEROPTS.adminhat = true;
m.removeClass("label-default")
2013-12-19 17:14:48 +00:00
.addClass("label-danger");
}
});
$("#usercount").mouseenter(function (ev) {
var breakdown = calcUserBreakdown();
// re-using profile-box class for convenience
var popup = $("<div/>")
.addClass("profile-box")
2014-01-30 04:50:14 +00:00
.css("top", (ev.clientY + 5) + "px")
.css("left", (ev.clientX) + "px")
.appendTo($("#usercount"));
var contents = "";
for(var key in breakdown) {
contents += "<strong>" + key + ":&nbsp;</strong>" + breakdown[key];
contents += "<br>"
}
popup.html(contents);
});
$("#usercount").mousemove(function (ev) {
var popup = $("#usercount").find(".profile-box");
if(popup.length == 0)
return;
2014-01-30 04:50:14 +00:00
popup.css("top", (ev.clientY + 5) + "px");
popup.css("left", (ev.clientX) + "px");
});
$("#usercount").mouseleave(function () {
$("#usercount").find(".profile-box").remove();
});
2013-06-20 04:42:20 +00:00
$("#messagebuffer").mouseenter(function() { SCROLLCHAT = false; });
$("#messagebuffer").mouseleave(function() { SCROLLCHAT = true; });
2014-01-06 15:55:12 +00:00
$("#guestname").keydown(function (ev) {
if (ev.keyCode === 13) {
socket.emit("login", {
name: $("#guestname").val()
});
}
});
function chatTabComplete() {
var words = $("#chatline").val().split(" ");
var current = words[words.length - 1].toLowerCase();
2014-01-31 05:17:19 +00:00
if (!current.match(/^[\w-]{1,20}$/)) {
return;
}
2014-01-31 17:01:51 +00:00
var __slice = Array.prototype.slice;
2014-03-20 03:17:57 +00:00
var usersWithCap = __slice.call($("#userlist").children()).map(function (elem) {
return elem.children[1].innerHTML;
});
var users = __slice.call(usersWithCap).map(function (user) {
return user.toLowerCase();
2014-01-31 17:01:51 +00:00
}).filter(function (name) {
2014-02-28 06:09:20 +00:00
return name.indexOf(current) === 0;
});
// users now contains a list of names that start with current word
2014-01-31 17:01:51 +00:00
if (users.length === 0) {
return;
}
2014-01-31 17:01:51 +00:00
// trim possible names to the shortest possible completion
var min = Math.min.apply(Math, users.map(function (name) {
return name.length;
}));
2014-01-31 17:01:51 +00:00
users = users.map(function (name) {
return name.substring(0, min);
});
// continually trim off letters until all prefixes are the same
var changed = true;
var iter = 21;
while (changed) {
changed = false;
var first = users[0];
for (var i = 1; i < users.length; i++) {
if (users[i] !== first) {
changed = true;
2014-02-01 18:42:49 +00:00
break;
2014-01-31 17:01:51 +00:00
}
}
if (changed) {
2014-02-01 18:42:49 +00:00
users = users.map(function (name) {
return name.substring(0, name.length - 1);
});
2014-01-31 17:01:51 +00:00
}
// In the event something above doesn't generate a break condition, limit
// the maximum number of repetitions
if (--iter < 0) {
break;
}
}
current = users[0].substring(0, min);
2014-03-20 03:17:57 +00:00
for (var i = 0; i < usersWithCap.length; i++) {
if (usersWithCap[i].toLowerCase() === current) {
current = usersWithCap[i];
break;
}
}
if (users.length === 1) {
if (words.length === 1) {
current += ":";
}
current += " ";
}
words[words.length - 1] = current;
$("#chatline").val(words.join(" "));
}
2013-06-09 18:03:41 +00:00
$("#chatline").keydown(function(ev) {
2013-12-15 03:59:47 +00:00
// Enter/return
2013-06-07 03:13:24 +00:00
if(ev.keyCode == 13) {
2013-11-19 21:14:40 +00:00
if (CHATTHROTTLE) {
return;
}
2013-06-07 03:13:24 +00:00
var msg = $("#chatline").val();
if(msg.trim()) {
2013-11-17 19:12:56 +00:00
var meta = {};
if (USEROPTS.adminhat && CLIENT.rank >= 255) {
msg = "/a " + msg;
2013-11-17 19:12:56 +00:00
} else if (USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) {
meta.modflair = CLIENT.rank;
2013-06-07 03:13:24 +00:00
}
2013-12-15 03:59:47 +00:00
// The /m command no longer exists, so emulate it clientside
2013-11-17 19:12:56 +00:00
if (CLIENT.rank >= 2 && msg.indexOf("/m ") === 0) {
meta.modflair = CLIENT.rank;
2013-11-21 23:46:33 +00:00
msg = msg.substring(3);
2013-11-17 19:12:56 +00:00
}
2013-06-07 03:13:24 +00:00
socket.emit("chatMsg", {
2013-11-17 19:12:56 +00:00
msg: msg,
meta: meta
2013-06-07 03:13:24 +00:00
});
CHATHIST.push($("#chatline").val());
2013-06-19 21:54:27 +00:00
CHATHISTIDX = CHATHIST.length;
2013-06-07 03:13:24 +00:00
$("#chatline").val("");
}
return;
}
2013-12-15 03:59:47 +00:00
else if(ev.keyCode == 9) { // Tab completion
chatTabComplete();
2013-06-07 03:13:24 +00:00
ev.preventDefault();
return false;
}
2013-12-15 03:59:47 +00:00
else if(ev.keyCode == 38) { // Up arrow (input history)
2013-06-07 03:13:24 +00:00
if(CHATHISTIDX == CHATHIST.length) {
CHATHIST.push($("#chatline").val());
}
if(CHATHISTIDX > 0) {
CHATHISTIDX--;
$("#chatline").val(CHATHIST[CHATHISTIDX]);
}
ev.preventDefault();
return false;
}
2013-12-15 03:59:47 +00:00
else if(ev.keyCode == 40) { // Down arrow (input history)
2013-06-07 03:13:24 +00:00
if(CHATHISTIDX < CHATHIST.length - 1) {
CHATHISTIDX++;
$("#chatline").val(CHATHIST[CHATHISTIDX]);
}
ev.preventDefault();
return false;
}
});
/* poll controls */
$("#newpollbtn").click(showPollMenu);
/* search controls */
$("#library_search").click(function() {
socket.emit("searchMedia", {
source: "library",
query: $("#library_query").val().toLowerCase()
});
});
$("#library_query").keydown(function(ev) {
if(ev.keyCode == 13) {
socket.emit("searchMedia", {
source: "library",
query: $("#library_query").val().toLowerCase()
});
}
});
$("#youtube_search").click(function () {
var query = $("#library_query").val().toLowerCase();
if(parseMediaLink(query).type !== null) {
makeAlert("Media Link", "If you already have the link, paste it " +
"in the 'Media URL' box under Playlist Controls. This "+
"searchbar works like YouTube's search function.",
2013-12-15 03:59:47 +00:00
"alert-danger")
.insertBefore($("#library"));
}
2013-06-07 03:13:24 +00:00
socket.emit("searchMedia", {
source: "yt",
query: query
2013-06-07 03:13:24 +00:00
});
});
/* user playlists */
$("#userpl_save").click(function() {
if($("#userpl_name").val().trim() == "") {
2013-12-15 03:59:47 +00:00
makeAlert("Invalid Name", "Playlist name cannot be empty", "alert-danger")
2013-06-07 03:13:24 +00:00
.insertAfter($("#userpl_save").parent());
return;
}
2014-02-02 18:41:41 +00:00
socket.emit("clonePlaylist", {
2013-06-07 03:13:24 +00:00
name: $("#userpl_name").val()
});
});
2013-06-23 18:21:21 +00:00
/* video controls */
2013-06-30 19:56:41 +00:00
$("#mediarefresh").click(function() {
PLAYER.type = "";
PLAYER.id = "";
2013-12-15 03:59:47 +00:00
// playerReady triggers the server to send a changeMedia.
// the changeMedia handler then reloads the player
2013-06-30 19:56:41 +00:00
socket.emit("playerReady");
});
2013-06-07 03:13:24 +00:00
/* playlist controls */
2013-06-07 22:09:36 +00:00
2013-06-11 19:41:03 +00:00
$("#queue").sortable({
start: function(ev, ui) {
2013-06-29 22:09:20 +00:00
PL_FROM = ui.item.data("uid");
2013-06-11 19:41:03 +00:00
},
update: function(ev, ui) {
var prev = ui.item.prevAll();
if(prev.length == 0)
2013-06-29 22:09:20 +00:00
PL_AFTER = "prepend";
else
2013-06-29 22:09:20 +00:00
PL_AFTER = $(prev[0]).data("uid");
socket.emit("moveMedia", {
from: PL_FROM,
after: PL_AFTER
});
2013-10-04 03:11:47 +00:00
$("#queue").sortable("cancel");
2013-06-11 19:41:03 +00:00
}
2013-06-09 18:03:41 +00:00
});
2013-06-11 19:41:03 +00:00
$("#queue").disableSelection();
2013-06-09 18:03:41 +00:00
2014-01-14 06:52:56 +00:00
function queue(pos, src) {
if (!src) {
src = "url";
}
if (src === "customembed") {
var title = $("#customembed-title").val();
if (!title) {
title = false;
}
2014-01-14 06:52:56 +00:00
var content = $("#customembed-content").val();
2013-08-03 19:10:06 +00:00
socket.emit("queue", {
2014-01-14 06:52:56 +00:00
id: content,
title: title,
2014-01-14 06:52:56 +00:00
pos: pos,
2014-02-09 06:24:20 +00:00
type: "cu",
temp: $(".add-temp").prop("checked")
2013-08-03 19:10:06 +00:00
});
2014-01-14 06:52:56 +00:00
} else {
var link = $("#mediaurl").val();
2013-06-07 22:09:36 +00:00
var data = parseMediaLink(link);
2014-02-10 02:10:11 +00:00
var duration = undefined;
if (link.indexOf("jw:") === 0) {
duration = parseInt($("#addfromurl-duration-val").val());
if (duration <= 0 || isNaN(duration)) {
duration = undefined;
}
}
2014-01-14 06:52:56 +00:00
if (data.id == null || data.type == null) {
makeAlert("Error", "Failed to parse link. Please check that it is correct",
"alert-danger")
.insertAfter($("#addfromurl"));
} else {
$("#mediaurl").val("");
2014-02-10 02:10:11 +00:00
$("#addfromurl-duration").remove();
2014-01-14 06:52:56 +00:00
socket.emit("queue", {
id: data.id,
type: data.type,
2014-02-09 06:24:20 +00:00
pos: pos,
2014-02-10 02:10:11 +00:00
duration: duration,
2014-02-09 06:24:20 +00:00
temp: $(".add-temp").prop("checked")
2014-01-14 06:52:56 +00:00
});
}
}
2013-06-07 22:09:36 +00:00
}
2014-01-14 06:52:56 +00:00
$("#queue_next").click(queue.bind(this, "next", "url"));
$("#queue_end").click(queue.bind(this, "end", "url"));
$("#ce_queue_next").click(queue.bind(this, "next", "customembed"));
$("#ce_queue_end").click(queue.bind(this, "end", "customembed"));
2013-06-07 22:09:36 +00:00
2014-02-10 02:10:11 +00:00
$("#mediaurl").keyup(function(ev) {
2014-01-14 06:52:56 +00:00
if (ev.keyCode === 13) {
queue("end", "url");
2014-02-10 02:10:11 +00:00
} else if ($("#mediaurl").val().indexOf("jw:") === 0) {
var duration = $("#addfromurl-duration");
if (duration.length === 0) {
duration = $("<div/>")
.attr("id", "addfromurl-duration")
.appendTo($("#addfromurl"));
$("<span/>").text("JWPlayer Duration (seconds) (optional)")
.appendTo(duration);
$("<input/>").addClass("form-control")
.attr("type", "text")
.attr("id", "addfromurl-duration-val")
.appendTo($("#addfromurl-duration"));
}
} else {
$("#addfromurl-duration").remove();
2014-01-14 06:52:56 +00:00
}
2013-06-07 22:09:36 +00:00
});
2014-01-14 06:52:56 +00:00
$("#customembed-content").keydown(function(ev) {
if (ev.keyCode === 13) {
queue("end", "customembed");
2013-06-07 22:09:36 +00:00
}
});
$("#qlockbtn").click(function() {
socket.emit("togglePlaylistLock");
});
2013-06-18 20:18:41 +00:00
$("#voteskip").click(function() {
socket.emit("voteskip");
2013-07-24 19:11:50 +00:00
$("#voteskip").attr("disabled", true);
2013-06-18 20:18:41 +00:00
});
2013-06-07 22:09:36 +00:00
$("#getplaylist").click(function() {
var callback = function(data) {
hidePlayer();
2013-06-07 22:09:36 +00:00
socket.listeners("playlist").splice(
socket.listeners("playlist").indexOf(callback)
);
var list = [];
2013-06-11 19:41:03 +00:00
for(var i = 0; i < data.length; i++) {
2013-07-12 20:10:06 +00:00
var entry = formatURL(data[i].media);
2013-06-07 22:09:36 +00:00
list.push(entry);
}
var urls = list.join(",");
2013-12-15 03:59:47 +00:00
var outer = $("<div/>").addClass("modal fade")
2013-06-07 22:09:36 +00:00
.appendTo($("body"));
2013-12-15 03:59:47 +00:00
modal = $("<div/>").addClass("modal-dialog").appendTo(outer);
modal = $("<div/>").addClass("modal-content").appendTo(modal);
2013-06-07 22:09:36 +00:00
var head = $("<div/>").addClass("modal-header")
.appendTo(modal);
$("<button/>").addClass("close")
.attr("data-dismiss", "modal")
.attr("aria-hidden", "true")
.html("&times;")
.appendTo(head);
$("<h3/>").text("Playlist URLs").appendTo(head);
var body = $("<div/>").addClass("modal-body").appendTo(modal);
2013-12-15 03:59:47 +00:00
$("<input/>").addClass("form-control").attr("type", "text")
2013-06-07 22:09:36 +00:00
.val(urls)
.appendTo(body);
$("<div/>").addClass("modal-footer").appendTo(modal);
2013-12-15 03:59:47 +00:00
outer.on("hidden", function() {
outer.remove();
unhidePlayer();
2013-06-07 22:09:36 +00:00
});
2013-12-15 03:59:47 +00:00
outer.modal();
};
2013-06-07 22:09:36 +00:00
socket.on("playlist", callback);
socket.emit("requestPlaylist");
});
$("#clearplaylist").click(function() {
var clear = confirm("Are you sure you want to clear the playlist?");
if(clear) {
socket.emit("clearPlaylist");
}
});
$("#shuffleplaylist").click(function() {
2013-06-11 19:41:03 +00:00
var shuffle = confirm("Are you sure you want to shuffle the playlist?");
if(shuffle) {
2013-06-07 22:09:36 +00:00
socket.emit("shufflePlaylist");
}
});
2013-06-11 15:29:21 +00:00
/* load channel */
var loc = document.location+"";
2013-12-25 21:18:21 +00:00
var m = loc.match(/\/r\/([a-zA-Z0-9-_#]+)$/);
2013-06-11 15:29:21 +00:00
if(m) {
CHANNEL.name = m[1];
2013-12-25 21:18:21 +00:00
if (CHANNEL.name.indexOf("#") !== -1) {
CHANNEL.name = CHANNEL.name.substring(0, CHANNEL.name.indexOf("#"));
}
2013-06-11 15:29:21 +00:00
}
2013-06-19 21:54:27 +00:00
/* oh internet explorer, how I hate thee */
$(":input:not(textarea)").keypress(function(ev) {
return ev.keyCode != 13;
});
if (location.protocol === "https:") {
var title = "Warning";
var text = "You connected to this page via HTTPS. Due to browser "+
"security policy, certain media players may throw warnings,"+
" while others may not work at all due to only being "+
"available over plain HTTP.<br>To encrypt your websocket "+
"traffic and API calls (logins, account management, etc) "+
"while loading this page over plain HTTP, enable the SSL "+
"option from the Options menu.";
makeAlert(title, text, "alert-warning")
.appendTo($("#announcements"));
}
2014-01-09 05:45:26 +00:00
/* channel ranks stuff */
2014-01-09 23:16:09 +00:00
function chanrankSubmit(rank) {
2014-01-09 05:45:26 +00:00
var name = $("#cs-chanranks-name").val();
socket.emit("setChannelRank", {
2014-05-21 03:11:40 +00:00
name: name,
2014-01-09 05:45:26 +00:00
rank: rank
});
2014-01-09 23:16:09 +00:00
}
$("#cs-chanranks-mod").click(chanrankSubmit.bind(this, 2));
$("#cs-chanranks-adm").click(chanrankSubmit.bind(this, 3));
$("#cs-chanranks-owner").click(chanrankSubmit.bind(this, 4));
2014-01-14 00:31:12 +00:00
2014-02-02 18:41:41 +00:00
["#showmediaurl", "#showsearch", "#showcustomembed", "#showplaylistmanager"]
.forEach(function (id) {
2014-01-14 00:31:12 +00:00
$(id).click(function () {
2014-01-22 05:04:06 +00:00
var wasActive = $(id).hasClass("active");
2014-01-14 00:31:12 +00:00
$(".plcontrol-collapse").collapse("hide");
2014-01-22 05:04:06 +00:00
$("#plcontrol button.active").button("toggle");
if (!wasActive) {
$(id).button("toggle");
}
2014-01-14 00:31:12 +00:00
});
});
2014-01-22 05:04:06 +00:00
$("#plcontrol button").button();
$("#plcontrol button").button("hide");
2014-01-14 00:31:12 +00:00
$(".plcontrol-collapse").collapse();
$(".plcontrol-collapse").collapse("hide");
2014-01-15 06:16:29 +00:00
$(".cs-checkbox").change(function () {
var box = $(this);
var key = box.attr("id").replace("cs-", "");
var value = box.prop("checked");
var data = {};
data[key] = value;
socket.emit("setOptions", data);
});
$(".cs-textbox").keyup(function () {
var box = $(this);
var key = box.attr("id").replace("cs-", "");
var value = box.val();
var lastkey = Date.now();
box.data("lastkey", lastkey);
setTimeout(function () {
if (box.data("lastkey") !== lastkey || box.val() !== value) {
return;
}
var data = {};
2014-01-16 17:53:34 +00:00
if (key.match(/chat_antiflood_(burst|sustained)/)) {
data = {
chat_antiflood_params: {
burst: $("#cs-chat_antiflood_burst").val(),
sustained: $("#cs-chat_antiflood_sustained").val()
}
};
} else {
data[key] = value;
}
2014-01-15 06:16:29 +00:00
socket.emit("setOptions", data);
}, 1000);
});
2014-01-16 17:53:34 +00:00
2014-02-08 18:45:07 +00:00
$("#cs-chanlog-refresh").click(function () {
2014-01-16 17:53:34 +00:00
socket.emit("readChanLog");
});
2014-02-08 18:45:07 +00:00
$("#cs-chanlog-filter").change(filterChannelLog);
2014-01-16 17:53:34 +00:00
$("#cs-motdsubmit").click(function () {
socket.emit("setMotd", {
motd: $("#cs-motdtext").val()
});
});
$("#cs-csssubmit").click(function () {
socket.emit("setChannelCSS", {
css: $("#cs-csstext").val()
});
});
$("#cs-jssubmit").click(function () {
socket.emit("setChannelJS", {
js: $("#cs-jstext").val()
});
});
2014-01-19 02:18:00 +00:00
$("#cs-chatfilters-newsubmit").click(function () {
var name = $("#cs-chatfilters-newname").val();
var regex = $("#cs-chatfilters-newregex").val();
var flags = $("#cs-chatfilters-newflags").val();
var replace = $("#cs-chatfilters-newreplace").val();
2014-04-13 07:14:34 +00:00
var entcheck = checkEntitiesInStr(regex);
if (entcheck) {
alert("Warning: " + entcheck.src + " will be replaced by " +
entcheck.replace + " in the message preprocessor. This " +
"regular expression may not match what you intended it to " +
"match.");
}
2014-01-19 02:18:00 +00:00
try {
new RegExp(regex, flags);
} catch (e) {
alert("Regex error: " + e);
return;
}
socket.emit("updateFilter", {
name: name,
source: regex,
flags: flags,
replace: replace,
active: true
});
$("#cs-chatfilters-newname").val("");
$("#cs-chatfilters-newregex").val("");
$("#cs-chatfilters-newflags").val("");
$("#cs-chatfilters-newreplace").val("");
});
2014-02-13 05:33:42 +00:00
$("#cs-emotes-newsubmit").click(function () {
var name = $("#cs-emotes-newname").val();
var image = $("#cs-emotes-newimage").val();
socket.emit("updateEmote", {
name: name,
image: image,
});
$("#cs-emotes-newname").val("");
$("#cs-emotes-newimage").val("");
});
2014-01-19 02:18:00 +00:00
$("#cs-chatfilters-export").click(function () {
var callback = function (data) {
socket.listeners("chatFilters").splice(
socket.listeners("chatFilters").indexOf(callback)
);
$("#cs-chatfilters-exporttext").val(JSON.stringify(data));
};
socket.on("chatFilters", callback);
socket.emit("requestChatFilters");
});
$("#cs-chatfilters-import").click(function () {
var text = $("#cs-chatfilters-exporttext").val();
var choose = confirm("You are about to import filters from the contents of the textbox below the import button. If this is empty, it will clear all of your filters. Are you sure you want to continue?");
if (!choose) {
return;
}
if (text.trim() === "") {
text = "[]";
}
var data;
try {
data = JSON.parse(text);
} catch (e) {
alert("Invalid import data: " + e);
return;
}
socket.emit("importFilters", data);
2014-01-19 02:18:00 +00:00
});
2014-01-25 19:49:34 +00:00
2014-02-13 05:33:42 +00:00
$("#cs-emotes-export").click(function () {
var em = CHANNEL.emotes.map(function (f) {
return {
name: f.name,
image: f.image
};
});
$("#cs-emotes-exporttext").val(JSON.stringify(em));
});
$("#cs-emotes-import").click(function () {
var text = $("#cs-emotes-exporttext").val();
var choose = confirm("You are about to import emotes from the contents of the textbox below the import button. If this is empty, it will clear all of your emotes. Are you sure you want to continue?");
if (!choose) {
return;
}
if (text.trim() === "") {
text = "[]";
}
var data;
try {
data = JSON.parse(text);
} catch (e) {
alert("Invalid import data: " + e);
return;
}
socket.emit("importEmotes", data);
});
2014-01-25 19:49:34 +00:00
var toggleUserlist = function () {
if ($("#userlist").css("display") === "none") {
$("#userlist").show();
} else {
$("#userlist").hide();
}
scrollChat();
};
$("#usercount").click(toggleUserlist);
$("#userlisttoggle").click(toggleUserlist);
2014-02-09 06:24:20 +00:00
$(".add-temp").change(function () {
$(".add-temp").prop("checked", $(this).prop("checked"));
});
2014-02-19 03:56:54 +00:00
applyOpts();