text: "use strict";BBLog.handle("add.plugin",{id:"sbplus",name:"Scoreboard+",translations:{en:{"sbplus.scoreboard.attackers":"Attackers","sbplus.scoreboard.defenders":"Defenders","sbplus.scoreboard.players":"Players","sbplus.scoreboard.tooltip.score":"Average Score","sbplus.scoreboard.tooltip.rank":"Average Rank","sbplus.scoreboard.liveupdate.liveupdate":"Live Update","sbplus.scoreboard.liveupdate.on":"On","sbplus.scoreboard.liveupdate.off":"Off","sbplus.settings.interval.placeholder":"Live Update interval in ms (Default: 3000)","sbplus.settings.interval.tooltip":"Live Update interval in ms (Default: 3000)","sbplus.settings.customcss.placeholder":"Example: http://mywebsite.com/example.css","sbplus.settings.customcss.tooltip":"Replace the default stylesheet of Scorboard+ with you own. Please enter the URL of your stylesheet.","sbplus.settings.descritpion":"Change the interval of live updating and replace the default stylesheet of Scorboard+ with your own.","sbplus.settings.title":"Settings","sbplus.settings.savebutton":"Save"},de:{"sbplus.scoreboard.attackers":"Angreifer","sbplus.scoreboard.defenders":"Verteidiger","sbplus.scoreboard.players":"Spieler","sbplus.scoreboard.tooltip.score":"Punktedurchschnitt","sbplus.scoreboard.tooltip.rank":"Rangdurchschnitt","sbplus.scoreboard.liveupdate.liveupdate":"Live Update","sbplus.scoreboard.liveupdate.on":"An","sbplus.scoreboard.liveupdate.off":"Aus","sbplus.settings.interval.placeholder":"Live Update Intervall in ms (Standard: 3000)","sbplus.settings.interval.tooltip":"Live Update Intervall in ms (Standard: 3000)","sbplus.settings.customcss.placeholder":"Beispiel: http://mywebsite.com/example.css","sbplus.settings.customcss.tooltip":"Ersetze das Standard Stylesheet von Scoreboard+ durch dein Eigenes. Bitte gebe die URL zu deinem Stylesheet ein.","sbplus.settings.descritpion":"Hier kannst du das Intervall des Live Updates ändern und das Standard Stylesheet von Scoreboard+ durch dein Eigenes ersetzen.","sbplus.settings.title":"Einstellungen","sbplus.settings.savebutton":"Speichern"},pt:{"sbplus.scoreboard.attackers":"Atacantes","sbplus.scoreboard.defenders":"Defensores","sbplus.scoreboard.players":"Jogadores","sbplus.scoreboard.tooltip.score":"Maior placara","sbplus.scoreboard.tooltip.rank":"Maior Rank","sbplus.scoreboard.liveupdate.liveupdate":"Atualização em Tempo Real","sbplus.scoreboard.liveupdate.on":"Ligado","sbplus.scoreboard.liveupdate.off":"Desligado","sbplus.settings.interval.placeholder":"Atualização em intervalos de (Padrão: 3000)","sbplus.settings.interval.tooltip":"Atualização em intervalos de (Padrão: 3000)","sbplus.settings.customcss.placeholder":"Exemplo: http://mywebsite.com/example.css","sbplus.settings.customcss.tooltip":"Usar a minha folha de estilo. Por favor adicione a URL da sua folha de estilo.","sbplus.settings.descritpion":"Mudar o intervalo de atualizações e sobrescrever a folha de estilos do Placar pela minha.","sbplus.settings.title":"Configurações","sbplus.settings.savebutton":"Salvar"}},configFlags:[{key:"sbplus.settings.title",init:1,handler:function(e){e.showSettings(e)}}],showSettings:function(e){var s=e.storage("storage.liveupdate.interval");null==s&&(s=3e3);var t=e.storage("storage.customcss.url");null==t&&(t="");var r='<div class="section-description"><p>'+e.t("sbplus.settings.descritpion")+"</p></div>";r+='<form method="post" action="" id="sbplus-settings-form"><input id="sbplus-input-interval" type="text" placeholder="'+e.t("sbplus.settings.interval.placeholder")+'" data-tooltip="'+e.t("sbplus.settings.interval.tooltip")+'" value="'+s+'"><br>',r+='<input id="sbplus-input-customcss" type="text" placeholder="'+e.t("sbplus.settings.customcss.placeholder")+'" data-tooltip="'+e.t("sbplus.settings.customcss.tooltip")+'" value="'+t+'"><br>',r+='<input type="submit" class="bblog-button tiny" id="sbplus-input-savebutton" style="width:auto;margin-top:5px;padding-left:10px;padding-right:10px;" value="'+e.t("sbplus.settings.savebutton")+'"></form>',BBLog.popup("bblog-option","Scoreboard+ "+e.t("sbplus.settings.title"),r),$("#sbplus-settings-form").bind("submit",function(s){s.preventDefault();var t=parseInt($("#sbplus-input-interval").attr("value")),r=$.trim($("#sbplus-input-customcss").attr("value")),a=!1;isNaN(t)||(e.storage("storage.liveupdate.interval",t),a=!0),r.match(/^http.*/)?(e.storage("storage.customcss.url",r),a=!0):""==r&&(e.storage("storage.customcss.url",null),a=!0),a&&base.showReceipt(BBLog.t("reload.required")+" (F5)"),BBLog.closeAllPopups()})},domchange:function(){$('.section-config > span[data-key="sbplus.sbplus.settings.title"]').remove()},init:function(e){var s=launcher.queryServer;launcher.queryServer=function(t,r){s(t,function(s){r(s),"OK"===s.status&&e.extendScoreboard(e,s)})},e.injectCSS(e),$(document).on("click",".sp-live-selector li",function(){var s=$(this);"selected"!=s.attr("class")&&("be-live-on"==s.attr("id")?($("#be-live-off").removeClass("selected"),$("#be-live-on").addClass("selected"),e.startLiveUpdate(e)):"be-live-off"==s.attr("id")&&($("#be-live-on").removeClass("selected"),$("#be-live-off").addClass("selected"),e.stopLiveUpdate(e)))}),1==e.storage("storage.liveupdate")&&e.startLiveUpdate(e),e.updateScoreboard(e)},extendScoreboard:function(e,s){var t,r,a,o,n,l,i,d,p,c,u,b,v,g=serverguide.serverinfoscore.surface_10_2.render({scoreboard:s,squadLetters:h}),h=["","A","B","C","D"],f=[],m=s.result.gameMode,x=[[[1,32,64,128,256],["US","RU"]],[[2,4],[e.t("sbplus.scoreboard.attackers"),e.t("sbplus.scoreboard.defenders")]],[[8],["Squad A","Squad B","Squad C","Squad D"]]];for(t=0,p=x.length;p>t&&(b=x[t],a=b[0],d=b[1],-1===a.indexOf(m));t++);var y=s.result.teams;for(t=0,c=y.length;c>t;t++){for(i=y[t],n=[],l=[],v=i.players,r=0,u=v.length;u>r;r++)o=v[r],n.push(o.rank),l.push(o.score);f[t]={type:t%2===0?"left":"right",title:d[t],players:i.players.length,score:e.average(e,l),rank:e.rankImage(e,e.average(e,n),"small")}}var S='<div class="sp-scoreboard-extended">',k=1==e.storage("storage.liveupdate");for(S+='<div class="sp-live-selector"><div class="header">'+e.t("sbplus.scoreboard.liveupdate.liveupdate")+'</div><ul class="common-selector"><li id="be-live-on"'+(k?' class="selected"':"")+"><div>"+e.t("sbplus.scoreboard.liveupdate.on")+'</div></li><li id="be-live-off"'+(k?"":' class="selected"')+"><div>"+e.t("sbplus.scoreboard.liveupdate.off")+"</div></li></ul></div>",t=0;t<f.length;t+=2)for(r=0;2>r;r++)i=f[t+r],S+='<div class="sp-scoreboard-section ',S+=0==r?"left":"right",S+='"><div class="title">'+i.title+'</div><div class="scoreboard-box"><div class="players">'+i.players+" "+e.t("sbplus.scoreboard.players")+'</div><div class="score clear" data-tooltip="'+e.t("sbplus.scoreboard.tooltip.score")+'">'+i.score+'</div><div class="rank clear"><img src="'+i.rank+'" data-tooltip="'+e.t("sbplus.scoreboard.tooltip.rank")+'"></div></div></div>';S+='<div class="clear"></div></div>',$("#serverinfoscore-link #selected-server-scoreboard").unwrap(),g=g.replace(/<\/div>[\S\s]{1,9}<\/surf:container>/,S+"</div></div></surf:container>"),$("#selected-server-scoreboard").replaceWith(g),$("#selected-server-scoreboard [data-tooltip]").tooltip()},updateScoreboard:function(){if($("#selected-server-scoreboard").length>0){var e=$("#serverguide-show-joinserver-form input[name$=gameip]").val(),s=$("#serverguide-show-joinserver-form input[name$=gameid]").val(),t=$("#serverguide-show-joinserver-form input[name$=gameport]").val(),r=$("#serverguide-show-joinserver-form input[name$=gamename]").val();launcher.queryServer({gameId:s,game:r,ip:e,port:t},function(){})}},startLiveUpdate:function(e){var s=e.cache("cache.liveupdate.intervalInst");null!=s&&clearInterval(s),e.storage("storage.liveupdate",1);var t=e.storage("storage.liveupdate.interval");s=setInterval(function(){e.updateScoreboard(e)},null!=t?t:3e3),e.cache("cache.liveupdate.intervalInst",s)},stopLiveUpdate:function(e){e.storage("storage.liveupdate",0);var s=e.cache("cache.liveupdate.intervalInst");null!=s&&(clearInterval(s),e.cache("cache.liveupdate.intervalInst",null))},average:function(e,s){var t,r,a,o;if(!s.length)return 0;for(r=0,a=0,o=s.length;o>a;a++)t=s[a],r+=t;return Math.round(r/s.length)},rankImage:function(e,s,t){var r;return null==t&&(t="tiny"),s=Math.round(s),r=s>45?"ss"+(s-45):"r"+s,"https://res.cloudinary.com/dhf60h12z/image/upload/bf3ranks/"+r+".png"},injectCSS:function(e){var s=e.storage("storage.customcss.url");null!=s?$("head").append('<link rel="stylesheet" type="text/css" href="'+s+'"/>'):$("<style>").prop("type","text/css").html("							.sp-scoreboard-extended {\n								min-height:50px;\n								position:relative;\n								padding:0 10px;\n							}\n							.sp-live-selector {\n								margin-left:-41px;\n								margin-top:-27px;\n								width:82px;\n								height:54px;\n								position:absolute;\n								left:50%;\n								top:50%;\n							}\n							.sp-live-selector .header {\n								padding-bottom:5px;\n								color:#8a8a8a;\n								font-family:Tahoma,sans-serif;\n								font-weight:700;\n								font-size:11px;\n								line-height:20px;\n								text-align:center;\n								text-transform:uppercase;\n							}\n							.sp-live-selector .common-selector {\n								float:none!important;\n								margin:0 5px!important;\n							}\n							.sp-scoreboard-section {\n								margin-top:10px;\n							}\n							.sp-scoreboard-section.left {\n								clear:left;\n							}\n							.sp-scoreboard-section.right {\n								text-align:right;\n								clear:right;\n							}\n							.sp-scoreboard-section .title {\n								padding-bottom:5px;\n								font-size:14px;\n								font-weight:700;\n								text-transform:uppercase;\n							}\n							.sp-scoreboard-section .players,.sp-scoreboard-section .score {\n								width:64px;\n								text-align:center;\n							}\n							.sp-scoreboard-section .score {\n								padding-top:5px;\n								font-weight:700;\n								font-size:14px;\n							}\n							.sp-scoreboard-section .rank {\n								width:64px;\n								height:64px;\n							}\n							.scoreboard-box {\n								border:1px solid #ccc;\n								width:64px;\n								background-color:#e5e5e5;\n								border-radius:5px;\n								padding:5px 10px;\n							}\n							.right .scoreboard-box {\n								float:right;\n							}\n							.sp-scoreboard-box {\n								position:absolute;\n								left:-2000px;\n							}\n							.sp-scoreboard-wrap {\n								width:1050px;\n								height:558px;\n								overflow:auto;\n							}").appendTo("head")}});