Fixed a scope issue
This commit is contained in:
parent
2a8175e119
commit
47bf32fb8b
|
@ -654,7 +654,7 @@ PublicServers.prototype.init = function () {
|
|||
})))));
|
||||
|
||||
$("#bd-pub-button").on("click", function () {
|
||||
this.show();
|
||||
self.show();
|
||||
});
|
||||
|
||||
var panelBase="";
|
||||
|
|
|
@ -27,7 +27,7 @@ if(typeof emotesFfz!=='undefined'&&settingsCookie["bda-es-1"]){if(emotesFfz.hasO
|
|||
if(typeof emotesBTTV!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=emotesBTTV[sWord];parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}
|
||||
if(typeof emotesBTTV2!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV2.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=bttvEmoteUrlStart+emotesBTTV2[sWord]+bttvEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}});if(parent.parentElement==null)return;var oldHeight=parent.parentElement.offsetHeight;parent.innerHTML=parentInnerHTML.replace(new RegExp("\uFDD9","g"),"");var newHeight=parent.parentElement.offsetHeight;var scrollPane=$(".scroller.messages").first();scrollPane.scrollTop(scrollPane.scrollTop()+(newHeight-oldHeight));}
|
||||
if(edited){setTimeout(inject,250);}else{inject();}};EmoteModule.prototype.autoCapitalize=function(){var self=this;$('body').delegate($(".channel-textarea-inner textarea"),'keyup change paste',function(){if(!settingsCookie["bda-es-4"])return;var text=$(".channel-textarea-inner textarea").val();if(text==undefined)return;var lastWord=text.split(" ").pop();if(lastWord.length>3){if(lastWord=="danSgame")return;var ret=self.capitalize(lastWord.toLowerCase());if(ret!==null&&ret!==undefined){$(".channel-textarea-inner textarea").val(text.replace(lastWord,ret));}}});};EmoteModule.prototype.capitalize=function(value){var res=emotesTwitch.emotes;for(var p in res){if(res.hasOwnProperty(p)&&value==(p+'').toLowerCase()){return p;}}};function PublicServers(){}
|
||||
PublicServers.prototype.getPanel=function(){return this.container;};PublicServers.prototype.init=function(){var self=this;var guilds=$(".guilds>li:first-child");guilds.after($("<li></li>",{id:"bd-pub-li",css:{"height":"20px","display":settingsCookie["bda-gs-1"]==true?"":"none"}}).append($("<div/>",{class:"guild-inner",css:{"height":"20px","border-radius":"4px"}}).append($("<a/>").append($("<div/>",{css:{"line-height":"20px","font-size":"12px"},text:"public",id:"bd-pub-button"})))));$("#bd-pub-button").on("click",function(){this.show();});var panelBase="";panelBase+="<div id=\"pubs-container\">";panelBase+=" <div id=\"pubs-spinner\">";panelBase+=" <span class=\"spinner\" type=\"wandering-cubes\"><span class=\"spinner-inner spinner-wandering-cubes\"><span class=\"spinner-item\"><\/span><span class=\"spinner-item\"><\/span><\/span><\/span>";panelBase+=" <\/div>";panelBase+=" <div id=\"pubs-header\">";panelBase+=" <h2 id=\"pubs-header-title\">Public Servers<\/h2>";panelBase+=" <button id=\"sbtn\">Search<\/button>";panelBase+=" <input id=\"sterm\" type=\"text\" placeholder=\"Search term...\"\/>";panelBase+=" <\/div>";panelBase+=" <div class=\"scroller-wrap\">";panelBase+=" <div class=\"scroller\">";panelBase+=" <div id=\"slist\" class=\"servers-listing\">";panelBase+=" ";panelBase+=" <\/div>";panelBase+=" <\/div>";panelBase+=" <\/div>";panelBase+=" <div id=\"pubs-footer\">";panelBase+=" <div>Server list provided by <a href=\"https:\/\/www.discordservers.com\/\" target=\"_blank\">DiscordServers.com<\/a><\/div>";panelBase+=" <\/div>";panelBase+="<\/div>";this.container=panelBase;if($("#bd-pub-li").length<1){setTimeout(function(){self.init();},250);}};PublicServers.prototype.show=function(){var self=this;$("body").append(this.getPanel());var dataset={"sort":[{"online":"desc"}],"from":0,"size":20,"query":{"filtered":{"query":{"match_all":{}}}}};$("#sbtn").on("click",function(){self.search();});$("#sterm").on("keyup",function(e){if(e.keyCode==13){self.search();}});this.loadServers(dataset,false);var self=this;$(document).on("mouseup.bdps",function(e){if(!$("#bd-pub-button").is(e.target)&&!$("#pubs-container").is(e.target)&&$("#pubs-container").has(e.target).length===0){self.hide();}});};PublicServers.prototype.hide=function(){$("#pubs-container").remove();$(document).off("mouseup.bdps");};PublicServers.prototype.loadServers=function(dataset,search){var self=this;$("#sbtn").prop("disabled",true);$("#sterm").prop("disabled",true);$("#slist").empty();$("#pubs-spinner").show();$.ajax({type:"POST",dataType:"json",url:"https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/app/_search",crossDomain:true,data:JSON.stringify(dataset),success:function(data){var hits=data.hits.hits;if(search){$("#pubs-header-title").text("Public Servers - Search Results: "+hits.length);}else{$("#pubs-header-title").text("Public Servers");}
|
||||
PublicServers.prototype.getPanel=function(){return this.container;};PublicServers.prototype.init=function(){var self=this;var guilds=$(".guilds>li:first-child");guilds.after($("<li></li>",{id:"bd-pub-li",css:{"height":"20px","display":settingsCookie["bda-gs-1"]==true?"":"none"}}).append($("<div/>",{class:"guild-inner",css:{"height":"20px","border-radius":"4px"}}).append($("<a/>").append($("<div/>",{css:{"line-height":"20px","font-size":"12px"},text:"public",id:"bd-pub-button"})))));$("#bd-pub-button").on("click",function(){self.show();});var panelBase="";panelBase+="<div id=\"pubs-container\">";panelBase+=" <div id=\"pubs-spinner\">";panelBase+=" <span class=\"spinner\" type=\"wandering-cubes\"><span class=\"spinner-inner spinner-wandering-cubes\"><span class=\"spinner-item\"><\/span><span class=\"spinner-item\"><\/span><\/span><\/span>";panelBase+=" <\/div>";panelBase+=" <div id=\"pubs-header\">";panelBase+=" <h2 id=\"pubs-header-title\">Public Servers<\/h2>";panelBase+=" <button id=\"sbtn\">Search<\/button>";panelBase+=" <input id=\"sterm\" type=\"text\" placeholder=\"Search term...\"\/>";panelBase+=" <\/div>";panelBase+=" <div class=\"scroller-wrap\">";panelBase+=" <div class=\"scroller\">";panelBase+=" <div id=\"slist\" class=\"servers-listing\">";panelBase+=" ";panelBase+=" <\/div>";panelBase+=" <\/div>";panelBase+=" <\/div>";panelBase+=" <div id=\"pubs-footer\">";panelBase+=" <div>Server list provided by <a href=\"https:\/\/www.discordservers.com\/\" target=\"_blank\">DiscordServers.com<\/a><\/div>";panelBase+=" <\/div>";panelBase+="<\/div>";this.container=panelBase;if($("#bd-pub-li").length<1){setTimeout(function(){self.init();},250);}};PublicServers.prototype.show=function(){var self=this;$("body").append(this.getPanel());var dataset={"sort":[{"online":"desc"}],"from":0,"size":20,"query":{"filtered":{"query":{"match_all":{}}}}};$("#sbtn").on("click",function(){self.search();});$("#sterm").on("keyup",function(e){if(e.keyCode==13){self.search();}});this.loadServers(dataset,false);var self=this;$(document).on("mouseup.bdps",function(e){if(!$("#bd-pub-button").is(e.target)&&!$("#pubs-container").is(e.target)&&$("#pubs-container").has(e.target).length===0){self.hide();}});};PublicServers.prototype.hide=function(){$("#pubs-container").remove();$(document).off("mouseup.bdps");};PublicServers.prototype.loadServers=function(dataset,search){var self=this;$("#sbtn").prop("disabled",true);$("#sterm").prop("disabled",true);$("#slist").empty();$("#pubs-spinner").show();$.ajax({type:"POST",dataType:"json",url:"https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/app/_search",crossDomain:true,data:JSON.stringify(dataset),success:function(data){var hits=data.hits.hits;if(search){$("#pubs-header-title").text("Public Servers - Search Results: "+hits.length);}else{$("#pubs-header-title").text("Public Servers");}
|
||||
hits.forEach(function(hit){var source=hit._source;var icode=source.invite_code;var html='<div class="server-row">';html+='<div class="server-icon" style="background-image:url('+source.icon+')"></div>';html+='<div class="server-info server-name">';html+='<span>'+source.name+' by '+source.owner.name+'</span>';html+='</div>';html+='<div class="server-info server-members">';html+='<span>'+source.online+'/'+source.members+' Members</span>';html+='</div>';html+='<div class="server-info server-region">';html+='<span>'+source.region+'</span>';html+='</div>';html+='<div class="server-info">';html+='<button data-server-invite-code='+icode+'>Join</button>';html+='</div>';html+='</div>';$("#slist").append(html);$("button[data-server-invite-code="+icode+"]").on("click",function(){self.joinServer(icode);});});},done:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);},always:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);},error:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);},complete:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);}});};PublicServers.prototype.search=function(){var dataset={"sort":[{"online":"desc"}],"from":0,"size":20,"query":{"filtered":{"query":{"match_all":{}}}}};var filter={"filter":{"and":[{"query":{"match_phrase_prefix":{"name":$("#sterm").val()}}}]}};if($("#sterm").val()){$.extend(dataset,filter);}
|
||||
this.loadServers(dataset,true);};PublicServers.prototype.joinServer=function(code){$(".guilds-add").click();$(".action.join .btn").click();$(".create-guild-container input").val(code);$(".form.join-server .btn-primary").click();};var emoteBtn,emoteMenu;var eiarr=[1,3,4,6,7,8,10,11,12,13,14];function QuickEmoteMenu(){}
|
||||
QuickEmoteMenu.prototype.init=function(reload){emoteBtn=null;$(".channel-textarea").first().removeClass("emotemenu-enabled");if(!emoteMenu){this.initEmoteList();}
|
||||
|
|
Loading…
Reference in New Issue