Difference between revisions of "MediaWiki:Common.js"

From SchemeServe Help
Jump to: navigation, search
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
console.log("test");
+
    // Set to false if opt-in required
 +
    var trackByDefault = true;
 +
 
 +
    function acEnableTracking() {
 +
        var expiration = new Date(new Date().getTime() + 1000 60 60 24 30);
 +
        document.cookie = "ac_enable_tracking=1; expires= " + expiration + "; path=/";
 +
        acTrackVisit();
 +
    }
 +
 
 +
    function acTrackVisit() {
 +
        var trackcmp_email = '';
 +
        var trackcmp = document.createElement("script");
 +
        trackcmp.async = true;
 +
        trackcmp.type = 'text/javascript';
 +
        trackcmp.src = '//trackcmp.net/visit?actid=1000065698&e=' + encodeURIComponent(trackcmp_email) + '&r=' + encodeURIComponent(document.referrer) + '&u=' + encodeURIComponent(window.location.href);
 +
        var trackcmp_s = document.getElementsByTagName("script");
 +
        if (trackcmp_s.length) {
 +
            trackcmp_s[0].parentNode.appendChild(trackcmp);
 +
        } else {
 +
            var trackcmp_h = document.getElementsByTagName("head");
 +
            trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
 +
        }
 +
    }
 +
 
 +
    if (trackByDefault || /(^|; )ac_enable_tracking=([^;]+)/.test(document.cookie)) {
 +
        acEnableTracking();
 +
    }

Revision as of 05:27, 24 August 2018

/* Any JavaScript here will be loaded for all users on every page load. */
    // Set to false if opt-in required
    var trackByDefault = true;

    function acEnableTracking() {
        var expiration = new Date(new Date().getTime() + 1000 60 60 24 30);
        document.cookie = "ac_enable_tracking=1; expires= " + expiration + "; path=/";
        acTrackVisit();
    }

    function acTrackVisit() {
        var trackcmp_email = '';
        var trackcmp = document.createElement("script");
        trackcmp.async = true;
        trackcmp.type = 'text/javascript';
        trackcmp.src = '//trackcmp.net/visit?actid=1000065698&e=' + encodeURIComponent(trackcmp_email) + '&r=' + encodeURIComponent(document.referrer) + '&u=' + encodeURIComponent(window.location.href);
        var trackcmp_s = document.getElementsByTagName("script");
        if (trackcmp_s.length) {
            trackcmp_s[0].parentNode.appendChild(trackcmp);
        } else {
            var trackcmp_h = document.getElementsByTagName("head");
            trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
        }
    }

    if (trackByDefault || /(^|; )ac_enable_tracking=([^;]+)/.test(document.cookie)) {
        acEnableTracking();
    }