Skip to content

Instantly share code, notes, and snippets.

@boertel
Created July 27, 2012 18:41
Show Gist options
  • Save boertel/3189702 to your computer and use it in GitHub Desktop.
Save boertel/3189702 to your computer and use it in GitHub Desktop.
Invisible mode for specific pages
(function() {
var pages = [];
var noLoad = false;
for (var i = 0; i < pages.length; i++) {
if (document.location.pathname === pages[i]) {
noLoad = true;
break;
}
}
if (noLoad) {
_punchtab_settings.display = "invisible";
}
var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;
pt.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + dde.env.settings.domain + ':8000/static/js/' + dde.env.settings.ptdotjs;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pt, s);
})();
@arthurio
Copy link

Alternative for url patterns:

/* for IE */
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(obj, start) {
         for (var i = (start || 0), j = this.length; i < j; i++) {
             if (this[i] === obj) { return i; }
         }
         return -1;
    }
}
(function() {
    var pages = ['/donate/', '/campaigns/'];
    var noLoad = false;

    for (var i = 0; i < pages.length; i++) {
        if (document.location.pathname.indexOf(pages[i]) === 0) {
            noLoad = true;
            break;
        }
    }
    if (noLoad) {
        _punchtab_settings.display = "invisible";
    }
    var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;
    pt.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.punchtab.com/js/pt.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pt, s);
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment