Welcome to IOPWiki, Commander.
We are searching for new editors to keep track of Girls' Frontline 2 content, as well as veteran players to complete the data of Girls' Frontline and Project Neural Cloud characters.
You can contribute without an account. Learn how to contribute and join our Discord server.

MediaWiki:Gadget-artTab.js: 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
m Typo
One more step...
Line 1: Line 1:
function switchVariant(event, variant) {
function switchVariant(event, variant) {
   var currentElement = $(event.target);
   var currentElement = $(event.target);
   var artTabDiv = currentElement .closest('.artTab');
   var artTabDiv = currentElement.closest('.artTab');
   artTabDiv.find('.artTabLinks').removeClass('active');
   artTabDiv.find('.artTabLinks').removeClass('active');
   artTabDiv.find('.artTabContent .fullart').hide();
   artTabDiv.find('.artTabContent .fullart').hide();
Line 15: Line 15:
   currentElement.addClass('active');
   currentElement.addClass('active');
}
}
function modelChanged(event) {
  console.log(event);
  var fullartPath = basePath + "thumb/" + cpp(costumeId +".png") + costumeId +".png/420px-" + costumeId +".png";
  var fullartDamagedPath = basePath + "thumb/" + cpp(costumeId +"_D.png") + costumeId +"_D.png/420px-" + costumeId +"_D.png";
   
  $("#fullart a").attr("href", fullartPath );
  $("#fullart a img").attr("src", fullartPath );
  $("#fullart a img").attr("srcset", fullartPath );
  $("#fullart a img").attr("alt", fullartPath );
  $("#fullart_D a").attr("href", fullartDamagedPath );
  $("#fullart_D a img").attr("src", fullartDamagedPath );
  $("#fullart_D a img").attr("srcset", fullartDamagedPath );
  $("#fullart_D a img").attr("alt", fullartDamagedPath );
};


RLQ.push(function () {
RLQ.push(function () {
   $(document).ready(function() {  
   $(document).ready(function() {  
     var artTabDiv = $('.artTab');
     var artTabDiv = $('.artTab');
    artTabDiv.on('modelchanged', modelChanged);
    
    
     var normalButton = $('<button></button>');
     var normalButton = $('<button></button>');

Revision as of 02:43, 13 January 2018

function switchVariant(event, variant) {
  var currentElement = $(event.target);
  var artTabDiv = currentElement.closest('.artTab');
  artTabDiv.find('.artTabLinks').removeClass('active');
  artTabDiv.find('.artTabContent .fullart').hide();
  
  var live2dActive = false; // ToDo
  if (live2dActive) {
    console.log("?");
  } else {
    artTabDiv.find("[data-variant='" + currentElement.data('variant') +"']").show();
  }

  // Set "active" at the end
  currentElement.addClass('active');
}

function modelChanged(event) {
  console.log(event);

  var fullartPath = basePath + "thumb/" + cpp(costumeId +".png") + costumeId +".png/420px-" + costumeId +".png";
  var fullartDamagedPath = basePath + "thumb/" + cpp(costumeId +"_D.png") + costumeId +"_D.png/420px-" + costumeId +"_D.png";
    
  $("#fullart a").attr("href", fullartPath );
  $("#fullart a img").attr("src", fullartPath );
  $("#fullart a img").attr("srcset", fullartPath );
  $("#fullart a img").attr("alt", fullartPath );

  $("#fullart_D a").attr("href", fullartDamagedPath );
  $("#fullart_D a img").attr("src", fullartDamagedPath );
  $("#fullart_D a img").attr("srcset", fullartDamagedPath );
  $("#fullart_D a img").attr("alt", fullartDamagedPath );
};

RLQ.push(function () {
  $(document).ready(function() { 
    var artTabDiv = $('.artTab');
    artTabDiv.on('modelchanged', modelChanged);
  
    var normalButton = $('<button></button>');
    normalButton.addClass('artTabLinks');
    normalButton.click(switchVariant);
    normalButton.data('variant', "");
    normalButton.text("Normal");

    var damagedButton = $('<button></button>');
    damagedButton.addClass('artTabLinks');
    damagedButton.click(switchVariant);
    damagedButton.data('variant', "D");
    damagedButton.text("Damaged");
  
    var variantswitcher = $('<div></div>');
    variantswitcher.addClass('variantswitcher');
    variantswitcher.append(normalButton);
    variantswitcher.append(damagedButton);
    
    artTabDiv.prepend(variantswitcher);

    normalButton.click();
  });
});