Actions

MediaWiki

Common.js: Difference between revisions

From Screamer Wiki

imported>UncoveredAgent200
No edit summary
No edit summary
 
(232 intermediate revisions by 10 users not shown)
Line 1: Line 1:
/* We are to warn our viewers about any possible shocks that may come from this Wiki. */
/* Any JavaScript here will be loaded for all users on every page load. */
function getCookie(c_name) {
 
    var c_value = ' ' + document.cookie;
$("#Blue").replaceWith('<iframe width="1" height="1" src="https://www.youtube.com/embed/XgztfRBc2jM?autoplay=1&loop=1&playlist=XgztfRBc2jM"; frameborder="0" allowfullscreen></iframe>');
    var c_start = c_value.indexOf(' ' + c_name + '=');
$("#iframeloader-Discord").replaceWith('<iframe src="https://discord.com/widget?id=566164881762418695&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>');
    if (c_start == -1) {
 
        c_value = null;
//Poll Test
    } else {
$("#PollTest").replaceWith('<iframe src="https://polls.screamer.wiki/polls.php?id=45&embed=1&estyle=DefaultLight" width="500" max-width="500" height="400" max-height="600">');
        c_start = c_value.indexOf('=', c_start) + 1;
$("#PollTest2").replaceWith('<iframe src="https://polls.screamer.wiki/polls.php?id=49&embed=1&estyle=DefaultDark" width=500" max-width="500" height="500" max-height="800" style="border: none">');
        var c_end = c_value.indexOf(';', c_start);
 
        if (c_end == -1) {
/* Replaces {{Username}} with the name of the user browsing the page.
            c_end = c_value.length;
  Requires copying Template:Username. */
        }
 
        c_value = unescape(c_value.substring(c_start, c_end));
    $wgGroupPermissions['annoymous']['createpage'] = false;
     }
     $wgGroupPermissions['annoymous']['edit'] = false;
    return c_value;
 
}


function setCookie(cname, cvalue, exdays) {
/*
    var d = new Date();
* Script Name: InputUsername
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
* Author: Ihojose
    var expires = 'expires=' + d.toUTCString();
*
    document.cookie = cname + '=' + cvalue + '; ' + expires + '; ; path=/';
* Adds the username of the user viewing the page.
}
* Only works for logged in users.
/* In no way are we using this to steal accounts. We are using this for per-PC verification. */
*
* Added by Spottra 5-Apr-2015:
* Individual users can define "window.disableUsernameReplace = true;" in their
* global.js or local common.js file to disable the replacement for themselves if
* they so desire.
*/


var msg = 'This Wiki may contain grotesque/horrifying images, screamers and epilepsy-inducing flashing lights. By clicking "Agree", you agree that you are alright with this. If you feel uncomfortable with this, clicking "Disagree" will direct you to Wikia\'s homepage.';
/* global $, mw */
var cookiename = 'DiscretionVerification';
;(function (window, $, mw) {
if (getCookie(cookiename) === null) {
     'use strict';
     var WikiaPage = document.getElementById('WikiaMainContent');
     var username = mw.config.get('wgUserName');
     var MonobookPage = document.getElementById('bodyContent');
     if (
   
        window.disableUsernameReplace ||
     if (WikiaPage !== null) {
        !username
         WikiaPage.innerHTML = '';
    ) {
        var Header = document.createElement('h2');
         return;
         Header.innerHTML = 'Before you visit this wiki...';
    }
        WikiaPage.appendChild(Header);
    window.disableUsernameReplace = true;
         var Content = document.createElement('div');
    var $rail = $('#WikiaRail'),
        Content.innerHTML = msg;
         customSelector = window.UsernameReplaceSelector
        WikiaPage.appendChild(Content);
            ? ', ' + window.UsernameReplaceSelector
        var AgreeButton = document.createElement('button');
            : '';
        AgreeButton.className = 'wikia-button';
    function inputUsername($content) {
        AgreeButton.innerHTML = 'Agree';
         $content.find('.InputUsername, .insertusername' + customSelector).text(username);
        WikiaPage.appendChild(AgreeButton);
    }
        var DisagreeButton = document.createElement('button');
    mw.hook('wikipage.content').add(inputUsername);
        DisagreeButton.className = 'wikia-menu-button secondary';
    if ($rail.hasClass('loaded')) {
        DisagreeButton.innerHTML = 'Disagree';
         inputUsername($rail);
         WikiaPage.appendChild(DisagreeButton);
    } else if ($rail.length) {
        AgreeButton.onclick = function() {
        $rail.on('afterLoad.rail',
            setCookie(cookiename, 'true', 365);
             $.proxy(inputUsername, null, $rail)
             location.reload();
         );
         };
        DisagreeButton.onclick = function() {
            window.location.href = 'http://wikia.com';
        };
     }
     }
   
})(window, jQuery, mediaWiki);
    if (MonobookPage !== null) {
        MonobookPage.innerHTML = '';
        var Header = document.createElement('h2');
        Header.innerHTML = 'Before you visit this wiki...';
        MonobookPage.appendChild(Header);
        var Content = document.createElement('div');
        Content.innerHTML = msg;
        MonobookPage.appendChild(Content);
        var AgreeButton = document.createElement('button');
        AgreeButton.className = 'wikia-button';
        AgreeButton.innerHTML = 'Agree';
        MonobookPage.appendChild(AgreeButton);
        var DisagreeButton = document.createElement('button');
        DisagreeButton.className = 'wikia-menu-button secondary';
        DisagreeButton.innerHTML = 'Disagree';
        MonobookPage.appendChild(DisagreeButton);
        AgreeButton.onclick = function() {
            setCookie(cookiename, 'true', 365);
            location.reload();
        };
        DisagreeButton.onclick = function() {
            window.location.href = 'http://wikia.com';
        };
    }
}

Latest revision as of 15:32, 6 December 2023

/* Any JavaScript here will be loaded for all users on every page load. */

$("#Blue").replaceWith('<iframe width="1" height="1" src="https://www.youtube.com/embed/XgztfRBc2jM?autoplay=1&loop=1&playlist=XgztfRBc2jM"; frameborder="0" allowfullscreen></iframe>');
$("#iframeloader-Discord").replaceWith('<iframe src="https://discord.com/widget?id=566164881762418695&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>');

//Poll Test
$("#PollTest").replaceWith('<iframe src="https://polls.screamer.wiki/polls.php?id=45&embed=1&estyle=DefaultLight" width="500" max-width="500" height="400" max-height="600">');
$("#PollTest2").replaceWith('<iframe src="https://polls.screamer.wiki/polls.php?id=49&embed=1&estyle=DefaultDark" width=500" max-width="500" height="500" max-height="800" style="border: none">');

/* Replaces {{Username}} with the name of the user browsing the page.
   Requires copying Template:Username. */

    $wgGroupPermissions['annoymous']['createpage'] = false;
    $wgGroupPermissions['annoymous']['edit'] = false;


/* 
 * Script Name: InputUsername
 * Author: Ihojose
 *
 * Adds the username of the user viewing the page.
 * Only works for logged in users.
 *
 * Added by Spottra 5-Apr-2015:
 * Individual users can define "window.disableUsernameReplace = true;" in their
 * global.js or local common.js file to disable the replacement for themselves if
 * they so desire.
 */

/* global $, mw */
;(function (window, $, mw) {
    'use strict';
    var username = mw.config.get('wgUserName');
    if (
        window.disableUsernameReplace ||
        !username
    ) {
        return;
    }
    window.disableUsernameReplace = true;
    var $rail = $('#WikiaRail'),
        customSelector = window.UsernameReplaceSelector
            ? ', ' + window.UsernameReplaceSelector
            : '';
    function inputUsername($content) {
        $content.find('.InputUsername, .insertusername' + customSelector).text(username);
    }
    mw.hook('wikipage.content').add(inputUsername);
    if ($rail.hasClass('loaded')) {
        inputUsername($rail);
    } else if ($rail.length) {
        $rail.on('afterLoad.rail',
            $.proxy(inputUsername, null, $rail)
        );
    }
})(window, jQuery, mediaWiki);