Skip to content

Instantly share code, notes, and snippets.

@cmourizard
Created April 1, 2013 08:41
Show Gist options
  • Save cmourizard/5283857 to your computer and use it in GitHub Desktop.
Save cmourizard/5283857 to your computer and use it in GitHub Desktop.
Getting main module for a SugarCRM page
if ( typeof(MyCustomJs) == 'undefined' ) MyCustomJs = {};
if ( typeof(MyCustomJs.Helper) == 'undefined' ) MyCustomJs.Helper = {};
MyCustomJs.Helper.getCurrentModuleName = function() {
if (typeof module_sugar_grp1 != "undefined") {
return module_sugar_grp1;
}
var url = YAHOO.util.History.getBookmarkedState('ajaxUILoc');
if (url == null) {
url = wwindows.location;
}
if (url != null) {
var mRegex = /module=([^&#]*)/.exec(url);
var module = mRegex ? mRegex[1] : false;
if (module != false) {
return module;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment