Tuesday, September 01, 2009

Monday, August 31, 2009

JavaScript complement of PeopleCode Global Vars

While writing some JavaScript for my new PeopleTools book, I came up with a JavaScript complement to some of the common PeopleCode global variables. Here is the code:

jjmpsj.sysVars = (function(url) {
var matches = url.match(
/ps[pc]\/(.+?)(?:_\d)*?\/(.+?)\/(.+?)\/c\/(.+?)\.(.+?)\.(.+?)$/);
return {
getSite: function() {
return matches[1];
},
getPortal: function() {
return matches[2];
},
getNode: function() {
return matches[3];
},
getMenu: function() {
return matches[4];
},
getComponent: function() {
return matches[5];
},
getMarket: function() {
return matches[6];
}
}
})(window.location.pathname);

Now, wouldn't you just love to know how I intend to use this code... to learn that you will have to wait for the book.