-
-
Save dfparker2002/6189394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------ | |
// Toggle 'wcmmode=disabled' | |
(function(){ | |
var WCMMODE_DISABLED = 'wcmmode=disabled'; | |
// Creates the path by combining the path and query string parameters | |
var createURL = function(path, query_string, hash) { | |
var url = path; | |
var qs = []; | |
for (var i=0;i<query_string.length;i++) { | |
if (query_string[i] != '') | |
qs.push(query_string[i]); | |
} | |
if(qs.length != 0 && !(qs.length == 1 && qs[0] == '')) { | |
url += '?' + qs.join('&'); | |
} | |
url += hash; | |
return url; | |
}; | |
var hash = window.location.hash; | |
var parameters = window.location.search.substring(1).split('&'); | |
var path = window.location.pathname; | |
if(parameters.indexOf(WCMMODE_DISABLED) != -1) { // present, | |
parameters.pop(WCMMODE_DISABLED); // so remove it | |
} else { | |
parameters.push(WCMMODE_DISABLED); | |
} | |
var url = createURL(path, parameters, hash); | |
window.location = url; | |
}()); | |
// Bookmarklet | |
javascript:(function(){var d="wcmmode=disabled";var a=function(m,k,l){var h=m;var g=[];for(var j=0;j<k.length;j++){if(k[j]!=""){g.push(k[j])}}if(g.length!=0&&!(g.length==1&&g[0]=="")){h+="?"+g.join("&")}h+=l;return h};var f=window.location.hash;var c=window.location.search.substring(1).split("&");console.log(c);var e=window.location.pathname;if(c.indexOf(d)!=-1){c.pop(d)}else{c.push(d)}var b=a(e,c,f);console.log(b);window.location=b}()); | |
// ------------------------------------ | |
// Toggle 'cf#/' | |
(function(){ | |
var CONTENT_FINDER = 'cf#/'; | |
var href = window.location.href; | |
var url = ""; | |
if(href.indexOf(CONTENT_FINDER) != -1) { | |
url = href.replace(CONTENT_FINDER,''); // remove it | |
} else { | |
url = href.replace('content/', CONTENT_FINDER + 'content/'); // add it | |
} | |
window.location = url; | |
}()); | |
// Bookmarklet | |
javascript:(function(){var e="cf#/";var t=window.location.href;var n="";if(t.indexOf(e)!=-1){n=t.replace(e,"")}else{n=t.replace("content/",e+"content/")}window.location=n})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment