Oracle JET in PT 8.55 - CSK_FL_BOOTSTRAP_JS
by Sasank Vemana
JavaScript
/*** Function Credit: Jim Marion
* Resource: http://jjmpsj.blogspot.com/2015/02/using-requirejs-to-manage-dependencies.html
* Build a URL based on the current component's URL
* @param {type} scriptId* @returns {String} derived URL for JavaScript
*/
var getScriptUrl = function (scriptId) {
var mainUrl = window.location.href;
var parts = mainUrl.match(/ps[pc]\/(.+?)(?:_\d)*?\/(.+?)\/(.+?)\/[chs]\//);
return window.location.origin + "/psc/" + parts[1] + "/" + parts[2] + "/" + parts[3] + "/s/WEBLIB_PTBR.ISCRIPT1.FieldFormula.IScript_GET_JS?ID=" + scriptId;
};
/*** Improvised from delivered JavaScript: PT_CHART_LOAD - loadScript Function
* Load JavaScript to Document* @param {type} sURL
* @param {type} sId
* @param {type} callback
*/
var cskLoadJS = function(sURL, sId, callback) {
var oElement= document.getElementsByTagName('head')[0];
var oScript= document.createElement('script');
oScript.type= 'text/javascript';
oScript.language='JavaScript';
//% console.log('cskLoadJS: ' + sId);
if(oScript.readyState) {
oScript.onreadystatechange=function() //for IE
{
if(oScript.readyState=="loaded"||oScript.readyState=="complete")
{
oScript.onreadystatechange=null;
}
}
} else {
oScript.onload=function()
{
//% console.log(' ' + sId + 'onload callback: ' + callback);
if (typeof(callback) === 'function')
{
callback(callback);
}
};
}
oScript.src= sURL;
oScript.id= sId;
oElement.appendChild(oScript);
};
/* Inject custom javascripts */
var cskInjectJS = function(){
/*
* Inject custom JS using getScriptUrl and cskLoadJS functions
* cskLoadJS(getScriptUrl('CSK_FL_TEST_JS'), 'CSK_FL_TEST_JS', callbackFunction);
* cskLoadJS(getScriptUrl('CSK_FL_TEST_JS'), 'CSK_FL_TEST_JS', 'sCntr');
*/
//% console.log('cskInjectJS');
cskLoadJS(getScriptUrl('CSK_FL_DBNAME_JS'), 'CSK_FL_DBNAME_JS', 'sCntr');
};
/* Main Function that...