MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Add A–Z articles to the staging wiki navigation sidebar |
Match forum pill order and branding, with a compact TechWiki browse row |
||
| Line 9: | Line 9: | ||
const shell = document.createElement('div'); | const shell = document.createElement('div'); | ||
shell.className = 'seloc-wiki-shell'; | shell.className = 'seloc-wiki-shell'; | ||
const brand = document.createElement('a'); | |||
brand.className = 'seloc-wiki-brand'; | |||
brand.href = home; | |||
const logo = document.querySelector('#p-logo a'); | |||
if (logo) { | |||
const artwork = getComputedStyle(logo).backgroundImage; | |||
if (artwork && artwork !== 'none') { | |||
const mark = document.createElement('span'); | |||
mark.className = 'seloc-wiki-mark'; | |||
mark.style.backgroundImage = artwork; | |||
mark.setAttribute('aria-hidden', 'true'); | |||
brand.append(mark); | |||
} | |||
} | |||
brand.append(document.createTextNode('LOTUS Enthusiasts Club')); | |||
const nav = document.createElement('nav'); | const nav = document.createElement('nav'); | ||
nav.className = 'seloc-wiki-primary'; | |||
nav.setAttribute('aria-label', 'SELOC staging sites'); | nav.setAttribute('aria-label', 'SELOC staging sites'); | ||
for (const [name, href] of [ | for (const [name, href] of [ | ||
['Forums', 'https://forumsug.seloc.org/'], | ['Forums', 'https://forumsug.seloc.org/'], | ||
['TechWiki', home], | ['TechWiki', home], | ||
['Gallery', 'https://forumsug.seloc.org/cp_gallery.php'], | ['Gallery', 'https://forumsug.seloc.org/cp_gallery.php'], | ||
['Classifieds', 'https://classifiedsug.seloc.org/'] | ['Classifieds', 'https://classifiedsug.seloc.org/'], | ||
['Advertisers', 'https://www.seloc.org/advertisers.php'] | |||
]) { | ]) { | ||
const link = document.createElement('a'); | const link = document.createElement('a'); | ||
| Line 52: | Line 68: | ||
else sidebar.prepend(item); | else sidebar.prepend(item); | ||
} | } | ||
shell.append(nav, form); | const browse = document.createElement('nav'); | ||
browse.className = 'seloc-wiki-secondary'; | |||
browse.setAttribute('aria-label', 'Browse TechWiki'); | |||
for (const [name, href] of [ | |||
['Models', home + '#Lotus_Cars'], | |||
['Technical subjects', home + '#Technical_Pages'], | |||
['Resources', home + '#Non_Technical_Pages'], | |||
['A–Z articles', '/a/Special:AllPages'], | |||
['Club site', 'https://f.seloc.club/w691/'] | |||
]) { | |||
const link = document.createElement('a'); | |||
link.href = href; | |||
link.textContent = name; | |||
browse.append(link); | |||
} | |||
index.remove(); | |||
shell.append(brand, nav, browse, form); | |||
content.prepend(shell); | content.prepend(shell); | ||
content.classList.add('seloc-wiki-enhanced'); | content.classList.add('seloc-wiki-enhanced'); | ||
document.body.classList.add('seloc-wiki-themed'); | |||
if (mw.config.get('wgNamespaceNumber') === 0 && !mw.config.get('wgIsMainPage')) { | if (mw.config.get('wgNamespaceNumber') === 0 && !mw.config.get('wgIsMainPage')) { | ||
content.classList.add('seloc-wiki-article'); | content.classList.add('seloc-wiki-article'); | ||
Revision as of 22:32, 5 November 2026
/* 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 brand = document.createElement('a');
brand.className = 'seloc-wiki-brand';
brand.href = home;
const logo = document.querySelector('#p-logo a');
if (logo) {
const artwork = getComputedStyle(logo).backgroundImage;
if (artwork && artwork !== 'none') {
const mark = document.createElement('span');
mark.className = 'seloc-wiki-mark';
mark.style.backgroundImage = artwork;
mark.setAttribute('aria-hidden', 'true');
brand.append(mark);
}
}
brand.append(document.createTextNode('LOTUS Enthusiasts Club'));
const nav = document.createElement('nav');
nav.className = 'seloc-wiki-primary';
nav.setAttribute('aria-label', 'SELOC staging sites');
for (const [name, href] of [
['Forums', 'https://forumsug.seloc.org/'],
['TechWiki', home],
['Gallery', 'https://forumsug.seloc.org/cp_gallery.php'],
['Classifieds', 'https://classifiedsug.seloc.org/'],
['Advertisers', 'https://www.seloc.org/advertisers.php']
]) {
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);
const sidebar = document.querySelector('#p-navigation ul');
if (sidebar && !document.getElementById('n-seloc-article-index')) {
const item = document.createElement('li');
item.id = 'n-seloc-article-index';
item.append(index.cloneNode(true));
const homeItem = sidebar.querySelector('#n-mainpage');
if (homeItem) homeItem.after(item);
else sidebar.prepend(item);
}
const browse = document.createElement('nav');
browse.className = 'seloc-wiki-secondary';
browse.setAttribute('aria-label', 'Browse TechWiki');
for (const [name, href] of [
['Models', home + '#Lotus_Cars'],
['Technical subjects', home + '#Technical_Pages'],
['Resources', home + '#Non_Technical_Pages'],
['A–Z articles', '/a/Special:AllPages'],
['Club site', 'https://f.seloc.club/w691/']
]) {
const link = document.createElement('a');
link.href = href;
link.textContent = name;
browse.append(link);
}
index.remove();
shell.append(brand, nav, browse, form);
content.prepend(shell);
content.classList.add('seloc-wiki-enhanced');
document.body.classList.add('seloc-wiki-themed');
if (mw.config.get('wgNamespaceNumber') === 0 && !mw.config.get('wgIsMainPage')) {
content.classList.add('seloc-wiki-article');
}
});
}());