MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 28: | Line 28: | ||
//aesthetic | //aesthetic | ||
/ | /* 70s Prog / Psych dynamic background | ||
* Drop into MediaWiki:Common.js | |||
* | */ | ||
mw.loader.using('jquery', function () { | |||
var body = document.body; | |||
// Turn it on | |||
body.classList.add('prog70s-bg'); | |||
/ | // Add grain overlay element | ||
var grain = document.createElement('div'); | |||
grain.id = 'prog70s-grain'; | |||
body.appendChild(grain); | |||
/ | // Palettes inspired by 70s prog/psych vibes | ||
var palettes = [ | |||
{ | |||
// Warm orange / magenta – generic psych poster | |||
name: 'Sunburst', | |||
a: '#ff9a00', | |||
b: '#ff005c', | |||
c: '#7b5cff', | |||
} | d: '#00f0ff' | ||
}, | |||
{ | |||
// Earth tones + cyan – more pastoral prog | |||
name: 'Pastoral', | |||
a: '#ffb347', | |||
b: '#ff6a88', | |||
c: '#48c6ef', | |||
d: '#3fffa8' | |||
}, | |||
{ | |||
// Deep cosmic – darker late-night vibe | |||
name: 'Cosmic', | |||
a: '#ff4b1f', | |||
b: '#1fddff', | |||
c: '#7f00ff', | |||
d: '#ffe000' | |||
}, | |||
{ | |||
// Acid lime & hot pink – more aggressive psych | |||
name: 'Acid', | |||
a: '#fdfc47', | |||
b: '#24fe41', | |||
c: '#ff00aa', | |||
d: '#ff5f6d' | |||
} | |||
]; | |||
function applyPalette(p) { | |||
var root = document.documentElement; | |||
root.style.setProperty('--prog70s-color-a', p.a); | |||
root.style.setProperty('--prog70s-color-b', p.b); | |||
root.style.setProperty('--prog70s-color-c', p.c); | |||
root.style.setProperty('--prog70s-color-d', p.d); | |||
} | |||
// Start with a random palette | |||
var index = Math.floor(Math.random() * palettes.length); | |||
applyPalette(palettes[index]); | |||
/ | // Slowly rotate palettes | ||
window.setInterval(function () { | |||
index = (index + 1) % palettes.length; | |||
applyPalette(palettes[index]); | |||
}, 70000); // 70s seconds per change, obviously | |||
/ | // Toggle button | ||
var $btn = $('<button>', { | |||
id: 'prog70s-toggle', | |||
} | text: 'Prog 70s: On' | ||
}); | |||
function updateButton() { | |||
if (body.classList.contains('prog70s-off')) { | |||
$btn.text('Prog 70s: Off'); | |||
} else { | |||
$btn.text('Prog 70s: On'); | |||
} | |||
} | } | ||
$btn.on('click', function () { | |||
body.classList.toggle('prog70s-off'); | |||
updateButton(); | |||
}); | |||
$('body').append($btn); | |||
updateButton(); | |||
}); | |||
} | |||
Revision as of 06:20, 26 November 2025
/* Any JavaScript here will be loaded for all users on every page load. */
// Auto-preload template for Shared_Experiences new story form
mw.hook('wikipage.content').add(function () {
// Only run on new-section add
if (
mw.config.get('wgPageName') === 'Shared_Experiences' &&
mw.config.get('wgAction') === 'edit' &&
new URLSearchParams(window.location.search).get('section') === 'new'
) {
var textbox = document.getElementById('wpTextbox1');
// Only insert if the textbox is empty
if (textbox && textbox.value.trim() === '') {
new mw.Api().get({
action: 'parse',
page: 'Template:SharedExperience/Preload',
prop: 'wikitext',
format: 'json'
}).done(function (data) {
// FIX: MediaWiki stores wikitext under ['*']
textbox.value = data.parse.wikitext['*'];
});
}
}
});
//aesthetic
/* 70s Prog / Psych dynamic background
* Drop into MediaWiki:Common.js
*/
mw.loader.using('jquery', function () {
var body = document.body;
// Turn it on
body.classList.add('prog70s-bg');
// Add grain overlay element
var grain = document.createElement('div');
grain.id = 'prog70s-grain';
body.appendChild(grain);
// Palettes inspired by 70s prog/psych vibes
var palettes = [
{
// Warm orange / magenta – generic psych poster
name: 'Sunburst',
a: '#ff9a00',
b: '#ff005c',
c: '#7b5cff',
d: '#00f0ff'
},
{
// Earth tones + cyan – more pastoral prog
name: 'Pastoral',
a: '#ffb347',
b: '#ff6a88',
c: '#48c6ef',
d: '#3fffa8'
},
{
// Deep cosmic – darker late-night vibe
name: 'Cosmic',
a: '#ff4b1f',
b: '#1fddff',
c: '#7f00ff',
d: '#ffe000'
},
{
// Acid lime & hot pink – more aggressive psych
name: 'Acid',
a: '#fdfc47',
b: '#24fe41',
c: '#ff00aa',
d: '#ff5f6d'
}
];
function applyPalette(p) {
var root = document.documentElement;
root.style.setProperty('--prog70s-color-a', p.a);
root.style.setProperty('--prog70s-color-b', p.b);
root.style.setProperty('--prog70s-color-c', p.c);
root.style.setProperty('--prog70s-color-d', p.d);
}
// Start with a random palette
var index = Math.floor(Math.random() * palettes.length);
applyPalette(palettes[index]);
// Slowly rotate palettes
window.setInterval(function () {
index = (index + 1) % palettes.length;
applyPalette(palettes[index]);
}, 70000); // 70s seconds per change, obviously
// Toggle button
var $btn = $('<button>', {
id: 'prog70s-toggle',
text: 'Prog 70s: On'
});
function updateButton() {
if (body.classList.contains('prog70s-off')) {
$btn.text('Prog 70s: Off');
} else {
$btn.text('Prog 70s: On');
}
}
$btn.on('click', function () {
body.classList.toggle('prog70s-off');
updateButton();
});
$('body').append($btn);
updateButton();
});