2015-08-26 10:52:17 +02:00
|
|
|
/* BetterDiscordApp QuickEmoteMenu JavaScript
|
2015-10-26 06:27:55 +01:00
|
|
|
* Version: 1.3
|
2015-08-26 10:52:17 +02:00
|
|
|
* Author: Jiiks | http://jiiks.net
|
|
|
|
* Date: 26/08/2015 - 11:49
|
2015-08-29 10:48:20 +02:00
|
|
|
* Last Update: 29/08/2015 - 11:46
|
2015-08-26 10:52:17 +02:00
|
|
|
* https://github.com/Jiiks/BetterDiscordApp
|
|
|
|
*/
|
|
|
|
|
2015-08-29 08:55:06 +02:00
|
|
|
var emoteBtn, emoteMenu;
|
|
|
|
|
2015-08-26 14:52:48 +02:00
|
|
|
function QuickEmoteMenu() {
|
2015-08-26 10:52:17 +02:00
|
|
|
|
2015-08-26 14:52:48 +02:00
|
|
|
}
|
|
|
|
|
2015-10-26 06:27:55 +01:00
|
|
|
QuickEmoteMenu.prototype.init = function() {
|
2015-08-31 15:36:28 +02:00
|
|
|
|
2015-10-26 06:27:55 +01:00
|
|
|
var emoteBtn;
|
2015-08-29 08:55:06 +02:00
|
|
|
|
|
|
|
if(!emoteMenu) {
|
|
|
|
this.initEmoteList();
|
|
|
|
}
|
2015-08-27 15:28:43 +02:00
|
|
|
|
2015-08-26 10:52:17 +02:00
|
|
|
var menuOpen;
|
2015-08-29 08:55:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
emoteBtn = $("<div/>", { id:"twitchcord-button-container", style:"display:none" }).append($("<button/>", { id: "twitchcord-button", onclick: "return false;" }));
|
2015-08-26 10:52:17 +02:00
|
|
|
|
2015-08-27 15:28:43 +02:00
|
|
|
$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn);
|
2015-08-29 08:55:06 +02:00
|
|
|
|
|
|
|
emoteMenu.detach();
|
2015-08-26 10:52:17 +02:00
|
|
|
emoteBtn.append(emoteMenu);
|
2015-08-29 08:55:06 +02:00
|
|
|
|
2015-08-26 10:52:17 +02:00
|
|
|
$("#twitchcord-button").on("click", function() {
|
|
|
|
menuOpen = !menuOpen;
|
|
|
|
if(menuOpen) {
|
|
|
|
emoteMenu.addClass("emotemenu-open");
|
|
|
|
$(this).addClass("twitchcord-button-open");
|
|
|
|
} else {
|
|
|
|
emoteMenu.removeClass();
|
|
|
|
$(this).removeClass();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-08-29 08:55:06 +02:00
|
|
|
if(settingsCookie["bda-es-0"]) {
|
2015-08-26 10:52:17 +02:00
|
|
|
emoteBtn.show();
|
|
|
|
}
|
|
|
|
|
2015-10-26 06:27:55 +01:00
|
|
|
var emoteIcon = $(".emote-icon");
|
|
|
|
|
|
|
|
emoteIcon.off();
|
|
|
|
emoteIcon.on("click", function() {
|
|
|
|
var emote = $(this).attr("id");
|
|
|
|
var ta = $(".channel-textarea-inner textarea");
|
|
|
|
ta.val(ta.val().slice(-1) == " " ? ta.val() + emote : ta.val() + " " + emote);
|
|
|
|
});
|
|
|
|
};
|
2015-08-29 08:55:06 +02:00
|
|
|
|
|
|
|
QuickEmoteMenu.prototype.obsCallback = function() {
|
|
|
|
if(!emoteBtn) return;
|
|
|
|
if(!$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form")) return;
|
|
|
|
|
2015-10-26 06:27:55 +01:00
|
|
|
var tcbtn = $("#twitchcord-button-container");
|
2015-08-29 08:55:06 +02:00
|
|
|
|
|
|
|
if(tcbtn.parent().prop("tagName") == undefined) {
|
|
|
|
quickEmoteMenu = new QuickEmoteMenu();
|
|
|
|
quickEmoteMenu.init(true);
|
|
|
|
}
|
2015-10-26 06:27:55 +01:00
|
|
|
};
|
2015-08-29 08:55:06 +02:00
|
|
|
|
|
|
|
QuickEmoteMenu.prototype.initEmoteList = function() {
|
|
|
|
|
|
|
|
emoteMenu = $("<div/>", { id: "emote-menu" });
|
|
|
|
|
|
|
|
var emoteMenuHeader = $("<div/>", { id: "emote-menu-header" }).append($("<span/>", { text: "Global Emotes" }));
|
|
|
|
var emoteMenuBody = $("<div/>", { id: "emote-menu-inner" });
|
|
|
|
emoteMenu.append(emoteMenuHeader);
|
|
|
|
emoteMenu.append(emoteMenuBody);
|
|
|
|
|
2015-10-26 06:27:55 +01:00
|
|
|
for(var emote in emotesTwitch.emotes) {
|
|
|
|
if(emotesTwitch.emotes.hasOwnProperty(emote)) {
|
|
|
|
var id = emotesTwitch.emotes[emote].image_id;
|
|
|
|
emoteMenuBody.append($("<div/>" , { class: "emote-container" }).append($("<img/>", { class: "emote-icon", id: emote, alt: "", src: "https://static-cdn.jtvnw.net/emoticons/v1/"+id+"/1.0", title: emote })));
|
|
|
|
}
|
2015-08-26 14:52:48 +02:00
|
|
|
}
|
2015-10-26 06:27:55 +01:00
|
|
|
};
|