MediaWiki:Common.js: Difference between revisions

From PsychoactiveWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 28: Line 28:
//aesthetic
//aesthetic


/*********************************
/* 70s Prog / Psych dynamic background
* 70s Prog / Psych Sunburst BG
  * Drop into MediaWiki:Common.js
  *********************************/
*/
mw.loader.using('jquery', function () {
    var body = document.body;


:root {
    // Turn it on
     --prog70s-bg: #050009;
     body.classList.add('prog70s-bg');
    --prog70s-color-a: #ff9a00;
    --prog70s-color-b: #ff005c;
    --prog70s-color-c: #7b5cff;
    --prog70s-color-d: #00f0ff;
}


/* Turned on from Common.js */
    // Add grain overlay element
body.prog70s-bg {
     var grain = document.createElement('div');
     background: var(--prog70s-bg);
     grain.id = 'prog70s-grain';
     color: #f5f5f5;
     body.appendChild(grain);
     overflow-x: hidden;
}


/* Content card styling so background peeks around edges */
    // Palettes inspired by 70s prog/psych vibes
body.prog70s-bg #content,
    var palettes = [
body.prog70s-bg .mw-body {
        {
    background: rgba(6, 3, 22, 0.92);
            // Warm orange / magenta – generic psych poster
    border-radius: 14px;
            name: 'Sunburst',
    box-shadow:
            a: '#ff9a00',
        0 0 0 1px rgba(255, 255, 255, 0.03),
            b: '#ff005c',
         0 30px 80px rgba(0, 0, 0, 0.9);
            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'
        }
    ];


/* Keep header areas clean-ish */
     function applyPalette(p) {
body.prog70s-bg #mw-page-base,
         var root = document.documentElement;
body.prog70s-bg #mw-head-base {
         root.style.setProperty('--prog70s-color-a', p.a);
    background: transparent;
        root.style.setProperty('--prog70s-color-b', p.b);
}
        root.style.setProperty('--prog70s-color-c', p.c);
 
        root.style.setProperty('--prog70s-color-d', p.d);
/* Rotating conic sunburst – big 70s record/poster vibe */
    }
body.prog70s-bg::before {
    content: "";
    position: fixed;
    inset: -40vh;
    z-index: -2;
    pointer-events: none;
 
     background:
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.9), transparent 60%),
         conic-gradient(
            from 0deg,
            var(--prog70s-color-a) 0deg,
            var(--prog70s-color-b) 45deg,
            var(--prog70s-color-c) 90deg,
            var(--prog70s-color-d) 135deg,
            var(--prog70s-color-a) 180deg,
            var(--prog70s-color-b) 225deg,
            var(--prog70s-color-c) 270deg,
            var(--prog70s-color-d) 315deg,
            var(--prog70s-color-a) 360deg
        );
 
    filter: blur(1px) saturate(1.3);
    mix-blend-mode: screen;
    animation: prog70s-spin 80s linear infinite;
    opacity: 0.85;
}
 
/* Horizontal psychedelic bands that drift + shimmer */
body.prog70s-bg::after {
    content: "";
    position: fixed;
    inset: -20vh;
    z-index: -1;
    pointer-events: none;
 
    background-image:
         linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.85),
            rgba(0, 0, 0, 0.4),
            rgba(0, 0, 0, 0.85)
        ),
        repeating-linear-gradient(
            0deg,
            var(--prog70s-color-a) 0,
            var(--prog70s-color-a) 15px,
            var(--prog70s-color-b) 15px,
            var(--prog70s-color-b) 30px,
            var(--prog70s-color-c) 30px,
            var(--prog70s-color-c) 45px,
            var(--prog70s-color-d) 45px,
            var(--prog70s-color-d) 60px
        );


     background-size: 100% 100%, 100% 260%;
     // Start with a random palette
     mix-blend-mode: screen;
     var index = Math.floor(Math.random() * palettes.length);
     animation:
     applyPalette(palettes[index]);
        prog70s-bands-shift 55s ease-in-out infinite alternate,
        prog70s-bands-wobble 18s ease-in-out infinite alternate;
    opacity: 0.9;
}


/* “Off” state when user toggles it */
    // Slowly rotate palettes
body.prog70s-bg.prog70s-off::before,
    window.setInterval(function () {
body.prog70s-bg.prog70s-off::after {
        index = (index + 1) % palettes.length;
    opacity: 0;
        applyPalette(palettes[index]);
     transition: opacity 0.6s ease-out;
     }, 70000); // 70s seconds per change, obviously
}


/* Slight color shift when off to keep the page readable */
    // Toggle button
body.prog70s-bg.prog70s-off {
    var $btn = $('<button>', {
    background: #050009;
        id: 'prog70s-toggle',
}
        text: 'Prog 70s: On'
    });


/* Rotating record / sunburst */
    function updateButton() {
@keyframes prog70s-spin {
        if (body.classList.contains('prog70s-off')) {
    0% {
            $btn.text('Prog 70s: Off');
        transform: rotate(0deg) scale(1.05);
        } else {
            $btn.text('Prog 70s: On');
        }
     }
     }
    50% {
        transform: rotate(180deg) scale(1.08);
    }
    100% {
        transform: rotate(360deg) scale(1.05);
    }
}
/* Bands sliding up and down */
@keyframes prog70s-bands-shift {
    0% {
        background-position: 0 0, 0 0;
    }
    100% {
        background-position: 0 0, 0 -200%;
    }
}
/* Gentle wobble like a warped LP */
@keyframes prog70s-bands-wobble {
    0% {
        transform: translate3d(0, 0, 0) skewY(0deg);
        filter: hue-rotate(0deg);
    }
    50% {
        transform: translate3d(0, -1.5%, 0) skewY(1.2deg);
        filter: hue-rotate(25deg);
    }
    100% {
        transform: translate3d(0, 1.5%, 0) skewY(-1.2deg);
        filter: hue-rotate(50deg);
    }
}
/* Optional: grain overlay for extra analog feel */
body.prog70s-bg #prog70s-grain {
    pointer-events: none;
    position: fixed;
    inset: -20vh;
    z-index: -1;
    opacity: 0.12;
    mix-blend-mode: soft-light;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");
    background-size: 160px 160px;
}
/* Toggle button */
#prog70s-toggle {
    position: fixed;
    right: 1.4rem;
    bottom: 1.4rem;
    z-index: 2000;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    background: radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.85));
    color: #ffe8ff;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);


     box-shadow:
     $btn.on('click', function () {
        0 0 0 1px rgba(0, 0, 0, 0.9),
         body.classList.toggle('prog70s-off');
         0 0 25px rgba(255, 0, 150, 0.4);
        updateButton();
    backdrop-filter: blur(5px);
     });
     font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}


#prog70s-toggle:hover {
     $('body').append($btn);
     transform: translateY(-1px);
     updateButton();
     box-shadow:
});
        0 0 0 1px rgba(0, 0, 0, 0.9),
        0 0 35px rgba(0, 240, 255, 0.6);
}

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();
});