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

Z Altaron Wiki
Nie podano opisu zmian
Znacznik: Wycofane
Nie podano opisu zmian
Znacznik: Wycofane
Linia 5: Linia 5:
// Tablica obiektów z tekstami i nazwami ikon dla każdego linku
// Tablica obiektów z tekstami i nazwami ikon dla każdego linku
var linksData = [
var linksData = [
   { text: ' mainpage', icon: 'fa-home' },
   { text: ' mainpage', icon: 'fas fa-home' },
   { text: ' Poradniki', icon: 'fa-book' },
   { text: ' Poradniki', icon: 'fas fa-book' },
   { text: ' Przedmioty', icon: 'fa-cube' },
   { text: ' Przedmioty', icon: 'fas fa-cube' },
   { text: ' Potwory', icon: 'fa-dragon' },
   { text: ' Potwory', icon: 'fas fa-dragon' },
   { text: ' Czary', icon: 'fa-magic' },
   { text: ' Czary', icon: 'fas fa-magic' },
   { text: ' Transport', icon: 'fa-train' },
   { text: ' Transport', icon: 'fas fa-train' },
   { text: ' Questy', icon: 'fa-map' },
   { text: ' Questy', icon: 'fas fa-map' },
   { text: ' Żywioły', icon: 'fa-tint' },
   { text: ' Żywioły', icon: 'fas fa-tint' },
   { text: ' NPC', icon: 'fa-user' },
   { text: ' NPC', icon: 'fas fa-user' },
   { text: ' Stroje', icon: 'fa-tshirt' },
   { text: ' Stroje', icon: 'fas fa-tshirt' },
   { text: ' Miasta i osady', icon: 'fa-building' },
   { text: ' Miasta i osady', icon: 'fas fa-building' },
   { text: ' Pozyskiwanie', icon: 'fa-tree' },
   { text: ' Pozyskiwanie', icon: 'fas fa-tree' },
   { text: ' Przepisy', icon: 'fa-scroll' },
   { text: ' Przepisy', icon: 'fas fa-scroll' },
   { text: ' TODO', icon: 'fa-tasks' },
   { text: ' TODO', icon: 'fas fa-tasks' },
   { text: ' Szablony', icon: 'fa-file-code' },
   { text: ' Szablony', icon: 'fas fa-file-code' },
   { text: ' Losowa strona', icon: 'fa-random' },
   { text: ' Losowa strona', icon: 'fas fa-random' },
   { text: ' Ostatnie zmiany', icon: 'fa-history' },
   { text: ' Ostatnie zmiany', icon: 'fas fa-history' },
];
];


Linia 34: Linia 34:
   // Pobierz nazwę ikony z tablicy obiektów dla danego linku
   // Pobierz nazwę ikony z tablicy obiektów dla danego linku
   var iconName = linksData[i].icon;
   var iconName = linksData[i].icon;
   icon.classList.add('fa', iconName);
   icon.className = iconName;
   link.innerHTML = '';
   link.innerHTML = '';
   link.appendChild(icon);
   link.appendChild(icon);
   link.appendChild(document.createTextNode(' ' + text));
   link.appendChild(document.createTextNode(' ' + text));
}
}

Wersja z 03:36, 16 lut 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");

// Tablica obiektów z tekstami i nazwami ikon dla każdego linku
var linksData = [
  { text: ' mainpage', icon: 'fas fa-home' },
  { text: ' Poradniki', icon: 'fas fa-book' },
  { text: ' Przedmioty', icon: 'fas fa-cube' },
  { text: ' Potwory', icon: 'fas fa-dragon' },
  { text: ' Czary', icon: 'fas fa-magic' },
  { text: ' Transport', icon: 'fas fa-train' },
  { text: ' Questy', icon: 'fas fa-map' },
  { text: ' Żywioły', icon: 'fas fa-tint' },
  { text: ' NPC', icon: 'fas fa-user' },
  { text: ' Stroje', icon: 'fas fa-tshirt' },
  { text: ' Miasta i osady', icon: 'fas fa-building' },
  { text: ' Pozyskiwanie', icon: 'fas fa-tree' },
  { text: ' Przepisy', icon: 'fas fa-scroll' },
  { text: ' TODO', icon: 'fas fa-tasks' },
  { text: ' Szablony', icon: 'fas fa-file-code' },
  { text: ' Losowa strona', icon: 'fas fa-random' },
  { text: ' Ostatnie zmiany', icon: 'fas fa-history' },
];

// Pobierz wszystkie linki znajdujące się w menu bocznym
var links = document.querySelectorAll('#mw-panel ul li a');

// Dla każdego linku dodaj ikonkę fontawesome przed tekstem
for (var i = 0; i < links.length; i++) {
  var link = links[i];
  var text = link.innerText;
  var icon = document.createElement('span');
  // Pobierz nazwę ikony z tablicy obiektów dla danego linku
  var iconName = linksData[i].icon;
  icon.className = iconName;
  link.innerHTML = '';
  link.appendChild(icon);
  link.appendChild(document.createTextNode(' ' + text));
}