-
Notifications
You must be signed in to change notification settings - Fork 1
/
show-map-rotation.latest.bblog.min.js
33 lines (31 loc) · 13.8 KB
/
show-map-rotation.latest.bblog.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
@name BF4/BF3/BFH Show Map Rotation
@author GreatApo & DarkThanos
@version 1.7
@release_date 27/06/2016
@url http://www.alites.com
Licensed under CC BY-NC-ND 3.0
Link: http://creativecommons.org/licenses/by-nc-nd/3.0/deed.en
*/
BBLog.handle("add.plugin",{id:"show-map-rotation-plugin",name:"Show Map Rotation",version:"1.7",build:"20160627",init:function(a){"bf4"===BBLog.cache("mode")?(a.events.onPageLoad(a,{page:"^/bf4/("+BBLog.cache("language")+"/)*(servers|serverbrowserwarsaw)/(playnow/|favourites/|history/)*(pc/|ps3/|ps4/|xbox360/|xboxone/)*[^/]*$",callback:a.mapRotation.init}),a.loadCSS.bf4(a)):"bf3"===BBLog.cache("mode")&&(a.events.onPageLoad(a,{page:"^/bf3/("+BBLog.cache("language")+"/)*servers/(playnow/|favourites/|history/)*(pc/|ps3/|ps4/|xbox360/|xboxone/)*[^/]*$",
callback:a.mapRotationBF3.init}),a.loadCSS.bf3(a))},domchange:function(a){a.eventsFire.onPageLoad(a)},events:{onPageLoad:function(a,c){c.page&&c.callback&&a.eventsData.onPageLoad.push(c)}},eventsFire:{onPageLoad:function(a){var c;for(c=0;c<a.eventsData.onPageLoad.length;c++)document.location.pathname.match(new RegExp(a.eventsData.onPageLoad[c].page))&&a.eventsData.onPageLoad[c].callback(a)}},eventsData:{onPageLoad:[]},loadCSS:{css:{any:"#serverbrowser-show .server-info .map-rotation .maps-icons,#serverguide-show .map-rotation .maps-icons{margin-top:1px;text-shadow:0 0 4px #000}#serverbrowser-show .server-info .map-rotation .maps-icons.wait-to-load,#serverguide-show .map-rotation .maps-icons.wait-to-load{margin:6px}#serverbrowser-show .server-info .map-rotation .maps-icons .map-icon.active,#serverguide-show .map-rotation .maps-icons .map-icon.active{border-left:3px solid #60c0f6}.dialog.dialog-map-rotation{position:fixed;top:50%;left:50%;width:992px;margin-left:-497px!important}.dialog.dialog-map-rotation .dialog-body{width:992px;position:relative;padding:0!important}.dialog.dialog-map-rotation .dialog-body .active-indicator{position:absolute;top:5px;right:5px;background-color:rgba(0,0,0,.5);padding:7px 5px 5px}.dialog.dialog-map-rotation .dialog-body .active-indicator h6{float:right;margin:2px 0 0}.dialog.dialog-map-rotation .dialog-body .scroll-button{position:absolute;top:0;font-family:consolas;font-size:5em;width:130px;text-align:center;cursor:pointer;text-shadow:0 0 4px black,0 0 4px black,0 0 4px black,0 0 4px #000;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dialog.dialog-map-rotation .dialog-body .left-scroll-button{left:0}.dialog.dialog-map-rotation .dialog-body .right-scroll-button{right:0}.dialog.dialog-map-rotation .dialog-body .map-name{position:absolute;left:0;bottom:82px;right:0;background-color:rgba(0,0,0,.5);text-align:center}.dialog.dialog-map-rotation .dialog-body .map-carousel{position:absolute;left:0;bottom:0;right:0;background-color:#000;height:82px;overflow:hidden}.dialog.dialog-map-rotation .dialog-body .map-carousel .map-preview{float:left;width:146px;height:79px;border:1px solid #5a5a5a;position:relative}.dialog.dialog-map-rotation .dialog-body .map-carousel .map-preview .map-preview-title{font-size:.9em;font-weight:700;position:absolute;bottom:2px;left:0;right:0;text-align:center;background-color:rgba(0,0,0,.3);padding:3px 0;text-shadow:0 0 3px black,0 0 3px black,0 0 3px #000}.dialog.dialog-map-rotation .dialog-body .map-carousel .map-preview .active-preview{position:absolute;top:2px;left:2px;border:4px solid #60c0f6}",
bf4:"#serverbrowser-show .quick-info .holder{z-index:2;text-shadow:0 0 4px #000}#serverbrowser-show .server-info .map-rotation{position:absolute;z-index:1;padding:2px;opacity:.7;transition:opacity .25s ease-in-out;-moz-transition:opacity .25s ease-in-out;-webkit-transition:opacity .25s ease-in-out}#serverbrowser-show .server-info .map-rotation:hover{opacity:1}#serverbrowser-show .server-info .map-rotation .maps-icons .map-icon{cursor:pointer;width:26px;height:26px;border-left:3px solid #d5dde5;margin:1px 2px;box-shadow:1px 1px 10px #888}.dialog.dialog-map-rotation{height:458px;margin-top:-229px!important}.dialog.dialog-map-rotation .dialog-body{height:427px !important}.dialog.dialog-map-rotation .dialog-body .scroll-button{height:288px;line-height:288px}.dialog.dialog-map-rotation .dialog-body .map-name{padding-top:8px}",
bf3:"#serverguide-show .map-rotation{padding-bottom:10px}#serverguide-show .map-rotation .maps-icons .map-icon{cursor:pointer;width:30px;height:24px;border-left:3px solid #777;margin:1px 3px 1px 0;box-shadow:0 0 2px #000}.dialog.dialog-map-rotation{height:285px;margin-top:-143px!important}.dialog.dialog-map-rotation .dialog-body{height:246px;color:#fff}.dialog.dialog-map-rotation .dialog-body .active-indicator{font-family:Purista,sans-serif;font-style:normal;font-weight:600;font-size:1.2em}.dialog.dialog-map-rotation .dialog-body .active-indicator .loader{margin-right:5px}.dialog.dialog-map-rotation .dialog-body .scroll-button{height:164px;line-height:164px}.dialog.dialog-map-rotation .dialog-body .map-name{padding-top:0}.dialog.dialog-map-rotation .dialog-body .map-name h1{font-size:1.8em;padding:5px;font-family:Purista,sans-serif;font-style:normal;font-weight:600}"},
bf4:function(a){a.loadCSS.add(a.loadCSS.css.any);a.loadCSS.add(a.loadCSS.css.bf4)},bf3:function(a){a.loadCSS.add(a.loadCSS.css.any);a.loadCSS.add(a.loadCSS.css.bf3)},add:function(a){var c=$("<style></style>");c.html(a);$("head").append(c)}},mapRotation:{active_ajax:null,active_server:{id:null,maps:null},init:function(a){0===$("#serverbrowser-show").length||$("#serverbrowser-results").data(a.id)||($("#serverbrowser-results").data(a.id,!0),$("#serverbrowser-show")[0].addEventListener("DOMNodeInserted",
function(c){c&&c.target&&"box"===c.target.className&&(0<$("#serverbrowser-show .map-rotation").length||a.mapRotation.updateServerInfo(a))},!0),a.mapRotation.updateServerInfo(a))},updateServerInfo:function(a){null!==a.mapRotation.active_ajax&&a.mapRotation.active_ajax.abort();$("#serverbrowser-show .server-info").prepend('<div class="map-rotation"><div class="maps-icons wait-to-load">☰</div></div>');a.mapRotation.getMapRotation(a)},getMapRotation:function(a){var c=$("#serverbrowser-show footer a").attr("href");
a.mapRotation.active_ajax=$.ajax({url:c,success:function(b){a.mapRotation.active_ajax=null;b=a.mapRotation.parseMapRotation(b);b.error?$("#serverbrowser-show .server-info .map-rotation .maps-icons").html("☰ Error"):a.mapRotation.showMapRotation(a,b.maps)}})},parseMapRotation:function(a){var c=a.match(/<section id="server-page"[^>]+>/im);if(!c||!c[0].match(/data-ip="([^"]+)"/i)||c[0].match(/data-ip="([^"]+)"/i)[1]!==$("#serverbrowser-show .join").data("ip")||0===$("#serverbrowser-show .map-rotation").length)return{error:!0};
c=[];a=a.match(/<td class="([^"]*)">[^<]*<span class="map-image" style="background-image: url\('([^']+)'\)"><\/span>[^<]*<p>[^<]*(<i[^>]+><\/i>|)[^<]*<strong>([^<]+)<\/strong><br>[^<]*<span>([^<]+)<\/span>[^<]*<\/p>/gm);if(!a)return{error:!0};for(var b,g,e,d,f=0;f<a.length;f++)b=a[f].match(/<td class="([^"]*)">[^<]*<span class="map-image" style="background-image: url\('([^']+)'\)"><\/span>[^<]*<p>[^<]*(<i[^>]+><\/i>|)[^<]*<strong>([^<]+)<\/strong><br>[^<]*<span>([^<]+)<\/span>[^<]*<\/p>/im),g=b[4],
e=b[5],d=b[2].replace("/195x79/","/IMAGExSIZE/"),b="active"==b[1]?!0:!1,c.push({name:g.trim(),mode:e.trim(),image:{big:d.replace("IMAGExSIZE","992x345"),medium:d.replace("IMAGExSIZE","146x79"),small:d.replace("IMAGExSIZE","30x21")},active:b});return{maps:c,error:!1}},showMapRotation:function(a,c){a.mapRotation.active_server.id=$("#serverbrowser-show .server-info .join").data("guid");a.mapRotation.active_server.maps=c;for(var b=0,g,e=$('<div class="maps-icons"></div>'),d=function(){a.mapRotation.showMapRotationPopUp(a,
parseInt($(this).data("index"),10))},b=0;b<c.length;b++)g=$('<img class="'+(c[b].active?"active ":"")+'map-icon" src="'+c[b].image.small+'" data-tooltip="'+c[b].name+" - "+c[b].mode+'" data-index="'+b+'"/>'),g.click(d),e.append(g);$("#serverbrowser-show .server-info .map-rotation").html("").append(e)},showMapRotationPopUp:function(a,c){var b,g,e=c,d=a.mapRotation.active_server.maps,f=d[e],m,h,k,n,p,q,l,r;BBLog.popup(a.id,"["+(e+1)+"/"+d.length+"] "+f.name+" - "+f.mode,"");m=$("#popup-"+a.id).addClass("dialog-map-rotation");
h=m.find(".dialog-body").css("background-image","url('"+f.image.big+"')");k=$('<div class="active-indicator"><h6>Active</h6><div class="loader small"></div></div>').hide();f.active&&k.show();n=$('<div class="scroll-button left-scroll-button"><</div>');p=$('<div class="scroll-button right-scroll-button">></div>');q=$('<div class="map-name"><h1>'+f.name+" - "+f.mode+"</h1></div>");l=$('<div style="width:'+(148*(d.length+1)+1)+'px;margin-left:992px;"></div>');for(b=0;b<d.length;b++)g=$('<div class="map-preview" style="background-image:url('+
d[b].image.medium+');"></div>'),g.append('<div class="map-preview-title">'+d[b].name+"<br>"+d[b].mode+"</div>"),d[b].active&&(g.css("border-color","#60c0f6"),g.append('<div class="active-preview"></div>')),b===e&&g.css("box-shadow","0px 0px 10px white inset"),d[b].preview_element=g,l.append(g);h.append(k);h.append(n);h.append(p);h.append(q);h.append($('<div class="map-carousel">').append(l));l.animate({marginLeft:422-148*e},500);r=function(a){if(a!==e){if(0>a){if(a=d.length-1,a===e)return}else if(a>
d.length-1&&(a=0,a===e))return;d[e].preview_element.css("box-shadow","");e=a;f=d[e];f.preview_element.css("box-shadow","0px 0px 10px white inset");q.html("<h1>"+f.name+" - "+f.mode+"</h1>");h.css("background-image","url('"+f.image.big+"')");m.find("header h3").html("["+(e+1)+"/"+d.length+"] "+f.name+" - "+f.mode);f.active?k.show():k.hide();l.animate({marginLeft:422-148*e},500)}};n.click(function(){r(e-1)});p.click(function(){r(e+1)})}},mapRotationBF3:{active_ajax:null,active_server:{id:null,maps:null},
init:function(a){0===$(".serverguide-list").length||0===$("#serverguide-show").length||$("#serverguide-server-list").data(a.id)||($("#serverguide-server-list").data(a.id,!0),$("#serverguide-show")[0].addEventListener("DOMNodeInserted",function(c){c&&c.target&&"base-box-push"===c.target.className&&(0<$("#serverguide-show .map-rotation").length||a.mapRotationBF3.updateServerInfo(a))},!0),a.mapRotationBF3.updateServerInfo(a))},updateServerInfo:function(a){null!==a.mapRotationBF3.active_ajax&&a.mapRotationBF3.active_ajax.abort();
$('<div class="map-rotation"><div class="maps-icons wait-to-load">☰</div></div>').insertBefore("#selected-server-mapimage");a.mapRotationBF3.getMapRotation(a)},getMapRotation:function(a){var c=$("#selected-server-name a").attr("href");a.mapRotationBF3.active_ajax=$.ajax({url:c,success:function(b){a.mapRotationBF3.active_ajax=null;b=a.mapRotationBF3.parseMapRotation(b);b.error?$("#serverguide-show .map-rotation .maps-icons").html("☰ Error"):a.mapRotationBF3.showMapRotation(a,b.maps)}})},
parseMapRotation:function(a){if(!a.match(/ ip="([^"]+)"/i)||a.match(/ ip="([^"]+)"/i)[1]!==$("#serverguide-show-serverjoin .base-button-arrow-almost-gigantic").data("ip")||0===$("#serverguide-show .map-rotation").length)return{error:!0};var c=[],b=$("#selected-server-info li")[2].innerHTML.trim();a=$(a).find("#maprotation").html();$(a).find("td").each(function(){if(0!==$(this).find(".maprotation-map-image-wpr img").length){var a=$(this).find(".maprotation-map-image-wpr img"),e=a.data("tooltip").split("<br>")[0],
d=a.data("tooltip").split("<br>")[1],a=a.attr("src").trim().replace("/146x79/","/IMAGExSIZE/"),f=$(this).attr("class").match("currentMap")?!0:!1;f&&d!==b&&(f=!1);c.push({name:e.trim(),mode:d.trim(),image:{big:a.replace("IMAGExSIZE","992x164"),medium:a.replace("IMAGExSIZE","146x79"),small:a.replace("IMAGExSIZE","62x42")},active:f})}});return{maps:c,error:!1}},showMapRotation:function(a,c){a.mapRotationBF3.active_server.id=$("#serverguide-show-serverjoin .base-button-arrow-almost-gigantic").data("guid");
a.mapRotationBF3.active_server.maps=c;for(var b=0,g,e=$('<div class="maps-icons"></div>'),d=function(){a.mapRotationBF3.showMapRotationPopUp(a,parseInt($(this).data("index"),10))},b=0;b<c.length;b++)g=$('<img class="'+(c[b].active?"active ":"")+'map-icon" src="'+c[b].image.small+'" data-tooltip="'+c[b].name+" - "+c[b].mode+'" data-index="'+b+'"/>'),g.click(d),e.append(g);$("#serverguide-show .map-rotation").html("").append(e)},showMapRotationPopUp:function(a,c){var b,g,e=c,d=a.mapRotationBF3.active_server.maps,
f=d[e],m,h,k,n,p,q,l,r;BBLog.popup(a.id,"["+(e+1)+"/"+d.length+"] "+f.name+" - "+f.mode,"");m=$("#popup-"+a.id).addClass("dialog-map-rotation");h=m.find(".dialog-body").css("background-image","url('"+f.image.big+"')");k=$('<div class="active-indicator"><h6>Active</h6><div class="loader small"></div></div>').hide();f.active&&k.show();n=$('<div class="scroll-button left-scroll-button"><</div>');p=$('<div class="scroll-button right-scroll-button">></div>');q=$('<div class="map-name"><h1>'+f.name+
" - "+f.mode+"</h1></div>");l=$('<div style="width:'+(148*(d.length+1)+1)+'px;margin-left:992px;"></div>');for(b=0;b<d.length;b++)g=$('<div class="map-preview" style="background-image:url('+d[b].image.medium+');"></div>'),g.append('<div class="map-preview-title">'+d[b].name+"<br>"+d[b].mode+"</div>"),d[b].active&&(g.css("border-color","#60c0f6"),g.append('<div class="active-preview"></div>')),b===e&&g.css("box-shadow","0px 0px 10px white inset"),d[b].preview_element=g,l.append(g);h.append(k);h.append(n);
h.append(p);h.append(q);h.append($('<div class="map-carousel">').append(l));l.animate({marginLeft:422-148*e},500);r=function(a){if(a!==e){if(0>a){if(a=d.length-1,a===e)return}else if(a>d.length-1&&(a=0,a===e))return;d[e].preview_element.css("box-shadow","");e=a;f=d[e];f.preview_element.css("box-shadow","0px 0px 10px white inset");q.html("<h1>"+f.name+" - "+f.mode+"</h1>");h.css("background-image","url('"+f.image.big+"')");m.find("header h3").html("["+(e+1)+"/"+d.length+"] "+f.name+" - "+f.mode);f.active?
k.show():k.hide();l.animate({marginLeft:422-148*e},500)}};n.click(function(){r(e-1)});p.click(function(){r(e+1)})}}});