MediaWiki:Common.js

From Screamer Wiki
Revision as of 17:51, 13 June 2015 by imported>UncoveredAgent200 (Created page with "→‎We are to warn our viewers about any possible shocks that may come from this Wiki.: function getCookie(c_name) { var c_value = ' ' + document.cookie; var c_start ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* We are to warn our viewers about any possible shocks that may come from this Wiki. */
function getCookie(c_name) {
    var c_value = ' ' + document.cookie;
    var c_start = c_value.indexOf(' ' + c_name + '=');
    if (c_start == -1) {
        c_value = null;
    } else {
        c_start = c_value.indexOf('=', c_start) + 1;
        var c_end = c_value.indexOf(';', c_start);
        if (c_end == -1) {
            c_end = c_value.length;
        }
        c_value = unescape(c_value.substring(c_start, c_end));
    }
    return c_value;
}

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = 'expires=' + d.toUTCString();
    document.cookie = cname + '=' + cvalue + '; ' + expires;
}
/* In no way are we using this to steal accounts. We are using this for per-PC verification. */

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.';
var cookiename = 'DiscretionVerification';
if (getCookie(cookiename) === null) {
    var WikiaPage = document.getElementById('WikiaMainContent');
    var MonobookPage = document.getElementById('bodyContent');
    
    if (WikiaPage !== null) {
        WikiaPage.innerHTML = '';
        var Header = document.createElement('h2');
        Header.innerHTML = 'Before you visit this wiki...';
        WikiaPage.appendChild(Header);
        var Content = document.createElement('div');
        Content.innerHTML = msg;
        WikiaPage.appendChild(Content);
        var AgreeButton = document.createElement('button');
        AgreeButton.className = 'wikia-button';
        AgreeButton.innerHTML = 'Agree';
        WikiaPage.appendChild(AgreeButton);
        var DisagreeButton = document.createElement('button');
        DisagreeButton.className = 'wikia-menu-button secondary';
        DisagreeButton.innerHTML = 'Disagree';
        WikiaPage.appendChild(DisagreeButton);
        AgreeButton.onclick = function() {
            setCookie(cookiename, 'true', 365);
            location.reload();
        };
        DisagreeButton.onclick = function() {
            window.location.href = 'http://wikia.com';
        };
    }
    
    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';
        };
    } 
}