Skip to content

Instantly share code, notes, and snippets.

@bwiggs
Last active August 29, 2015 13:57
Show Gist options
  • Save bwiggs/9651284 to your computer and use it in GitHub Desktop.
Save bwiggs/9651284 to your computer and use it in GitHub Desktop.
before and after global namespace pollution cleanup
function findURLValue(q) {
var p = document.location.search.substring(1).split('&'),
i = 0;
for (; i < p.length; i = i + 1) {
if (p[i].split('=')[0] == q) return p[i].split('=')[1];
}
return '';
}
var Application = (function () {
var userrole = '#listDeleteAt(client.role_list, listFind(client.role_list, "MYAPP", ","), ",")#';
var Application = {
versionNumber: '#application.applicationVersionNumber#',
environment : '#application.environment#',
host : '#application.host#'
};
var User = {
type: '#session.usertype#',
name: '#client.username#',
role: userrole,
isRequester: (userrole.search(/REQR/) != -1) ? true : false,
isApprover: (userrole.search(/APPR/) != -1) ? true : false,
isFacRequester: (userrole.search(/FAC/) != -1) ? true : false
};
var ViewState = {
widget_id: findURLValue('wid'),
request_id: findURLValue('rid'),
facilityID: findURLValue('fid'),
URLPrefix: '#viewstate.getvalue("myself")#'
};
var Messages = {
StandardError: 'A standard error message.',
StandardSuccess: 'A standard success message.'
};
return {
getApplication: function () {
return Application;
},
getUser: function () {
return User;
},
getMessages: function () {
return Messages;
},
getViewState: function () {
return ViewState;
}
}
})();
function findURLValue(q){
var p=document.location.search.substring(1).split('&'),i=0;
for(;i<p.length;i=i+1){ if(p[i].split('=')[0]==q)return p[i].split('=')[1]; }
return '';
}
var userrole = '#listDeleteAt(client.role_list, listFind(client.role_list, "MYAPP", ","), ",")#';
var Messages = {
StandardError : 'A standard error message.',
StandardSuccess : 'A standard success message.'
};
var Application = {
versionNumber: '#application.applicationVersionNumber#',
environment: '#application.environment#',
host: '#application.host#'
};
var User = {
type: '#session.usertype#',
name: '#client.username#',
role: userrole,
isRequester: (userrole.search(/REQR/) != -1) ? true : false,
isApprover: (userrole.search(/APPR/) != -1) ? true : false,
isFacRequester: (userrole.search(/FAC/) != -1) ? true : false
};
var ViewState = {
widget_id    : findURLValue('wid'),
request_id   : findURLValue('rid'),
facilityID   : findURLValue('fid'),
URLPrefix    : '#viewstate.getvalue("myself")#'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment