MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 27: | Line 27: | ||
//aesthetic | //aesthetic | ||
/* Psychedelic 70s frame – dark mode + white text */ | |||
/* 70s | |||
mw.loader.using('jquery', function () { | mw.loader.using('jquery', function () { | ||
var body = document.body; | var body = document.body; | ||
// Turn | // Turn on the theme | ||
body.classList.add(' | body.classList.add('psy70'); | ||
// | // Grain overlay element | ||
var grain = document.createElement('div'); | var grain = document.createElement('div'); | ||
grain.id = ' | grain.id = 'psy70-grain'; | ||
body.appendChild(grain); | body.appendChild(grain); | ||
// | // Color palettes with 70s prog/psych vibes | ||
var palettes = [ | var palettes = [ | ||
{ | { | ||
name: 'Sunburst', | name: 'Sunburst', | ||
a: '#ff9a00', | a: '#ff9a00', | ||
| Line 53: | Line 49: | ||
}, | }, | ||
{ | { | ||
name: 'Pastoral', | name: 'Pastoral', | ||
a: '#ffb347', | a: '#ffb347', | ||
| Line 61: | Line 56: | ||
}, | }, | ||
{ | { | ||
name: 'Cosmic', | name: 'Cosmic', | ||
a: '#ff4b1f', | a: '#ff4b1f', | ||
| Line 69: | Line 63: | ||
}, | }, | ||
{ | { | ||
name: 'Acid', | name: 'Acid', | ||
a: '#fdfc47', | a: '#fdfc47', | ||
| Line 80: | Line 73: | ||
function applyPalette(p) { | function applyPalette(p) { | ||
var root = document.documentElement; | var root = document.documentElement; | ||
root.style.setProperty('-- | root.style.setProperty('--psy70-color-a', p.a); | ||
root.style.setProperty('-- | root.style.setProperty('--psy70-color-b', p.b); | ||
root.style.setProperty('-- | root.style.setProperty('--psy70-color-c', p.c); | ||
root.style.setProperty('-- | root.style.setProperty('--psy70-color-d', p.d); | ||
} | } | ||
| Line 94: | Line 87: | ||
index = (index + 1) % palettes.length; | index = (index + 1) % palettes.length; | ||
applyPalette(palettes[index]); | applyPalette(palettes[index]); | ||
}, 70000); // | }, 70000); // ~70 seconds per switch | ||
// Toggle button | // Toggle button | ||
var $btn = $('<button>', { | var $btn = $('<button>', { | ||
id: ' | id: 'psy70-toggle', | ||
text: ' | text: 'Psy Frame: On' | ||
}); | }); | ||
function updateButton() { | function updateButton() { | ||
if (body.classList.contains(' | if (body.classList.contains('psy70-off')) { | ||
$btn.text(' | $btn.text('Psy Frame: Off'); | ||
} else { | } else { | ||
$btn.text(' | $btn.text('Psy Frame: On'); | ||
} | } | ||
} | } | ||
$btn.on('click', function () { | $btn.on('click', function () { | ||
body.classList.toggle(' | body.classList.toggle('psy70-off'); | ||
updateButton(); | updateButton(); | ||
}); | }); | ||
Revision as of 06:30, 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
/* Psychedelic 70s frame – dark mode + white text */
mw.loader.using('jquery', function () {
var body = document.body;
// Turn on the theme
body.classList.add('psy70');
// Grain overlay element
var grain = document.createElement('div');
grain.id = 'psy70-grain';
body.appendChild(grain);
// Color palettes with 70s prog/psych vibes
var palettes = [
{
name: 'Sunburst',
a: '#ff9a00',
b: '#ff005c',
c: '#7b5cff',
d: '#00f0ff'
},
{
name: 'Pastoral',
a: '#ffb347',
b: '#ff6a88',
c: '#48c6ef',
d: '#3fffa8'
},
{
name: 'Cosmic',
a: '#ff4b1f',
b: '#1fddff',
c: '#7f00ff',
d: '#ffe000'
},
{
name: 'Acid',
a: '#fdfc47',
b: '#24fe41',
c: '#ff00aa',
d: '#ff5f6d'
}
];
function applyPalette(p) {
var root = document.documentElement;
root.style.setProperty('--psy70-color-a', p.a);
root.style.setProperty('--psy70-color-b', p.b);
root.style.setProperty('--psy70-color-c', p.c);
root.style.setProperty('--psy70-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); // ~70 seconds per switch
// Toggle button
var $btn = $('<button>', {
id: 'psy70-toggle',
text: 'Psy Frame: On'
});
function updateButton() {
if (body.classList.contains('psy70-off')) {
$btn.text('Psy Frame: Off');
} else {
$btn.text('Psy Frame: On');
}
}
$btn.on('click', function () {
body.classList.toggle('psy70-off');
updateButton();
});
$('body').append($btn);
updateButton();
});