MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Staging TechWiki navigation and native search. */
(function () {
'use strict';
if (location.hostname !== 'wikiug.seloc.org' || mw.config.get('wgAction') !== 'view') return;
$(function () {
const content = document.querySelector('#content');
if (!content || document.querySelector('.seloc-wiki-shell')) return;
const home = '/a/SELOC_TechWiki';
const shell = document.createElement('div');
shell.className = 'seloc-wiki-shell';
const nav = document.createElement('nav');
nav.setAttribute('aria-label', 'SELOC staging sites');
for (const [name, href] of [
['Club site', 'https://f.seloc.club/w691/'],
['Forums', 'https://forumsug.seloc.org/'],
['TechWiki', home],
['Gallery', 'https://forumsug.seloc.org/cp_gallery.php'],
['Classifieds', 'https://classifiedsug.seloc.org/']
]) {
const link = document.createElement('a');
link.href = href;
link.textContent = name;
if (name === 'TechWiki') link.setAttribute('aria-current', 'true');
nav.append(link);
}
const form = document.createElement('form');
form.action = mw.config.get('wgScript');
form.method = 'get';
form.setAttribute('role', 'search');
form.setAttribute('aria-label', 'TechWiki articles');
for (const [name, value] of [['title', 'Special:Search'], ['fulltext', '1']]) {
const field = document.createElement('input');
field.type = 'hidden'; field.name = name; field.value = value;
form.append(field);
}
const query = document.createElement('input');
query.type = 'search'; query.name = 'search'; query.required = true;
query.placeholder = 'Search models, parts or jobs';
query.setAttribute('aria-label', 'Search TechWiki articles');
const submit = document.createElement('button');
submit.type = 'submit'; submit.textContent = 'Search';
const index = document.createElement('a');
index.href = '/a/Special:AllPages'; index.textContent = 'A–Z articles';
form.append(query, submit, index);
shell.append(nav, form);
content.prepend(shell);
content.classList.add('seloc-wiki-enhanced');
if (mw.config.get('wgNamespaceNumber') === 0 && !mw.config.get('wgIsMainPage')) {
content.classList.add('seloc-wiki-article');
}
});
}());