MediaWiki:Common.js: Różnice pomiędzy wersjami

Z Altaron Wiki
Nie podano opisu zmian
Nie podano opisu zmian
Linia 4: Linia 4:




var linksData = [  { text: 'mainpage', icon: 'fas fa-home fa-fw' },  { text: 'Poradniki', icon: 'fas fa-book fa-fw' },  { text: 'Przedmioty', icon: 'fas fa-cube fa-fw' },  { text: 'Potwory', icon: 'fas fa-dragon fa-fw' },  { text: 'Czary', icon: 'fas fa-magic fa-fw' },  { text: 'Transport', icon: 'fas fa-train fa-fw' },  { text: 'Questy', icon: 'fas fa-map fa-fw' },  { text: 'Żywioły', icon: 'fas fa-tint fa-fw' },  { text: 'NPC', icon: 'fas fa-user fa-fw' },  { text: 'Stroje', icon: 'fas fa-tshirt fa-fw' },  { text: 'Miasta i osady', icon: 'fas fa-building fa-fw' },  { text: 'Pozyskiwanie', icon: 'fas fa-tree fa-fw' },  { text: 'Przepisy', icon: 'fas fa-scroll fa-fw' },  { text: 'TODO', icon: 'fas fa-tasks fa-fw' },  { text: 'Szablony', icon: 'fas fa-file-code fa-fw' },  { text: 'Losowa strona', icon: 'fas fa-random fa-fw' },  { text: 'Ostatnie zmiany', icon: 'fas fa-history fa-fw' },];
(function() {
var linksData = [  { text: 'mainpage', icon: 'fas fa-home fa-fw' },  { text: 'Poradniki', icon: 'fas fa-book fa-fw' },  { text: 'Przedmioty', icon: 'fas fa-cube fa-fw' },  { text: 'Potwory', icon: 'fas fa-dragon fa-fw' },  { text: 'Czary', icon: 'fas fa-magic fa-fw' },  { text: 'Transport', icon: 'fas fa-train fa-fw' },  { text: 'Questy', icon: 'fas fa-map fa-fw' },  { text: 'Żywioły', icon: 'fas fa-tint fa-fw' },  { text: 'NPC', icon: 'fas fa-user fa-fw' },  { text: 'Stroje', icon: 'fas fa-tshirt fa-fw' },  { text: 'Miasta i osady', icon: 'fas fa-building fa-fw' },  { text: 'Pozyskiwanie', icon: 'fas fa-tree fa-fw' },  { text: 'Przepisy', icon: 'fas fa-scroll fa-fw' },  { text: 'TODO', icon: 'fas fa-tasks fa-fw' },  { text: 'Szablony', icon: 'fas fa-file-code fa-fw' },  { text: 'Losowa strona', icon: 'fas fa-random fa-fw' },  { text: 'Ostatnie zmiany', icon: 'fas fa-history fa-fw' },];
var links = document.querySelectorAll('#mw-panel ul li a');
for (var i = 0; i < links.length; i++) {
  var link = links[i];
 
  if (linksData[i]) {
  var text = link.innerText;
  var icon = document.createElement('span');
 
  var iconName = linksData[i].icon;
  icon.className = 'icon ' + iconName;
  link.innerHTML = '';
  link.appendChild(icon);
  link.appendChild(document.createTextNode(text));
  }
}
})();
 
(function() {
// npc info-box
$('.npc-infobox').each(function(){
console.log(this);
 
var box = $(this);
$(box).find('.npc-infobox-tab-content, .npc-infobox-tab').removeClass('active');


var links = document.querySelectorAll('#mw-panel ul li a');
// add indices
$(box).find('.npc-infobox-tab-content').each(function(index,el){
$(el).data('npc-infobox-tab-index', index);
});
$(box).find('.npc-infobox-tab').each(function(index,el){
$(el).data('npc-infobox-tab-index', index);
});


for (var i = 0; i < links.length; i++) {
var showTab = function(index) {
  var link = links[i];
$(box).find('.npc-infobox-tab-content').each(function(idx, el){
 
if (idx == index) {
  if (linksData[i]) {
$(el).addClass('active');
  var text = link.innerText;
}
  var icon = document.createElement('span');
});
 
};
  var iconName = linksData[i].icon;
  icon.className = 'icon ' + iconName;
  link.innerHTML = '';
  link.appendChild(icon);
  link.appendChild(document.createTextNode(text));
  }


}
$(box).find('.npc-infobox-tab').click(function(){
var index = $(this).data('npc-infobox-tab-index');
$(box).find('.npc-infobox-tab-content, .npc-infobox-tab').removeClass('active');
$(this).addClass('active');
showTab(index);
return false;
});
showTab(0);
});
})();

Wersja z 18:36, 13 maj 2023

/* Umieszczony tutaj kod JavaScript zostanie załadowany przez każdego użytkownika, podczas każdego ładowania strony. */

mw.loader.load("https://wiki.altaron.pl/custom/table-sorter/jquery.tablesorter.js");


(function() {
	var linksData = [  { text: 'mainpage', icon: 'fas fa-home fa-fw' },  { text: 'Poradniki', icon: 'fas fa-book fa-fw' },  { text: 'Przedmioty', icon: 'fas fa-cube fa-fw' },  { text: 'Potwory', icon: 'fas fa-dragon fa-fw' },  { text: 'Czary', icon: 'fas fa-magic fa-fw' },  { text: 'Transport', icon: 'fas fa-train fa-fw' },  { text: 'Questy', icon: 'fas fa-map fa-fw' },  { text: 'Żywioły', icon: 'fas fa-tint fa-fw' },  { text: 'NPC', icon: 'fas fa-user fa-fw' },  { text: 'Stroje', icon: 'fas fa-tshirt fa-fw' },  { text: 'Miasta i osady', icon: 'fas fa-building fa-fw' },  { text: 'Pozyskiwanie', icon: 'fas fa-tree fa-fw' },  { text: 'Przepisy', icon: 'fas fa-scroll fa-fw' },  { text: 'TODO', icon: 'fas fa-tasks fa-fw' },  { text: 'Szablony', icon: 'fas fa-file-code fa-fw' },  { text: 'Losowa strona', icon: 'fas fa-random fa-fw' },  { text: 'Ostatnie zmiany', icon: 'fas fa-history fa-fw' },];
	var links = document.querySelectorAll('#mw-panel ul li a');
	
	for (var i = 0; i < links.length; i++) {
	  var link = links[i];
	  
	  if (linksData[i]) {
		  var text = link.innerText;
		  var icon = document.createElement('span');
		  
		  var iconName = linksData[i].icon;
		  icon.className = 'icon ' + iconName;
		  link.innerHTML = '';
		  link.appendChild(icon);
		  link.appendChild(document.createTextNode(text));
	  }
	
	}
})();

(function() {
		// npc info-box
		$('.npc-infobox').each(function(){
			console.log(this);

			var box = $(this);
			$(box).find('.npc-infobox-tab-content, .npc-infobox-tab').removeClass('active');

			// add indices
			$(box).find('.npc-infobox-tab-content').each(function(index,el){
				$(el).data('npc-infobox-tab-index', index);
			});
			$(box).find('.npc-infobox-tab').each(function(index,el){
				$(el).data('npc-infobox-tab-index', index);
			});

			var showTab = function(index) {
				$(box).find('.npc-infobox-tab-content').each(function(idx, el){
					if (idx == index) {
						$(el).addClass('active');
					}
				});
			};

			$(box).find('.npc-infobox-tab').click(function(){
				var index = $(this).data('npc-infobox-tab-index');
				$(box).find('.npc-infobox-tab-content, .npc-infobox-tab').removeClass('active');
				$(this).addClass('active');
				showTab(index);
				return false;	
			});
			
			showTab(0);
		});
	
})();