var engine = { /* ************************************************************************** */ // application global functions specific to questionnaire /* ************************************************************************** */ buildQPage:function(z) { // here we build the actual page // the page is build in 2 rounds.... // round 1 sets the divs in the content page for example "div_objecttype_pageid_pageobjectid" // round 2 goes thru the object list again and fills the divs with the actual object by using the loadPageObject function // if (engine.processRPCServerResponce(z)) { // set all previous objects to invisible engine.cleanupObjectArray(); //debugger; var objPageObjects=z.oResult; var content=''; var qid=1; var div=''; for (objPageObject in objPageObjects) { if (engine.QMode=='DESIGN') { div = engine.draw_div(objPageObjects[objPageObject],1,'YES'); } else { div = engine.draw_div(objPageObjects[objPageObject],0,'YES'); } content += div; div=''; } // add the div list to the content page dojo.byId(engine.qdiv).innerHTML = content; //reiterate the object list and call the loadPageObject function for each object. var arr=new Array(); var count=0; for (objPageObject in objPageObjects) { // get object parameters obj = objPageObjects[objPageObject]; js_name = obj.js_name; ui_name = obj.ui_name; contentpaneId = 'div_' + obj['object_type_name'] + '_' + obj['page_id'] + '_' + obj['group_id'] + "_" + obj['page_object_id']; contentpaneId=contentpaneId.replace(/ /g,'_'); //alert(contentpaneId); name = obj['object_type_name'] + '_' + obj['page_id'] + '_' + obj['group_id'] + "_" + obj['page_object_id']; // convert spaces in the name to underscores (the name is used as an object identifier so spaces break that mechanism) name=name.replace(/ /g,'_'); // load and display the module engine.getQPageObject( engine.sLangCode, ui_name, js_name, name, contentpaneId, obj ); //debugger; } } else { dojo.byId(engine.qdiv).innerHTML=''; } }, cleanupObjectArray:function() { bCleanUp = false; //debugger; for (ex in engine.aLoadedComponents) { if (engine.aLoadedComponents[ex].bIsQObject==true && engine.aLoadedComponents[ex]!=null) { if (engine.aLoadedComponents[ex].bIsVisible==true) { engine.aLoadedComponents[ex].detachEvents(); engine.aLoadedComponents[ex]=null bCleanUp = true; } } } //debugger; if (bCleanUp) { var arrObjects=new Array(); for (ex in engine.aLoadedComponents) { if (engine.aLoadedComponents[ex]!=null) { arrObjects[ex]=engine.aLoadedComponents[ex]; } } engine.aLoadedComponents=null; delete engine.aLoadedComponents; //CollectGarbage(); engine.aLoadedComponents=new Array(); for (ex in arrObjects) { engine.aLoadedComponents[ex]=arrObjects[ex]; } arrObjects=null; } }, draw_div:function (obj,border,enable_events) { _name = 'div_' + obj['object_type_name'] + '_' + obj['page_id'] + '_' + obj['group_id'] + "_" + obj['page_object_id']; var strTop=''; var strLeft=''; var strHeight=''; var strWidth=''; var strBorder=''; var strEvent=''; _name=_name.replace(/ /g,'_'); if ( enable_events != undefined && enable_events != '' ) { qid = obj['questionnaire_id']; pid = obj['page_id']; gid = obj['group_id']; poid = obj['page_object_id']; strEvent="ondblclick='dojo.publish(\"event_object_selected\", [\""+qid+"\", \""+pid+"\", \""+gid+"\", \""+poid+"\"]); ' "; } strBorder = ''; if ( border > 0 ) { strBorder = 'border:5px solid #000000;'; } if (obj.Y.property_value && obj.Y.property_value!=null) { if ( obj.Y.property_value > 0 ) { _top = obj.Y.property_value; strTop="top:" + _top + "px;"; } } else { alert('Y propertie in database zetten voor '+obj['object_type_name']); } if (obj.X.property_value && obj.X.property_value!=null) { if ( obj.X.property_value > 0 ) { _left = obj.X.property_value; strLeft="left:" + obj.X.property_value + "px;"; } } else { alert('X propertie in database zetten voor '+obj['object_type_name']); } if (obj.object_type_name=='Text') { if (obj.Height) { if ( obj.Height.property_value > 0 && obj.Height.property_value != null ) { _height = obj.Height.property_value; strHeight = "height:" + obj.Height.property_value + "px;"; } } if (obj.Width) { if ( obj.Width.property_value > 0 && obj.Width.property_value != null ) { _width = obj.Width.property_value; strWidth = "width:" + obj.Width.property_value + "px;"; } } } tt=''; if (obj['Balloon text']) { if (obj['Balloon text'].property_value!='') { tt="
"; } } //var div = tt+"
"; strClass = ""; if (engine.QMode=='DESIGN' || engine.QMode=='PREVIEW') { strClass = "class='drag'"; } var div = tt+"
"; return div; }, setTableCellWidth: function(domid,width) { var colRadio = document.getElementsByName('tc_'+domid); for (var i = 0; i < colRadio.length; i++) { colRadio[i].width=width+'px'; colRadio[i].span='1px'; } }, getQPageObject:function( sLangCode, sUIID, sJSID, sObjectName, sContentPaneId, oInitVars ) { // sLangCode ==> 'eng', 'nld', ... // sUIID and sJSID ar names of sources // sContentPaneId ==> in which contentpane has the ui component to be put // sObjectName ==> the name we give to the initialized object in array aLoadedComponents // oInitVars ==> the object which we give to the js component before it is executed... var objCS={sUIID:sUIID, sJSID:sJSID, sLangCode:sLangCode, sObjectName:sObjectName, sContentPaneId:sContentPaneId, oInitVars:oInitVars }; //engine.aTempObjectInits.push(obj); engine.aTempObjectInits[sObjectName]=objCS; engine.requestUI( engine.sSession, engine.sCountryCode, sLangCode, sUIID, sObjectName); engine.requestJS( engine.sSession, engine.sCountryCode, sLangCode, sJSID, sObjectName); //only the request are done here, when the request actualy returns something, an event is fired to the initObject function which builds the pageobject }, initObject:function(sLangCode, sId, sObjectName) { try { //debugger; if (engine.sLastLoadedObject!=sObjectName) // both requestui and js fire this event, however, we dont want to execute this function twice...) { if (js=engine.aJSs[sId].js) { if (ui=engine.aUIs[sId].ui) { objInit=engine.aTempObjectInits[sObjectName]; if (ui!='EMPTY') { ui=dojo.string.substitute(ui,{__PAGEID_PAGEOBJECTID__:sObjectName,__OBJECTNAME__:sObjectName}); dojo.byId(objInit.sContentPaneId).innerHTML=ui; } if (js!='EMPTY') { js=dojo.string.substitute(js,{__CLASSNAME__:sObjectName,__OBJECTNAME__:sObjectName,__INIT__:"init('EMPTY')"}); eval(js); // copy created object to array eval("engine.aLoadedComponents[sObjectName]="+sObjectName) // delete roaming object eval("delete "+sObjectName); // get object properties objInit=engine.aTempObjectInits[sObjectName]; // assign the init object (object properties) to the now loaded (but not initialized) page object engine.aLoadedComponents[sObjectName].objInit = objInit.oInitVars; // set the current pageobject to visible...(js should realy check for itself...) engine.aLoadedComponents[sObjectName].bIsVisible=true; // initialize the page object engine.aLoadedComponents[sObjectName].execute(sObjectName); // set the last loaded object name (so this function wont be executed twice...) engine.sLastLoadedObject=sObjectName; } return true; } return false; } return false; } return true; } catch(e) { return false; } }, // these are set when a loadPage is called sSecurityZone:'public', sLangCode:'nld', sCountryCode:'nl', sPageId:'welcome', sComponentId:'welcome', sContentPaneId:'content', sSession:'No Session', sLastLoadedObject:'', rpc:false, bLogStat:false, bLogHistory:false, bMenu:false, name:'', user_type:null, // old stuf we will get rid of... aLoadedContents: new Array(), // contains initialized objects (evald js components) // old stuf we will get rid of... aLoadedComponents: new Array(), // contains initialized objects (evald js components) aUIs:new Array(), // ui part of object (once loaded these will not be removed aJSs:new Array(), // js object source straight from server uninitialized and un parsed. aTempObjectInits:new Array(), // contains the init objects for page objects to be initialized...(will be deleted when page object is created and initialized) aResources:new Array(), sessionvars: new Array(), qdiv:'content', // questionnaire starts in this div topics:new Array(), // event array to which one can be subscribed questionnaire_topics:new Array(), // event array specific to questionnaire QMode:'RUN', // possible values 'RUN' or 'DESIGN' qUESTIONNAIRE IS IN DESIGN MODE OR RUN MODE evaluatingNext:false, // when next button is clicked this is set to true (it prevents dubbelclick of next button) addResource:function(id,content) { engine.aResources[id.toLowerCase()]=content; }, resource:function(id) { if (engine.aResources[id.toLowerCase()]==undefined) { console.debug('RESOURCE: resource tag: ' + id.toLowerCase() + " reguested in language " + engine.sLangCode + " but tag is not available"); return 'UNDEFINED'; } return engine.aResources[id.toLowerCase()]; }, init:function() { // describe events to which one can subscribe engine.topics[0] = dojo.subscribe("LOGINCOMPLETEDSUCCESS", engine, "login_completed_success"); engine.topics[1] = dojo.subscribe("LOGINCOMPLETEDFAILURE", engine, "login_completed_failure"); engine.topics[2] = dojo.subscribe("LOGOFF", engine, "logoff"); engine.topics[3] = dojo.subscribe("INITIALLAYOUT", engine, "initial_layout"); engine.topics[4] = dojo.subscribe("DIRECTLINK", engine, "direct_link"); engine.topics[7] = dojo.subscribe("OPEN_INVITATION", engine, "open_invitation"); // these are fired when source are downloaded from the server... engine.topics[5] = dojo.subscribe("UILOADED", engine, "initObject"); engine.topics[6] = dojo.subscribe("JSLOADED", engine, "initObject"); engine.requestResourceFile(engine.sLangCode,'framework'); console.debug(engine.resource("INITIALIZED")); engine.rpc = new dojo.rpc.JsonService("smd/c2servicesapi.smd"); engine.rpc.iTestAPI(engine.sLangCode,"API").addCallback(engine.apiTest); engine.init_dialogs(); }, init_dialogs:function() { }, ajaxDlg_1:function(sDlgType,sTitel,sMessage,sBtnValue) { if (sDlgType=='MESSAGE') { dijit.byId("dlgMessage_1btn").title='Hoi'; dijit.byId("dlgMessage_1btn").show(); dojo.byId('dlgMessage_message').innerHTML=sMessage; dojo.byId('btnMessage_1btn').value=sBtnValue; dijit.byId("dlgMessage_1btn").title=sTitel; } }, apiTest:function(z) { if (z.bResult) { if (z.bMessage) { console.debug(engine.resource(z.sMessage)); } } else { if (z.bMessage) { console.debug(engine.resource(z.sMessage)); } } }, bootstrap: function() { engine.init(); pageref=window.location.hash; // alert(pageref) switch(pageref) { case 'OPEN_INVITATION': case '#OPEN_INVITATION': dojo.publish("OPEN_INVITATION"); break; case'#DIRECTLINK': case'DIRECTLINK': dojo.publish("DIRECTLINK"); break; default: dojo.publish("INITIALLAYOUT"); break; } }, loadPage:function( sSecurityZone, sLangCode, sComponentId, sPageId, sContentPaneId, bLogStat, bLogHistory ) { console.debug( "loadPage(" + sSecurityZone + ", " + sLangCode + ", " + sComponentId + ", " + sPageId + ", " + sContentPaneId + ", " + bLogStat + ", " + bLogHistory + " )"); if (bLogStat) { engine.logStat(sPageId); } engine.sSecurityZone=dojo.string.trim(sSecurityZone); engine.sLangCode=dojo.string.trim(sLangCode); engine.sPageId=dojo.string.trim(sPageId); engine.sComponentId=dojo.string.trim(sComponentId); engine.sContentPaneId=dojo.string.trim(sContentPaneId); engine.bLogStat=bLogStat; engine.bLogHistory=bLogHistory; if (sPageId.toUpperCase()=='EMPTY') { dojo.byId(sContentPaneId).innerHTML=''; } else { engine.requestUIComponent( engine.sSession, engine.sLangCode, engine.sSecurityZone, engine.sPageId, 'PAGE' ); dojo.byId( engine.sContentPaneId ).innerHTML= engine.getObjectContent( engine.sLangCode, engine.sPageId ) ; } engine.requestJSComponent( engine.sComponentId ); engine.aLoadedComponents[engine.sComponentId].execute(); }, loadModule:function( sSecurityZone, sLangCode, sComponentId, sPageId, sContentPaneId ) { console.debug("loadModule( " + sSecurityZone + ", " + sLangCode + ", " + sComponentId + ", " + sPageId + ", " + sContentPaneId + ")"); if (sContentPaneId.toUpperCase()!='EMPTY') { if (sPageId.toUpperCase()=='EMPTY') { dojo.byId(sContentPaneId).innerHTML=''; } else { engine.requestUIComponent( engine.sSession, sLangCode, sSecurityZone, sPageId, 'MODULE' ); dojo.byId(sContentPaneId).innerHTML=engine.getObjectContent( sLangCode, sPageId ); } } engine.requestJSComponent( sComponentId ); engine.aLoadedComponents[sComponentId].execute(); }, loadPageObject:function( sSecurityZone, sLangCode, sComponentId, sPageId, sContentPaneId, sName, oInitVars ) { // sSecurityZone ==> 'public','private' // sLangCode ==> 'eng', 'nld', ... // sComponentId ==> as in the js component which resides on the server // sPageId ==> as in the ui component which resides on the server // sContentPaneId ==> in which contentpane has the ui component to be put // sName ==> the name in which the js comonent is known in the framework (in case of multiple components of the same type) // oInitVars ==> the object which we give to the js component before it is executed... if (sContentPaneId.toUpperCase()!='EMPTY') { if (sPageId.toUpperCase()=='EMPTY') { dojo.byId(sContentPaneId).innerHTML=''; } else { sObjectId = oInitVars.page_id + '_' + oInitVars.group_id + '_' + oInitVars.page_object_id; engine.requestUIComponent( engine.sSession, sLangCode, sSecurityZone, sPageId, 'PAGEOBJECT', sObjectId ); dojo.byId(sContentPaneId).innerHTML=engine.getObjectContent( sLangCode, sObjectId ); } } engine.requestJSComponent( sComponentId, sName ); engine.aLoadedComponents[sName].objInit=oInitVars; engine.aLoadedComponents[sName].bIsVisible=true; engine.aLoadedComponents[sName].execute(); }, requestJSComponent:function(sComponentId, sName) { if (sName==undefined || sName=='' || sName==false) { console.debug("requestJSComponent( " + sComponentId + ")"); if (engine.aLoadedComponents[sComponentId]==undefined) { console.debug("requestJSComponent( ... ) ==> granted"); var kw = { url: "/_jsserver.php", handleAs: "text", sync:true, timeout: 5000, content: { ssComponentId:sComponentId }, load: function(response, ioArgs) { response=dojo.string.substitute(response,{__CLASSNAME__:sComponentId,__INIT__:"init('EMPTY')"}); //console.debug(response); eval(response); }, error: function(response, ioArgs) { alert("requestJSComponent(" + sComponentId + ") --> error with status: " + ioArgs.xhr.status + ", message:" + response.message); } }; x=dojo.xhrGet( kw ); } } else { console.debug("requestJSComponent( " + sName + ")"); if (engine.aLoadedComponents[sName]==undefined) { console.debug("requestJSComponent( ... ) ==> granted"); var kw = { url: "/_jsserver.php", handleAs: "text", sync:true, timeout: 5000, content: { ssComponentId:sComponentId }, load: function(response, ioArgs) { response=dojo.string.substitute(response,{__CLASSNAME__:sName,__INIT__:"init('EMPTY')"}); eval(response); }, error: function(response, ioArgs) { alert("requestJSComponent(" + sName + ") --> error with status: " + ioArgs.xhr.status + ", message:" + response.message); } }; x=dojo.xhrGet( kw ); } } }, requestUIComponent:function( sSession, sLangCode, sSecurityZone, sPageId, sPageType, sReplace) { console.debug("requestUIComponent( " + sSession + ", " + sLangCode + ", " + sSecurityZone + ", " + sPageId + ", " + sPageType + ")"); try { var bPageAvailable=false; if ( engine.aLoadedContents != undefined ) { for (x in engine.aLoadedContents) { if (sPageType!='PAGEOBJECT') { if (engine.aLoadedContents[x].sLangCode==sLangCode && engine.aLoadedContents[x].sPageId==sPageId) { bPageAvailable=true; } } else { if (engine.aLoadedContents[x].sLangCode==sLangCode && engine.aLoadedContents[x].sPageId==sReplace) { bPageAvailable=true; } } } } if (! bPageAvailable) { console.debug("requestUIComponent( ... ) ==> granted"); var kw = { url: "/_uiserver.php", handleAs: "text", sync:true, timeout: 5000, content: { ssSession:sSession, ssLangCode:sLangCode, ssSecurityZone:sSecurityZone, ssPageId:sPageId, ssPageType:sPageType }, load: function(data) { if ( sReplace != undefined && sReplace != false && sReplace != '' ) { data=dojo.string.substitute(data,{__PAGEID_PAGEOBJECTID__:sReplace}); } if (sPageType!='PAGEOBJECT') { var obj={ sPageId:sPageId, sLangCode:sLangCode, sContent:data, dtCreated:'', dtLastAccessed:''}; } else { var obj={ sPageId:sReplace, sLangCode:sLangCode, sContent:data, dtCreated:'', dtLastAccessed:''}; } engine.aLoadedContents.push(obj); }, error: function(response, ioArgs) { alert("requestUIComponent(" + sPageId + ") --> error with status: " + ioArgs.xhr.status + ", message:" + response.message); } }; dojo.xhrGet(kw); console.debug("requestUIComponent( ... ) ==> granted==End"); } } catch(e) { console.debug("ERROR: catched requestUIComponent exception: " + e.message); } }, requestResourceFile:function( sLangCode, sComponentId ) { console.debug("requestResourceFile( " + sLangCode + ", " + sComponentId + " )"); var kwx= { url: "/_rsserver.php", handleAs: "text", sync:true, timeout: 5000, content: { ssLangCode:sLangCode, ssComponentId:sComponentId }, error: function(response, ioArgs) { alert("requestResourceFile(" + sComponentId + ") --> error with status: " + ioArgs.xhr.status + ", message:" + response.message); }, load: function(response, ioArgs) { aLines=new Array(); aLines=response.split("\r\n"); for (x in aLines) { if (aLines[x].indexOf('==',0)>0 && aLines[x].indexOf('//')==-1) { aValues=aLines[x].split('=='); str0=dojo.string.trim(aValues[0]); str1=dojo.string.trim(aValues[1]) if ( sComponentId == 'framework') // engine is for the messages belonging to the framework { engine.addResource(str0.toLowerCase(),str1); } else { engine.aLoadedComponents[sComponentId.toLowerCase()].addResource(str0.toLowerCase(),str1); } } } } }; x=dojo.xhrGet( kwx ); }, logStat:function(sPageId) { // log statistic to db }, getObjectContent:function (sLangCode,sPageId) { if ( engine.aLoadedContents != undefined ) { for (x in engine.aLoadedContents) { if (engine.aLoadedContents[x].sLangCode==sLangCode && engine.aLoadedContents[x].sPageId==sPageId) { return engine.aLoadedContents[x].sContent; } } } return false; }, processRPCServerResponce:function (z) { if (z.bResult!=true) { if (z.bMessage==true) { console.debug("SERVER ERROR: " + z.sMessage); } else { console.debug("SERVER ERROR: "); } return false; } return true; }, /* ************************************************************************** */ // application global functions not specific to the engine but they sure come in handy /* ************************************************************************** */ Day:function() { var today = new Date(); return today.getDate(); }, Month:function() { var today = new Date(); return today.getMonth() + 1; }, Year:function() { var today = new Date(); return today.getFullYear(); }, Hour:function() { var today = new Date(); return today.getHours(); }, Minute:function() { var today = new Date(); return today.getMinutes(); }, Second:function() { var today = new Date(); return today.getSeconds(); }, MilliSecond:function() { var today = new Date(); return today.getMilliseconds(); }, getHMS:function() { Y=engine.Year(); M=engine.Month(); D=engine.Day(); H=engine.Hour(); m=engine.Minute(); S=engine.Second(); ms=engine.MilliSecond(); return }, getYMDHMSmSerial:function() { Y=engine.Year(); M=engine.Month(); D=engine.Day(); H=engine.Hour(); m=engine.Minute(); S=engine.Second(); ms=engine.MilliSecond(); dt=Y+M+D+H+m+S+ms; return dt; }, /* ************************************************************************** */ // Event handlers /* ************************************************************************** */ login_completed_success:function(s) { engine.sSession=s; engine.rpc.getPreloadableSources(engine.sSession).addCallback(engine.login_completed_success_2); }, login_completed_success_2:function(z) { try { if (engine.processRPCServerResponce(z)) { // preload js sources and htmls for (x in z.oResult) { engine.requestUI( engine.sSession, engine.sCountryCode, engine.sLangCode, z.oResult[x].ui, false ); engine.requestJS( engine.sSession, engine.sCountryCode, engine.sLangCode, z.oResult[x].js, false ); } if (engine.user_type=='ADMIN') { engine.QMode='DESIGN'; engine.loadModule("public", engine.sLangCode, 'loggedon', 'loggedon', 'login'); engine.loadModule("public", engine.sLangCode, 'logoff', 'logoff', 'user'); } else if (engine.user_type=='QTESTER' || engine.user_type=='USER') { engine.qdiv='all'; engine.QMode='RUN'; engine.loadPage("public", engine.sLangCode, 'questionnaire_run', 'questionnaire_run', 'all', false, false); } } else { alert('Preloadable sources: '+z.sMessage+' (login_completed_success_2 function in engine)'); } } catch(err) { alert(err.description); } }, login_completed_failure:function() { dojo.byId('dlgAlert_header').innerHTML=engine.resource('loggedoff.dlgAlert_header'); dojo.byId('dlgAlert_message').innerHTML=engine.resource('loggedoff.dlgAlert_message'); dijit.byId('dlgAlert').show(); }, logoff:function() { engine.bMenu=false; dojo.byId('main_menu').innerHTML=''; dojo.byId('sub_menu').innerHTML=''; engine.sSession=''; engine.initial_layout(); }, getURLParam:function(strParamName) { var strReturn = ""; var strHref = window.location.href; if ( strHref.indexOf("?") > -1 ) { var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase(); var aQueryString = strQueryString.split("&"); for ( var iParam = 0; iParam < aQueryString.length; iParam++ ) { if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ) { var aParam = aQueryString[iParam].split("="); strReturn = aParam[1]; break; } } } return unescape(strReturn); }, open_invitation:function(){ //alert('open invitatiomn') engine.rpc.login_open().addCallback(engine.direct_link_result); }, direct_link:function() { // // http://192.168.1.109/#DIRECTLINK?USER=kh1&PASSWORD=kh1 name=engine.getURLParam('USER') password=engine.getURLParam('PASSWORD') engine.rpc.login(name,password).addCallback(engine.direct_link_result); }, direct_link_result:function(z) { if (engine.processRPCServerResponce(z)) { if (z.bMessage==true) { // get usertype, name engine.user_type=z.oResult.user_type; engine.name=z.oResult.name; dojo.publish("LOGINCOMPLETEDSUCCESS", [z.sMessage]); return true; } } dojo.publish("LOGINCOMPLETEDFAILURE"); return false; }, initial_layout:function() { // clear all layout divs dojo.byId('logo').innerHTML=''; dojo.byId('login').innerHTML=''; dojo.byId('user').innerHTML=''; dojo.byId('language').innerHTML=''; dojo.byId('main_menu').innerHTML=''; dojo.byId('sub_menu').innerHTML=''; dojo.byId('content').innerHTML=''; dojo.byId('properties').innerHTML=''; // load modules engine.loadModule("public", engine.sLangCode, 'logo', 'logo', 'logo'); //engine.loadModule("public", engine.sLangCode, 'loggedoff', 'loggedoff', 'login'); engine.loadModule("public", engine.sLangCode, 'login', 'login', 'login'); //engine.loadModule("public", engine.sLangCode, 'register', 'register', 'user'); //engine.loadModule("public", engine.sLangCode, 'language', 'language', 'language'); if (engine.bMenu ) { engine.loadModule("public", engine.sLangCode, 'menu', 'empty', 'EMPTY'); } engine.loadPage('public', engine.sLangCode, 'welcome', 'welcome', 'content', true, true); }, /* *************** EXPERIMENTAL ************************* */ requestJS:function( sSession, sCountryCode, sLangCode, sID, sObjectName) { if (!engine.aJSs[sID]) { if (sID!='EMPTY') { var kw = { url: "/_jsserver_2.php", handleAs: "text", sync:false, timeout: 5000, content: { sSession:sSession, sID:sID, sLangCode:sLangCode, sCountryCode:sCountryCode, sApplicationName:sApplicationName, sAdditionalMethods:'', sAdditionalProperties:'', sAdditionalUtilities:'' }, load: function(response, ioArgs) { // add response to array dt=engine.getYMDHMSmSerial(); var objJS={ sID:sID, sLangCode:sLangCode, js:response, dtCreated:dt, dtLastAccessed:''}; engine.aJSs[sID]=objJS; if (sObjectName!=false) { dojo.publish("JSLOADED", [sLangCode, sID, sObjectName]); } }, error: function(response, ioArgs) { console.debug("requestJS(" + sID + "," + sLangCode + ") --> error with status: " + ioArgs.xhr.status + ", message:" + response.message) } }; x=dojo.xhrGet( kw ); } else { dt=engine.getYMDHMSmSerial(); var objJS={ sID:sID, sLangCode:sLangCode, js:'', dtCreated:dt, dtLastAccessed:''}; engine.aJSs[sID]=objJS; if(sObjectName!=false) { dojo.publish("JSLOADED", [sLangCode, sID, sObjectName]); } } } else { dojo.publish("JSLOADED", [sLangCode, sID, sObjectName]); } }, requestUI:function( sSession, sCountryCode, sLangCode, sID, sObjectName) { if (!engine.aUIs[sID]) { if (sID!='EMPTY') { var kw = { url: "/_uiserver_2.php", handleAs: "text", sync:false, timeout: 5000, content: { sSession:sSession, sID:sID, sLangCode:sLangCode, sCountryCode:sCountryCode }, load: function(response, ioArgs) { dt=engine.getYMDHMSmSerial(); var objUI={ sID:sID, sLangCode:sLangCode, ui:response, dtCreated:dt, dtLastAccessed:''}; engine.aUIs[sID]=objUI; if (sObjectName!=false) { dojo.publish("UILOADED", [sLangCode, sID, sObjectName]); } }, error: function(response, ioArgs) { console.debug("requestUI(" + sID + "," + sLangCode + ") --> error with status: " + ioArgs.xhr.status + ", message:" + response.message); } }; dojo.xhrGet(kw); } else { dt=engine.getYMDHMSmSerial(); var objUI={ sID:sID, sLangCode:sLangCode, ui:'', dtCreated:dt, dtLastAccessed:''}; engine.aUIs[sID]=objUI; if (sObjectName!=false) { dojo.publish("UILOADED", [sLangCode, sID, sObjectName]); } } } else { dojo.publish("UILOADED", [sLangCode, sID, sObjectName]); } }, /* *********************************************************** */ change_language:function() { } } function trim(sValue) { return sValue.replace(/^\s+/,'').replace(/\s+$/,''); } function clearlistbox(sDomId) { dojo.byId(sDomId).options.length=0; } function selectLBOption(domid,value) { // selects an item in a dropdown listbox and displays it // based on the value of the option (for instance: a record id ?) var obj=dojo.byId(domid); var selLength = obj.length; var i; for(i=selLength-1; i>=0; i--) { if(obj.options[i].value==value) { obj.options[i].selected=true; obj.selectedIndex=i; } } } function resetLB (sDomId) { var collection; collection = document.all[sDomId]; //collection = dojo.byId('domid'); if ( collection ) { for (i=0;i 1900 ; x-- ) { var index=obj.length; var newOption = new Option(x, x); obj.options[index] = newOption; if (bSelectedYear==x) { obj.options[index].selected=true; } } } function fillLBwithFutureYears(sDomId,bSelectedYear,bShowChoose) { var obj=dojo.byId(sDomId); if ( bShowChoose ) { var index=obj.length; var newOption = new Option("-- Choose --",0); obj.options[index] = newOption; } objDate= new Date(); for( x = objDate.getFullYear() ; x < objDate.getFullYear() + 5 ; x++ ) { var index=obj.length; var newOption = new Option(x, x); obj.options[index] = newOption; if ( bSelectedYear == x ) { obj.options[index].selected=true; } } } function resetRadioValue(sDomId) { var collection; collection = document.all[sDomId]; if ( collection ) { for (i=0;i0){ str = str + ', ' + (i+1); } else { str = '' + (i+1); } } } //alert(str); return str; } function IsNumeric(sText) { var ValidChars = "0123456789."; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } function currentDay () { var today = new Date(); return today.getDate(); } function currentMonth () { var today = new Date(); return today.getMonth() + 1; } function currentYear () { var today = new Date(); return today.getFullYear(); } function addLBOption (sDomId, sText, sValue, bSelected) { // Adds an item to een select box var obj=dojo.byId(sDomId); var newOption = new Option(sText, sValue); var index = obj.length; obj.options[index] = newOption; if (bSelected) { obj.options[index].selected=true; } } function setLBSingleItemSelected (sDomId,sValue) { // selects an item in a dropdown listbox and displays it // based on the value of the option (for instance: a record id ?) var obj=dojo.byId(sDomId); var selLength = obj.length; var i; for(i=selLength-1; i>=0; i--) { if(obj.options[i].value==sValue) { obj.options[i].selected=true; obj.selectedIndex=i; } } } function getIsSelectionLB (sDomId) { var obj=dojo.byId(sDomId); var selLength = obj.length; var arrReturn=new Array(); var arrCounter=0; var i; for(i=0; i < selLength ; i++) { if(obj.options[i].selected==true) { return true; } } return false; } function getLBMultipleSelected(sDomId) { var obj=dojo.byId(sDomId); var selLength = obj.length; var arrReturn=new Array(); var arrCounter=0; var i; for(i=0; i < selLength ; i++) { if(obj.options[i].selected==true) { arrReturn[arrCounter++]=obj.options[i].value; } } if (arrCounter==0) { arrReturn[0]=-1; } return arrReturn; } function daysInMonth (iMonth, iYear) { return 32 - new Date(iYear, iMonth, 32).getDate(); } function addOptionWithSelected(selectId,sText,sValue,bSelected) { // adds an option to a select with the option selected status set (true or false) // good voor multi select boxes with multiple items set to chosen... //debugger var index=selectId.length; var newOption = new Option(sText, sValue); selectId.options[index] = newOption; if (bSelected) { selectId.options[index].selected=true; } }