Welcome to IOPWiki, Commander.
We are searching for editors to complete gameplay topics in all games. You can contribute without an account. Learn how to contribute and join our Discord server.

Widget:mainpage: Difference between revisions

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search
Pianoforte (talk | contribs)
No edit summary
Added document-ready wait functionality as the MediaWiki does not wait for DOM
 
(15 intermediate revisions by 3 users not shown)
Line 16: Line 16:
}
}


function changeServer () {
function changeServer (serverName) {
  var serverName = document.getElementById("serverForm").value;
 
   document.cookie = "serverSelection=" + serverName;
   document.cookie = "serverSelection=" + serverName;
  tablinks = document.getElementsByClassName("serverTabLinks");
  for (i = 0; i < tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace("serverTabLinks-active", "");
  }
  document.getElementById('serverTabLink-' + serverName).className += " serverTabLinks-active";


   $(".banners, .promotions, .updates").each(function(){
   $(".banners, .promotions, .updates").each(function(){
     this.style.position="absolute";
     this.style.position="absolute";
     this.style.visibility="hidden";})
     this.style.visibility="hidden";
  })
    
    
   document.getElementById("banner-" + serverName).style.position = "relative";
   document.getElementById("banner-" + serverName).style.position = "relative";
Line 34: Line 43:


   $(".jcarousel-item").each(function(){$(this).css("width", $(this).parent().parent().outerWidth());})
   $(".jcarousel-item").each(function(){$(this).css("width", $(this).parent().parent().outerWidth());})


   $("div#banner-" + serverName + " > div > div > div").each(function(){$(this.firstChild).attr("src", $(this).data("value"))});   
   $("div#banner-" + serverName + " > div > div > div").each(function(){$(this.firstChild).attr("src", $(this).data("value"))});   
   $("div#promotion-" + serverName + " > div > div > div").each(function(){$(this.getElementsByTagName('img')[1]).attr("src", $(this).data("value"))});
   $("div#promotion-" + serverName + " > div > div > div").each(function(){$(this.getElementsByTagName('img')[1]).attr("src", $(this).data("value"))});
  if (serverName == "cn") {
      document.getElementById("eventsUrl").firstChild.href = "/wiki/Events";
      document.getElementById("updatesUrl").firstChild.href = "/wiki/Updates";
  } 
  else {
      document.getElementById("eventsUrl").firstChild.href = "/wiki/Events_(" + serverName.toUpperCase()+")";
      document.getElementById("updatesUrl").firstChild.href = "/wiki/Updates_(" + serverName.toUpperCase()+")";
  }
}
}


RLQ.push(function () {
RLQ.push(['jquery', function () {
   $(document).ready(function() {
   $(document).ready(function() {
     var serverSelection = getCookie ("serverSelection");  
     var serverSelection = getCookie ("serverSelection");  
     if (serverSelection == "") serverSelection = "cn"  
     if (serverSelection == "") serverSelection = "cn"; // This wiki is based on CN server


     $("#serverForm").val(serverSelection);
     var firstHeading = document.getElementById("firstHeading");
    if (firstHeading == null) {
        firstHeading = document.getElementsByClassName ("mf-section-0")[0];
        firstHeading.insertBefore(document.createElement ("H1"), firstHeading.firstChild);
        firstHeading = firstHeading.firstChild;
    }


     changeServer (serverSelection);  
    if (document.getElementsByClassName("serverTabLinks").length == 0) {
   
    serverTabSpan = document.createElement ("span");
 
    firstHeading.appendChild(serverTabSpan);
 
    serverTabSpan.outerHTML = '<span id="serverTabSpan">' +
        '<button id="serverTabLink-cn" class="serverTabLinks"  onclick="changeServer(\'cn\')">Bilibili/DigitalSky (CN)</button>' +
        '<button id="serverTabLink-en" class="serverTabLinks"  onclick="changeServer(\'en\')">Sunborngame (EN)</button>' +
        '<button id="serverTabLink-kr" class="serverTabLinks"  onclick="changeServer(\'kr\')">X.D. Global (KR)</button>' +
        '<button id="serverTabLink-tw" class="serverTabLinks"  onclick="changeServer(\'tw\')">Tianxia Game (TW)</button>' +
        '<button id="serverTabLink-jp" class="serverTabLinks"  onclick="changeServer(\'jp\')">Sunborngame (JP)</button>' +
        '<span>';
    }
 
     changeServer (serverSelection);
   });
   });
});
}]);
</script>
</script>
<select id="serverForm" style="background-color:rgba(250,250,250,0.9);width:100%" onchange="changeServer()" >
<option value="cn">CN</option>
<option value="kr">KR</option>
<option value="tw">TW</option>
<option value="jp">JP</option>
</select>

Latest revision as of 15:11, 14 October 2019

<script> function getCookie(cname) {

   var name = cname + "=";
   var decodedCookie = decodeURIComponent(document.cookie);
   var ca = decodedCookie.split(';');
   for(var i = 0; i <ca.length; i++) {
       var c = ca[i];
       while (c.charAt(0) == ' ') {
           c = c.substring(1);
       }
       if (c.indexOf(name) == 0) {
           return c.substring(name.length, c.length);
       }
   }
   return "";

}

function changeServer (serverName) {

  document.cookie = "serverSelection=" + serverName;


  tablinks = document.getElementsByClassName("serverTabLinks");
  for (i = 0; i < tablinks.length; i++) {
     tablinks[i].className = tablinks[i].className.replace("serverTabLinks-active", "");
  }
  document.getElementById('serverTabLink-' + serverName).className += " serverTabLinks-active";


  $(".banners, .promotions, .updates").each(function(){
   this.style.position="absolute";
   this.style.visibility="hidden";
  })
 
  document.getElementById("banner-" + serverName).style.position = "relative";
  document.getElementById("banner-" + serverName).style.visibility ="visible"; 
  document.getElementById("update-" + serverName).style.position = "relative";
  document.getElementById("update-" + serverName).style.visibility ="visible"; 
  document.getElementById("promotion-" + serverName).style.position = "relative";
  document.getElementById("promotion-" + serverName).style.visibility ="visible"; 
  $(".jcarousel-item").each(function(){$(this).css("width", $(this).parent().parent().outerWidth());})


  $("div#banner-" + serverName + " > div > div > div").each(function(){$(this.firstChild).attr("src", $(this).data("value"))});  
  $("div#promotion-" + serverName + " > div > div > div").each(function(){$(this.getElementsByTagName('img')[1]).attr("src", $(this).data("value"))});
  if (serverName == "cn") {
     document.getElementById("eventsUrl").firstChild.href = "/wiki/Events";
     document.getElementById("updatesUrl").firstChild.href = "/wiki/Updates";
  }   
  else {
     document.getElementById("eventsUrl").firstChild.href = "/wiki/Events_(" + serverName.toUpperCase()+")";
     document.getElementById("updatesUrl").firstChild.href = "/wiki/Updates_(" + serverName.toUpperCase()+")";
  }

}

RLQ.push(['jquery', function () {

 $(document).ready(function() {
   var serverSelection = getCookie ("serverSelection"); 
   if (serverSelection == "") serverSelection = "cn"; // This wiki is based on CN server
   var firstHeading = document.getElementById("firstHeading");
   if (firstHeading == null) {
       firstHeading = document.getElementsByClassName ("mf-section-0")[0];
       firstHeading.insertBefore(document.createElement ("H1"), firstHeading.firstChild);
       firstHeading = firstHeading.firstChild;
   }
   if (document.getElementsByClassName("serverTabLinks").length == 0) {
   
   serverTabSpan = document.createElement ("span"); 
   firstHeading.appendChild(serverTabSpan);
   serverTabSpan.outerHTML = '' + 
       '<button id="serverTabLink-cn" class="serverTabLinks"  onclick="changeServer(\'cn\')">Bilibili/DigitalSky (CN)</button>' +
       '<button id="serverTabLink-en" class="serverTabLinks"  onclick="changeServer(\'en\')">Sunborngame (EN)</button>' +
       '<button id="serverTabLink-kr" class="serverTabLinks"  onclick="changeServer(\'kr\')">X.D. Global (KR)</button>' +
       '<button id="serverTabLink-tw" class="serverTabLinks"  onclick="changeServer(\'tw\')">Tianxia Game (TW)</button>' +
       '<button id="serverTabLink-jp" class="serverTabLinks"  onclick="changeServer(\'jp\')">Sunborngame (JP)</button>' +
       '';
   }
   changeServer (serverSelection);
 });

}]); </script>