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. */
 
 
     // Set to false if opt-in required
 
     // Set to false if opt-in required
 
     var trackByDefault = true;
 
     var trackByDefault = true;
  
 
     function acEnableTracking() {
 
     function acEnableTracking() {
         var expiration = new Date(new Date().getTime() + 1000 60 60 24 30);
+
         var expiration = new Date(new Date().getTime() + 1000*60*60*24*30);
 
         document.cookie = "ac_enable_tracking=1; expires= " + expiration + "; path=/";
 
         document.cookie = "ac_enable_tracking=1; expires= " + expiration + "; path=/";
 
         acTrackVisit();
 
         acTrackVisit();

Revision as of 05:29, 24 August 2018

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