UNPKG

profoundjs

Version:

Profound.js Framework and Server

108 lines (107 loc) 46.5 kB
function w(b){this.onready=this.onfail=this.onsuccess=this.cacheBuster=this.suppressAlert=this.password=this.user=this.async=this.url=this.reqData=this.postData=this.method=null;this.headers={};this.params=null;this.sendAsBinary=true;var c=this.overrideMimeType=null,a=null,d=null,e=null,g=typeof pui!="undefined"&&typeof pui.alert!="undefined"?pui.alert:alert,f=this;if(w.defaultHeaders)this.headers=w.defaultHeaders;if(typeof b=="object")for(var i in b){if(typeof this[i]!="undefined")this[i]=b[i]}else this.url= b;if(window.XMLHttpRequest)c=new XMLHttpRequest;else if(window.ActiveXObject)c=new ActiveXObject("Microsoft.XMLHTTP");else{g("Ajax request error: Unsupported browser.");return}this.send=this.send=function(){function h(){if(c.readyState==4){a=c.status===0?x?"Request aborted.":"Request failed. Check the browser console for more details.":c.status+" - "+c.statusText;f.onready!=null&&f.onready(f);if(c.status==200){d=true;f.onsuccess!=null&&f.onsuccess(f)}else{d=false;f.suppressAlert!=true&&g(a);f.onfail!= null&&f.onfail(f)}e=false}}var j,l=null,m=null,q=null;if(f.method==null)l="GET";else if(typeof f.method!="string"&&(f.method.toUpperCase()!="GET"||f.method.toUpperCase()!="POST"||f.method.toUpperCase()!="PUT"||f.method.toUpperCase()!="DELETE")){g('Invalid value for property: "method".');return}else l=f.method.toUpperCase();if(l=="POST"||l=="PUT"||l=="DELETE"){if(f.reqData!=null)q=f.reqData;else if(f.postData!=null)q=f.postData;if(q!=null){if(typeof q!="string"){g('Invalid value for property: "postData".'); return}}else q=""}if(f.async==null)m=true;else if(f.async!=true&&f.async!=false){g('Invalid value for property: "async".');return}else m=f.async;if(typeof f.url!="string")g('Invalid value for property: "url".');else{if(f.user!=null)if(typeof f.user!="string"){g('Invalid value for property: "user".');return}if(f.password!=null)if(typeof f.password!="string"){g('Invalid value for property: "password".');return}if(f.onsuccess!=null)if(typeof f.onsuccess!="function"){g('Invalid value for event: "onsuccess".'); return}if(f.onfail!=null)if(typeof f.onfail!="function"){g('Invalid value for event: "onfail".');return}if(f.onready!=null)if(typeof f.onready!="function"){g('Invalid value for event: "onready".');return}var o=true;if(q!=null)for(j in f.headers)if(j.toUpperCase()=="CONTENT-TYPE")if(f.headers[j].toLowerCase().indexOf("www-form-urlencoded")==-1)o=false;var t=f.url,n=f.params;if(typeof n=="object"){var k="";for(j in n){var r=n[j],p=[];if(typeof r=="object"){if(r.length!=null&&r.length>0)p=r}else p.push(r); for(r=0;r<p.length;r++){if(k!="")k+="&";k+=encodeURIComponent(j)+"="+encodeURIComponent(p[r])}}if(k!="")if(o&&(l=="POST"||l=="PUT"||l=="DELETE")){if(q!=null&&q!="")q+="&";else q="";q+=k}else{o=t.split("?");if(o.length==2&&o[1]!="")t=o[0]+"?"+o[1]+"&"+k;else t+="?"+k}}if(l==="GET"&&(f.cacheBuster===null||f.cacheBuster===true))t=pui.addUrlCacheBuster(t);try{typeof f.user=="string"&&typeof f.password=="string"?c.open(l,t,m,f.user,f.password):c.open(l,t,m);t=false;var s=f.headers;for(j in s){c.setRequestHeader(j, s[j]);if(j.toUpperCase()=="CONTENT-TYPE")t=true}if(l=="POST"||l=="PUT"||l=="DELETE")t||c.setRequestHeader("Content-type","application/x-www-form-urlencoded");typeof f.overrideMimeType=="string"&&typeof c.overrideMimeType=="function"&&c.overrideMimeType(f.overrideMimeType)}catch(v){g(v);return}e=true;var x=false;if(m==true){c.onload=h;c.onerror=h;c.onabort=function(){x=true;h()}}if(f.sendAsBinary==true)try{c.sendAsBinary(q)}catch(E){c.send(q)}else c.send(q);m!=true&&h()}};this.ok=this.N=function(){return d!= null?d:false};this.getResponseText=this.d=function(){return c.responseText};this.getResponseXML=this.w=function(){return c.responseXML};this.getStatus=this.e=function(){return c.status};this.getStatusText=this.n=function(){return c.statusText};this.getStatusMessage=this.m=function(){return a};this.getAllResponseHeaders=this.getAllResponseHeaders=function(){if(d)try{return c.getAllResponseHeaders()}catch(h){g(h)}};this.getResponseHeader=this.getResponseHeader=function(h){if(d)try{return c.getResponseHeader(h)}catch(j){g(j)}}; this.setRequestHeader=this.setRequestHeader=function(h,j){f.headers[h]=j};this.abort=this.abort=function(){if(e===true)try{c.abort()}catch(h){g(h)}}} function y(b,c){var a,d,e,g="";if(arguments.length==1&&typeof arguments[0]=="object"){a=arguments[0];a.async=null;a.onsuccess=null;if(typeof a.handler=="function"){d=true;e=a.handler}else d=false}else if(c!=null&&typeof c=="function"){d=true;e=c}else d=false;a=new w(arguments[0]);a.async=d;a.onsuccess=function(f){g+=f.d();d==true&&e(g)};a.send();if(d==false)return g} function B(b,c){var a,d,e,g=null,f=false;if(arguments.length==1&&typeof arguments[0]=="object"){a=arguments[0];a.async=null;a.onsuccess=null;if(a.saveResponse==true)f=true;if(typeof a.handler=="function"){d=true;e=a.handler}else d=false}else if(c!=null&&typeof c=="function"){d=true;e=c}else d=false;a=new w(arguments[0]);a.async=d;a.onsuccess=function(i){i=i.d();if(f&&typeof pui=="object")pui.savedJSON=i;try{g=eval("("+i+")")}catch(h){e(null,h);return}d==true&&e(g)};a.send();if(d==false)return g} if(typeof window.pui=="undefined")window.pui={};window.RPGspRequest=w;window.pui.Ajax=w;window.pui.AjaxRequest=w;window.ajax=y; window.ajaxXML=function(b,c){var a,d,e,g=null;if(arguments.length==1&&typeof arguments[0]=="object"){a=arguments[0];a.async=null;a.onsuccess=null;a.onfail=null;a.onsuccess=null;if(typeof a.handler=="function"){d=true;e=a.handler}else d=false}else if(c!=null&&typeof c=="function"){d=true;e=c}else d=false;a=new w(arguments[0]);a.async=d;a.onsuccess=function(f){g=f.w();d==true&&e(g)};a.send();if(d==false)return g};window.ajaxJSON=B; window.ajaxSubmit=function(b,c){var a,d="",e=typeof pui!="undefined"&&typeof pui.alert!="undefined"?pui.alert:alert;if(typeof b=="object")a=b;else{a=document.getElementById(b);if(a==null)a=document.forms[b]}var g;if(a!=null)g=a.tagName;if(a==null||g==null||g.toUpperCase()!="FORM"){e("Ajax request error: Invalid form object.");return""}if(b.action==""){e("Ajax request error: Invalid form action.");return""}for(e=0;e<a.elements.length;e++){g=a.elements[e];if(g.name!=null&&g.name!=""){var f=false;if(g.tagName== "INPUT"){var i=g.type;i=i.toLowerCase();if(i=="hidden")f=true;if(i=="password")f=true;if(i=="text")f=true;if(pui.oa(i))f=true;if(i=="")f=true;if(i=="checkbox"||i=="radio")if(g.checked)f=true}if(g.tagName=="TEXTAREA")f=true;if(g.tagName=="SELECT")f=true;if(f){if(d!="")d+="&";d+=g.name+"="+encodeURIComponent(g.value)}}}a=new w(a.action);a.method="POST";a.postData=d;var h="",j;if(c!=null&&typeof c=="function")j=true;else{j=false;a.async=false}a.onsuccess=function(l){h+=l.d();j==true&&c(h)};a.send(); if(j==false)return h};function D(b,c){var a,d;a=b!=null&&typeof b=="object"?b:document.getElementById(b);if(a==null)return"";d="";if(a.tagName.toLowerCase()=="div"){d=a.firstChild;d=d!=null&&d.tagName!=null&&d.tagName=="A"?d.innerHTML:a.innerHTML}if(a.tagName=="INPUT"&&a.type=="checkbox"){if(a.indeterminate===true)return a.indeterminateValue;if(a.checked&&a.checkedValue!=null)return a.checkedValue;if(!a.checked&&a.uncheckedValue!=null)return a.uncheckedValue;return a.checked}if(a.tagName=="INPUT"&&a.type=="radio")return a.checked; if(a.tagName=="TEXTAREA")d=a.value;else if(a.tagName=="INPUT"){var e=a.j;if(c&&e!=null&&typeof e.value==="string")if(e.value.length>0)d=a.j.value;else{if(pui["force auto complete match"]==false)d=a.value}else d=a.value}else if(a.tagName=="SELECT"){d=a.selectedIndex;d=d>=0?a.options[d].value:a.pui&&a.pui.properties&&a.pui.properties.value?a.pui.properties.value:a.value}if(a.comboBoxWidget!=null)d=a.comboBoxWidget.getValue();if(a.h!=null)d=a.h.getValue();if(a.signaturePad!=null)d=a.signaturePad.getValue(); if(a.A!=null)d=String(a.value);if(a.g!=null){d="";if(a.g.K&&a.g.O!=null)d=a.g.O;else if(!a.g.K&&a.g.M!=null)d=a.g.M}if(a.pui&&a.pui.widget&&typeof a.pui.widget.getPropertyValue==="function")d=a.pui.widget.getPropertyValue("value");for(d=d.replace(/&nbsp;/g," ");d.indexOf(String.fromCharCode(160))!=-1;)d=d.replace(String.fromCharCode(160)," ");if(d==a.ha)d="";return d}function G(b){if(typeof b!=="string")return b;for(;b.charAt(0)==" ";)b=b.replace(b.charAt(0),"");return b} function I(b){if(typeof b!=="string")return b;return b.replace(/^\s*|\s*$/g,"")}pui.detachCalendar=function(b){if(typeof b=="string")b=document.getElementById(b);b!=null&&pui.ta(b)}; function J(b,c,a){var d=false,e=location.href;e=e.split("?")[0];e=e.split("/");if(e.length>2&&e[e.length-2].toLowerCase()=="auth")d=true;e="/profoundui/";var g=["PUI0009101.PGM","PUI0009102.PGM","PUI0009103.PGM","PUI0009104.PGM","PUI0009107.PGM","PUI0009109.PGM","PUI0009110.PGM","PUI0009119.PGM"];if(typeof pui.widgetURLPrefix==="string"&&g.indexOf(b.toUpperCase())!=-1){e=pui.widgetURLPrefix;if(e.substr(e.length-1)!="/")e+="/"}if(d==true||a==true)e+="auth/";e+=b;if(c!=null&&c==true)e+="/"+PSID;if(pui.serverURL!= null)e=pui.serverURL+e;return e}pui.getProgramURL=J;pui.ja=function(b){return pui.v(b).x};pui.ka=function(b){return pui.v(b).y}; pui.v=function(b){b=b||window.event;var c={x:0,y:0};if(b!=null&&b.touches!=null&&b.touches.length==1){c.x=b.touches[0].pageX;c.y=b.touches[0].pageY}else if(b!=null){if(b.pageX)c.x=b.pageX;else if(b.clientX)c.x=b.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);if(b.pageY)c.y=b.pageY;else if(b.clientY)c.y=b.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)}return c}; function K(){var b={},c="";c=location.search.substring(1,location.search.length);if(c.length==0)return b;c=c.replace(/\+/g," ");c=c.split("&");for(var a=0;a<c.length;a++){var d=c[a].split("="),e=decodeURIComponent(d[0]),g="";if(d.length==2)g=decodeURIComponent(d[1]);b[e]=g}return b}if(typeof applyDesignProperty!="undefined")window.aa=applyDesignProperty; pui.r={u:function(b){for(var c="",a=0;a<b.length;a++){var d=b.codePointAt(a);d>65535&&a++;if(d<128)c+=String.fromCharCode(d);else{if(d<2048)c+=String.fromCharCode(d>>6|192);else{if(d<65536)c+=String.fromCharCode(d>>12|224);else{c+=String.fromCharCode(d>>18|240);c+=String.fromCharCode(d>>12&63|128)}c+=String.fromCharCode(d>>6&63|128)}c+=String.fromCharCode(d&63|128)}}return c},t:function(b){for(var c="",a=0,d=0,e=0,g=0,f=0;a<b.length;){d=b.charCodeAt(a);if(d<128){c+=String.fromCharCode(d);a++}else if(d< 224){e=b.charCodeAt(a+1);c+=String.fromCharCode((d&31)<<6|e&63);a+=2}else if(d<240){e=b.charCodeAt(a+1);g=b.charCodeAt(a+2);c+=String.fromCharCode((d&15)<<12|(e&63)<<6|g&63);a+=3}else{e=b.charCodeAt(a+1);g=b.charCodeAt(a+2);f=b.charCodeAt(a+3);c+=String.fromCodePoint((d&7)<<18|(e&63)<<12|(g&63)<<6|f&63);a+=4}}return c}}; pui.W={c:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u:function(b){var c="",a,d,e,g,f,i,h=0;for(b=pui.r.u(b);h<b.length;){a=b.charCodeAt(h++);d=b.charCodeAt(h++);e=b.charCodeAt(h++);g=a>>2;a=(a&3)<<4|d>>4;f=(d&15)<<2|e>>6;i=e&63;if(isNaN(d))f=i=64;else if(isNaN(e))i=64;c=c+this.c.charAt(g)+this.c.charAt(a)+this.c.charAt(f)+this.c.charAt(i)}return c},t:function(b){var c="",a,d,e,g,f,i=0;for(b=b.replace(/[^A-Za-z0-9+/=]/g,"");i<b.length;){a=this.c.indexOf(b.charAt(i++));d=this.c.indexOf(b.charAt(i++)); g=this.c.indexOf(b.charAt(i++));f=this.c.indexOf(b.charAt(i++));a=a<<2|d>>4;d=(d&15)<<4|g>>2;e=(g&3)<<6|f;c+=String.fromCharCode(a);if(g!=64)c+=String.fromCharCode(d);if(f!=64)c+=String.fromCharCode(e)}return c=pui.r.t(c)}}; pui.downloadJSON=function(){if(pui.recordTest)pui.saveRecording();else if(pui.savedJSON==null)pui.alert("JSON is not available.");else{var b=pui.savedJSON;if(typeof JSON==="object"&&typeof JSON.parse==="function"&&typeof JSON.stringify==="function")try{b=JSON.stringify(JSON.parse(pui.savedJSON),null," ")}catch(c){}pui.F("text/plain","json.txt",b)}}; pui.saveRecording=function(b){for(var c=null,a=0;a<pui.b.payloads.length;a++){if(!c&&pui.b.responses[a].appJob)c=pui.b.responses[a].appJob.user;pui.b.payloads[a].response=pui.b.responses[a]}var d=K().testid;(a=d)||(a=prompt("Enter recording name"));if(a)if(pui.pjsServer)if(pui.b.payloads.length===0)pui.alert("No recording to save.");else{c={id:d,appuser:c,payloads:pui.b.payloads};a={"Content-Type":"application/json"};if(sessionStorage["atrium-token"])a.Authorization="Basic "+sessionStorage["atrium-token"]; fetch("/auto-testing/save-recording",{method:"POST",headers:a,body:JSON.stringify(c)}).then(function(g){if(g.ok){window.parent&&window.parent.Atrium&&window.parent.Atrium.api&&typeof window.parent.Atrium.api.reloadNavParent==="function"&&window.parent.Atrium.api.reloadNavParent("test-"+d);pui.b={payloads:[],responses:[]};typeof b==="function"?b():pui.alert("Recording saved.")}else pui.alert("Failed to save recording.")})["catch"](function(g){pui.alert("Error: Unable to save recording.");console.error("Fetch error:", g)})}else{c=JSON.stringify({user:c,payloads:pui.b.payloads});var e=a;e.endsWith(".json")||(e+=".json");if(pui["recording path"]){a=[];a.push({name:"path",value:pui["recording path"]+e});a.push({name:"text",value:"1"});a.push({name:"replace",value:"Y"});a.push({name:"json",value:c,fileName:e});c=new pui.X;c.Y(a);a=J("PUI0001109.pgm");a=a.replace("/auth","");c.send(a,function(g){var f,i={};if(g.e()!=200)f=g.m();if(!f){i=eval("("+g.d()+")");i.success||(f=i.errorText)}if(f)pui.alert(f);else{pui.alert("Recording saved."); pui.b={payloads:[],responses:[]}}})}else pui.F("text/plain",e,c)}}; pui.keepAlive=function(){var b;if(!(context=="genie"&&pui.f.i==true)){if(context=="dspf")b=pui.f==null?J("PUI0001200.pgm"):J("PUI0002110.pgm");else if(context=="genie")b=window.DOCUMENT_URI;else return false;if(pui.psid!=null&&pui.psid!="")b+="/"+pui.psid;if(pui.overrideSubmitUrl!=null&&typeof pui.overrideSubmitUrl=="function")try{b=pui.overrideSubmitUrl(b)}catch(c){}if(context=="genie")pui.B(pui.f.i=true);if(context=="dspf")pui.q=false;pui.wa();var a={keepalive:"1"};if(pui.isCloud)a.workspace_id= pui.cloud.ws.id;y({url:pui.Z(b),method:"post",params:a,sendAsBinary:false,suppressAlert:true,handler:function(){pui.I();if(context=="genie")pui.B(pui.f.i=false);if(context=="dspf")pui.q=true;for(var d=0;d<pui.o.length;d++)pui.o[d].unMask()},onfail:function(d){pui.onoffline==null&&!pui["suppress comm errors"]&&pui.alert(pui.la(d));pui.I();if(context=="genie")pui.B(pui.f.i=false);if(context=="dspf")pui.q=true;for(d=0;d<pui.o.length;d++)pui.o[d].unMask();pui.onoffline!=null&&pui.onoffline()}});return true}}; pui.getWindowSize=function(){var b,c;if(document.body&&document.body.offsetWidth){b=document.body.offsetWidth;c=document.body.offsetHeight}if(document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth){b=document.documentElement.offsetWidth;c=document.documentElement.offsetHeight}if(window.innerWidth&&window.innerHeight){b=window.innerWidth;c=window.innerHeight}if(window.visualViewport&&window.visualViewport.width&&window.visualViewport.height){b=window.visualViewport.width; c=window.visualViewport.height}if(document.documentElement&&document.documentElement.clientWidth){b=document.documentElement.clientWidth;c=document.documentElement.clientHeight}if(b==null&&screen!=null)b=screen.width;if(c==null&&screen!=null)c=screen.height;if(b==null)b=800;if(c==null)c=600;return{width:b,height:c}};pui.openURL=function(b){window.open(b)}; pui.normalizeURL=function(b,c){if(b==null||typeof b!="string")return"";if(c==true&&window.puiMobileClient==null)return b;if(b.substr(0,5).toLowerCase()=="http:"||b.substr(0,6).toLowerCase()=="https:"||b.substr(0,5).toLowerCase()=="data:")return b;return pui.serverURL!=null?pui.serverURL+b:window.cordova&&b.substr(0,1)=="/"?b.substr(1):b}; pui.animate=function(b){var c,a,d=b.element;if(typeof d=="string")d=document.getElementById(d);if(d!=null){var e;c=b.effect;if(c=="fly in left"||c=="fly in right"||c=="fly out left"||c=="fly out right")e="left";else if(c=="fly in up"||c=="fly in down"||c=="fly out up"||c=="fly out down")e="top";else if(c=="fade in"||c=="fade out")e="opacity";else{e=b.properties;if(e==null){e=b.property;if(e==null)return}}if(typeof e=="string")e=[e];var g=b.duration;if(g==null)g="500ms";if(g.substr(g.length-1,1)!= "s")g+="s";var f=parseInt(g)*1E3;if(g.length>2&&g.substr(g.length-2,2)=="ms")f=parseInt(g);var i=b.type;if(i==null)i="ease";var h=b.from,j=b.to;switch(c){case "fly in right":h=-d.offsetWidth;h+="px";j="0px";break;case "fly in left":h=d.offsetWidth;h+="px";j="0px";break;case "fly out left":j=-d.offsetWidth;j+="px";h="0px";break;case "fly out right":j=d.offsetWidth;j+="px";h="0px";break;case "fly out down":j=d.offsetHeight;j+="px";h="0px";break;case "fly out up":j=-d.offsetHeight;j+="px";h="0px";break; case "fly in up":h=d.offsetHeight;h+="px";j="0px";break;case "fly in down":h=-d.offsetHeight;h+="px";j="0px";break;case "fade in":h="0";j="100";break;case "fade out":h="100";j="0";break}if(j!=null){var l="";for(c=0;c<e.length;c++){a=e[c];if(l!="")l+=", ";l+=a+" "+g+" "+i}var m=["transition","MozTransition","WebkitTransition","msTransition","OTransition"];if(h!=null){if(typeof h=="string"||typeof h=="number")h=[h];for(c=0;c<e.length;c++){a=e[c];d.style[a]=h[c]}}setTimeout(function(){for(var q=0;q< m.length;q++)d.style[m[q]]=l;setTimeout(function(){if(typeof j=="string"||typeof j=="number")j=[j];for(var o=0;o<e.length;o++)d.style[e[o]]=j[o];setTimeout(function(){for(var t=0;t<m.length;t++)d.style[m[t]]="";b.oncomplete!=null&&b.oncomplete()},f)},1)},1)}}};pui.getActiveElement=function(){return context=="genie"?lastActiveElement:pui.activeElement};pui.fieldExit=function(b){var c=pui.getActiveElement();if(c!=null){var a=false;if(b!=null)a=true;context=="genie"?fieldExit(c,a):pui.fa(c)}}; pui.gotoNextElement=function(b){O(b,true)};pui.gotoPreviousElement=function(b){O(b,false)}; function O(b,c){var a=c?1:-1,d=document.querySelectorAll("INPUT,SELECT,TEXTAREA"),e=d.length;if(!(e<2))for(var g=Array.prototype.indexOf.call(d,b),f=g+a,i;;){if(f===g)break;if(f===e)f=0;else if(f===-1)f=e-1;else{var h=i=d[f];if(i!=null&&i.comboBoxWidget!=null)h=i.comboBoxWidget.G();if(i!=null&&i.h!=null)h=i.h.G();if(h.readOnly||h.disabled||h.style.visibility==="hidden"||h.tabIndex==="-1"||!h.clientHeight||!h.clientWidth)f+=a;else{try{h.focus();if(document.activeElement!=h){f+=a;continue}setTimeout(function(){pui["highlight on focus"]&& typeof h.select=="function"&&h.select();pui.va(null,h)},0)}catch(j){}break}}}}pui.showCalendar=function(b){var c=b;if(typeof b=="string")c=document.getElementById(b);if(c!=null)if(typeof c=="object"){var a=c.calimg;if(a!=null)if(a.click!=null&&typeof a.click=="function")a.click();else a.onclick!=null&&typeof a.onclick=="function"&&setTimeout(function(){a.onclick()},250)}}; pui.getComputedStyle=function(b){var c=null;if(window.getComputedStyle)c=window.getComputedStyle(b);else if(b.currentStyle)c=b.currentStyle;return c}; pui.upload=function(b,c){var a,d,e=b.dir,g=b.overwrite===true,f;if(typeof b.slimit=="number")f=b.slimit;var i;if(typeof b.flimit=="number")i=b.flimit;var h="";if(typeof b.altname=="string")h=b.altname;var j;if(typeof b.allowedTypes&&b.allowedTypes instanceof Array)j=b.allowedTypes;if(i==null)i=b.files.length;if(f==null||j==null){var l,m=[];for(a=0;a<b.files.length;a++){d=b.files[a];var q=typeof d.type!="undefined"&&d.type!=""?d.type:"application/octet-stream";pui.ba(m,q)==-1&&m.push(q);d=d.data&& d.data instanceof ArrayBuffer?d.data.byteLength:d.size;d=Math.ceil(d/1048576);if(l==null||d>l)l=d}if(f==null)f=l;if(j==null)j=m}l=J("PUI0009109.PGM");l+="?AUTH="+encodeURIComponent(pui.p?pui.p:pui.appJob.auth);if(b.mode!=="widget")l+="&mode=ajax";if(b.id)l+="&id="+encodeURIComponent(b.id);l+="&r="+Math.floor(Math.random()*1E9);if(pui.isCloud)l+="&workspace_id="+pui.cloud.ws.id;m=new FormData;m.append("dir",e);m.append("overwrite",g?"1":"0");m.append("flimit",i);m.append("slimit",f);m.append("altname", h);typeof b.generateNames=="string"&&m.append("generateNames",b.generateNames);for(a=0;a<j.length;a++)m.append("type",j[a]);for(a=0;a<b.files.length;a++){d=b.files[a];if(d.data&&d.data instanceof ArrayBuffer){var o;try{o=new Blob([d.data])}catch(t){e=new window.WebKitBlobBuilder;e.append(d.data);o=e.getBlob()}m.append("file",o)}else m.append("file",d);m.append("filename",d.name)}var n=new XMLHttpRequest;n.open("POST",l,true);n.onreadystatechange=function(){if(n.readyState==4){var k=true,r;if(n.status== 200){var p;try{p=eval("("+n.responseText+")")}catch(s){k=false;r="Server response missing or invalid."}if(p){k=p.success;if(!k)if(p.key){r=pui.getLanguageText("runtimeMsg","upload "+p.key);if(p.key=="file limit")r=r.replace("&1",i);if(p.key=="size limit")r=r.replace("&1",f)}else r=p.error}}else{k=false;r=n.status+" - "+n.statusText+".";if(n.status==0&&n.statusText=="")r="The FILE could not be found in the system."}typeof c=="function"&&c(k,r)}};if(typeof b.onabort=="function")n.onabort=b.onabort; if(typeof b.onprogress=="function"&&"upload"in n)n.upload.onprogress=b.onprogress;if(typeof b.onload=="function")n.onload=b.onload;n.send(m);return n};pui.getCookie=function(b){var c=document.cookie.split(";"),a="",d="",e="",g="";for(g=0;g<c.length;g++){a=c[g].split("=");d=a[0].replace(/^\s+|\s+$/g,"");if(d==b){if(a.length>1)e=unescape(a[1].replace(/^\s+|\s+$/g,""));return e}}return null}; pui.setCookie=function(b,c,a,d,e,g,f){var i=new Date;i.setTime(i.getTime());if(a)a=a*1E3*60*60*24;i=new Date(i.getTime()+a);document.cookie=b+"="+escape(c)+(a?";expires="+i.toGMTString():"")+(d?";path="+d:"")+(e?";domain="+e:"")+(g?";secure":"")+(f?";SameSite="+f:"")};pui.deleteCookie=function(b,c,a,d,e){if(pui.getCookie(b))document.cookie=b+"="+(c?";path="+c:"")+(a?";domain="+a:"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT"+(d?";Secure":"")+(e?";SameSite="+e:"")}; pui.refresh=function(b){if(b==null)b={};var c=b.url;b=b.skin;pui.setCookie("puiRefreshId",pui.psid,null,"/",null,null,"Strict");pui.skipConfirm=true;pui.shutdownOnClose=false;pui.confirmOnClose=false;if(b!=null){b="skin="+encodeURIComponent(b);c=window.location.href;var a=c.split("?");c=a[0];a=a[1];if(a==null)a="";a=a.split("&");for(var d=false,e=0;e<a.length;e++)if(a[e].length>=5&&a[e].substr(0,5).toLowerCase()=="skin="){a[e]=b;d=true}if(!d)if(a.length==1&&a[0]=="")a[0]=b;else a.push(b);a=a.join("&"); c=c+"?"+a}if(c!=null)window.location.href=c;else window.location.reload()}; pui.downloadURL=function(b){if(pui==null||pui.appJob==null||pui.appJob.auth==null||pui.appJob.auth=="")return pui.is_ie?"":"data:text/html,<!DOCTYPE html><html><body><p>To download, please connect to a Profound UI session.</p></body></html>";var c=b.inline===true;if(b.id==null)return"";var a=J("PUI0009110.PGM");a+="?id="+encodeURIComponent(b.id);if(b.contentType!=null)a+="&type="+encodeURIComponent(b.contentType);if(c)a+="&inline=1";a+="&usehttprc=0";a+="&AUTH="+encodeURIComponent(pui.p?pui.p:pui.appJob.auth); a+="&r="+Math.floor(Math.random()*1E9);return a};pui.download=function(b){var c=pui.downloadURL(b);b=b.inline===true;if(pui==null||pui.appJob==null||pui.appJob.auth==null||pui.appJob.auth=="")b=true;b?pui.openURL(c):pui.link(c)}; pui.downloadFile=function(b){if(typeof b==="undefined"||b==null||typeof b.id!=="string"||b.id.length<1)pui.alert("Error downloading file. \n\n No file path given",null,"Error","Close");else{var c=pui.downloadURL(b),a=b.id,d=new XMLHttpRequest;d.responseType="blob";d.open("GET",c,true);d.send();var e=null,g=null,f=null,i=null;d.onprogress=function(h){var j=pui.extractFileNameFromContentDisposition(d.getResponseHeader("Content-Disposition"));if(!(a.split("/").pop()!=j&&j=="error.txt")){if(typeof d.onprogress.diaglogShown=== "undefined"){d.onprogress.diaglogShown=true;e=document.createElement("dialog");document.body.appendChild(e);g=document.createElement("p");e.appendChild(g);f=document.createElement("button");f.innerHTML="OK";f.onclick=function(){e.close();e.remove()};i=document.createElement("button");i.innerHTML="Cancel";i.id="cancelButton";i.onclick=function(){d.abort();e.close();e.remove()};e.appendChild(i);g.innerHTML="Downloading file: "+a+"<br> Starting download...";e.showModal();d.onprogress.lastTime=Date.now()}if(Date.now()> d.onprogress.lastTime+2E3){g.innerHTML="Downloading file: "+a+"<br>"+h.type+" "+(h.loaded/1048576).toFixed(4)+" mb loaded";d.onprogress.lastTime=Date.now()}}};d.onloadend=function(){if(e!=null){e.querySelector("button[id='cancelButton']").remove();e.appendChild(f);g.innerHTML="File "+a+" downloaded successfully."}};d.onreadystatechange=function(){if(d.readyState==4&&d.status==200){var h=pui.extractFileNameFromContentDisposition(d.getResponseHeader("Content-Disposition"));if(a.split("/").pop()!=h&& h=="error.txt"){var j=new FileReader;j.onload=function(){pui.alert("Error downloading file: "+a+"\n\n"+j.result,null,"Error","Close");console.log(j.result)};j.readAsText(d.response)}else{var l=null;if(typeof b.contentType==="string"&&b.contentType.length>0)l=b.contentType;else{l=d.getResponseHeader("Content-Type").split(";")[0];if(typeof l==="string"&&l=="application/octet-stream"){var m=h.split(".").pop();if(typeof m==="string")switch(m.toLowerCase()){case "pdf":l="application/pdf";break;case "txt":l= "text/plain";break;case "csv":l="text/csv";break;case "json":l="application/json";break;case "xml":l="application/xml";break;case "html":l="text/html";break;case "htm":l="text/html";break;case "jpg":l="image/jpeg";break;case "jpeg":l="image/jpeg";break;case "png":l="image/png";break;case "gif":l="image/gif";break}}}m=["application/pdf","text/plain","text/csv","application/json","application/xml","text/html","image/jpeg","image/png","image/gif"];var q=new File([d.response],h,{type:l});q=URL.createObjectURL(q); var o=document.createElement("a");if(typeof b.inline==="boolean"&&b.inline&&m.includes(l))o.target="_blank";else o.download=h;o.name=h;o.href=q;document.body.appendChild(o);o.dispatchEvent(new MouseEvent("click",{bubbles:true,cancelable:true,view:window}));document.body.removeChild(o)}}}}};pui.extractFileNameFromContentDisposition=function(b){b=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(b);if(b!=null&&b[1])return b[1].replace(/['"]/g,"");return null}; pui.focusOnContainer=function(){window.parent!=window&&pui.V(window.parent)&&window.parent.noderun||setTimeout(function(){if(pui.a==null){pui.a=document.createElement("input");pui.a.type=pui.is_touch?"button":"text";pui.a.readOnly=true;pui.a.style.position="absolute";pui.a.style.left="-999px";pui.a.style.top="-999px";pui.a.style.width="10px";pui.a.style.borderStyle="none";pui.a.style.backgroundColor="transparent";pui.runtimeContainer&&pui.runtimeContainer.appendChild(pui.a)}pui.J=true;pui.a.focus(); setTimeout(function(){pui.J=false},0)},1)};pui.addCSS=function(b){var c=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css";if(pui.is_old_ie)a.styleSheet.cssText=b;else a.innerHTML=b;c.appendChild(a)}; pui.loadCSS=function(b){if(pui.H(b)!=null)return false;var c=document.getElementsByTagName("head")[0],a=document.createElement("link");a.setAttribute("rel","stylesheet");a.setAttribute("type","text/css");a.setAttribute("media","screen");a.setAttribute("href",pui.normalizeURL(b));c.appendChild(a);return true}; pui.removeCSS=function(b){var c=document.getElementsByTagName("head")[0],a=pui.H(b);if(a==null){a=c.getElementsByTagName("style");for(var d=0;d<a.length;d++){var e=a[d];if(e.innerHTML==b||e.styleSheet!=null&&e.styleSheet.cssText==b){c.removeChild(e);return true}}return false}else{c.removeChild(a);return true}}; pui.loadJS=function(b){if(b==null)return null;var c,a,d,e;if(typeof b=="string")c=b;if(typeof b=="object"){c=b.path;a=b.callback;d=b.onerror;e=b.test;if(e!=null&&typeof e=="function"&&e()==true)return false}if(c==null)return null;if(pui.ma(pui.normalizeURL(c))!=null)return false;b=document.getElementsByTagName("head")[0];var g=false,f=document.createElement("script");f.type="text/javascript";f.onreadystatechange=function(){if(f.readyState=="complete"||f.readyState=="loaded")if(!(e!=null&&typeof e== "function"&&e()!=true)){!g&&a!=null&&a();g=true}};f.onload=function(){if(!(e!=null&&typeof e=="function"&&e()!=true)){!g&&a!=null&&a();g=true}};if(d)f.onerror=d;f.src=pui.normalizeURL(c);b.appendChild(f);return true}; pui.endOfSession=function(b){pui.confirmOnClose=false;pui.shutdownOnClose=false;if(window.puiMobileClient!=null){window.location.href="index.html";b!=null&&pui.alert(b)}else{var c=K().gobackto;if(c!=null){document.body.innerHTML="";b!=null&&pui.alert(b);location.href=c}if(navigator.app!=null&&navigator.app.exitApp!=null){document.body.innerHTML="";b!=null?pui.alert(b,function(){navigator.app.exitApp()}):navigator.app.exitApp()}}}; pui.addUrlCacheBuster=function(b,c){var a=Date.now();if(typeof c==="string"&&c.toLowerCase()!=="get")return b;return b=/[&?]r=[^&]+/.test(b)?b.replace(/([&?]r=)[^&]+/,function(d,e){return e+a}):b+(b.indexOf("?")==-1?"?":"&")+"r="+a}; pui.alert=function(b,c,a,d){if(window.cordova&&window.device.platform=="iOS"&&c==null&&a==null&&d==null)window.alert(b);else if(window.navigator!=null&&window.navigator.notification!=null&&window.navigator.notification.alert!=null)if(c==null&&a==null&&d==null&&window.puiMobileClient!=null&&window.puiMobileClient.alert!=null)window.puiMobileClient.alert(b);else{if(c==null)c=function(){};if(a==null)a="Profound UI";if(d==null)d="OK";window.navigator.notification.alert(b,c,a,d)}else pui.pa&&window.parent&& window.parent!=window&&pui.V(window.parent)&&window.parent.noderun?console.log("Suppressed alert: "+b):alert(b)};pui.applyProperty=function(b,c,a){return window.applyProperty(b,c,a)};pui.get=function(b){return I(D(b,void 0))}; pui.set=function(b,c){var a;a=typeof b=="object"?b:document.getElementById(b);if(a!=null){if(a.tagName=="DIV")if(a.A!=null)a.A.setValue(c);else if(a.comboBoxWidget!=null)a.comboBoxWidget.setValue(c);else if(a.h!=null)a.h.setValue(c);else if(a.button&&a.button.T)a.button.T.innerHTML=c;else if(a.pui&&a.pui.widget)applyProperty(a,"value",c);else a.innerHTML=c;else if(a.tagName=="INPUT"||a.tagName=="SELECT"||a.tagName=="TEXTAREA")if(a.tagName=="INPUT"&&a.type=="checkbox")a.checked=typeof c=="boolean"? c:a.checkedValue!=null&&c==a.checkedValue?true:false;else{context=="genie"&&c!=a.value&&pui.f.ra(a);a.value=c;if(a.j!=null)a.j.value=c}if(context=="dspf"||pui.U&&a.l==null){a.modified=true;pui.za(a);var d=a.Aa;if(a.id!=null&&a.id.indexOf(".")==-1&&a.D!=null)pui.ea[a.D]=true;if(d!=null){d.na();d.ga=true;pui.ua(a,d.ia())}}if(context=="genie"&&a.l!=null&&a.l.idx!=null)pui.response[a.l.idx]=a;pui.ca(a);if(a.pui&&a.pui.properties)a.pui.properties.value=c}}; pui.getActiveContainer=function(){if(context=="genie"){for(var b=1,c=document.getElementById("window"+b);c;){var a=document.getElementById("window"+ ++b);if(a)c=a;else break}if(c)return c}else if(context=="dspf"&&pui.L)return pui.L;return pui.runtimeContainer};pui.getDisplayType=function(){return pui.U?"5250-handler":context=="dspf"?"rdf":"5250"}; function P(b){function c(){if(!(l>=j.length)){o=j[l].command;t=j[l].wait;l+=1;if(typeof pui.onPCCommand=="function")try{var k=pui.onPCCommand(o,t);if(k==null||k==true){setTimeout(c,0);return}}catch(r){showFailureMessage(o)}q="?cmd="+encodeURIComponent(o)+"&wait="+(t?"1":"0");if(f==1||f==2)if(i){n.params.cmd=o;n.params.sign=1;n.params.hashalg=typeof pui["pccmd hash sign algorithm"]==="string"?pui["pccmd hash sign algorithm"].toUpperCase():"SHA-512";n.handler=e;B(n)}else a("");else if(f==3){n.params.cmd= o;n.handler=d;B(n)}else{if(l==0&&j.length>0){k=[];for(var p=0;p<j.length;p++)k.push("("+j[p].da+")");o=k.join(" && ")}try{h.runCommand(o)}catch(s){k='Unable to execute "'+o+'".\n\n';if(s!=null)k+=s.name+":\n\n"+s.message+".";alert(k)}}}}function a(k){if(f==2){var r=new Image;r.onload=c;r.onerror=function(){console.log("PC Command Listener image mode failure.");g(o)};r.src=m+q+"&type=image&rnd="+String(Math.random())+String((new Date).getTime())+k}else{k=new pui.Ajax(m+q+k);k.method="GET";k.async= t?false:true;k.suppressAlert=true;k.onfail=function(s){if(s.e()!=200){console.log("PC Command Listener comm. failure: "+s.m());g(o)}};k.onsuccess=function(s){try{var v=JSON.parse(s.d());if(!v.success&&typeof v.error==="string"){console.log("PC Command Listener failure.",v.error);g(o);return}}catch(x){}c()};try{k.send()}catch(p){console.log("PC Command Listener failure.",p);g(o)}}}function d(k,r){try{if(r)throw r;if(k==null)throw Error("Empty response from PCCMD crypt program.");if(k.error!=null|| typeof k.error==="string"&&k.error.length>0)throw Error("PCCMD crypt error: "+String(k.error));if(typeof k.cmd!=="string"||k.cmd.length==0)throw Error("PCCMD crypt response was missing a command.");var p="puilaunch:"+encodeURIComponent(k.cmd),s=document.createElement("iframe");s.style.display="none";s.src=p;document.body.appendChild(s);setTimeout(function(){s!=null&&s.parentNode!=null&&document.body.removeChild(s);s=null;c()},5E3)}catch(v){console.log(v)}}function e(k,r){try{if(r)throw r;if(typeof k!== "object"||k===null)throw Error("Empty response");if(k.success!==true)throw typeof k.error==="string"&&k.error.length>0?k.error:"Unknown error";var p="";if(typeof k.sig==="string"&&k.sig.length>0)p="&sig="+encodeURIComponent(k.sig);a(p)}catch(s){console.log(s);g(o)}}function g(k){console.log("Command: "+k);k=pui.getLanguageText("runtimeMsg","pccommand error");pui["alert pccommand errors"]!==false?alert(k):console.log(k);console.log("Visit https://docs.profoundlogic.com/x/aQFK for more information on supporting STRPCCMD.")} var f=1,i=false;if(pui["use pc listener"])f=1;if(window.HTTPS!=null&&window.HTTPS=="ON"&&f==1)f=2;if(pui["pc listener mode"])f=parseInt(pui["pc listener mode"]);if(typeof pui["pc command mode"]=="string")switch(pui["pc command mode"]){case "applet":f=0;break;case "listener":case "listener_m1":f=1;break;case "listener_m1s":f=1;i=true;break;case "listener_m2":f=2;break;case "listener_m2s":f=2;i=true;break;case "launcher":f=3;break;default:f=1;console.log("Unsupported pc command mode:",pui["pc command mode"])}if(f== 0){var h=document.getElementById("PCCommandApplet");if(!h){pui.s=b;loadPCCommandApplet("runCommandCb");return}}var j=[],l=0;j=typeof b=="string"?[{command:b,wait:false}]:b;b=parseInt(pui["pc listener port"],10);if(isNaN(b))b="80";var m="http://localhost:"+b+"/",q="",o,t,n={url:J("PUI0009117.pgm"),method:"post",params:{auth:pui.appJob&&pui.appJob.auth?pui.appJob.auth:""},async:true};c()}window.runCommandCb=function(){P(pui.s);pui.s=null};pui.runPCCommand=P; pui.isServerBusy=function(){if(typeof context=="undefined")return false;if(context=="dspf"&&pui.q===false||context=="genie"&&pui.f.i===true)return true;for(var b=document.getElementsByTagName("iframe"),c=0;c<b.length;c++){var a=b[c].contentWindow;if(a!=null){var d=null;try{d=a.pui}catch(e){}if(d!=null)if(typeof d==="object")if(typeof d.isServerBusy==="function")if(d.isServerBusy())return true}}return false}; pui.showLastError=function(){if(errors.length==0)alert("No errors have been reported.");else{var b=errors.length-1;alert("Operation: "+errors[b].sa+"\nId: "+errors[b].id+"\n\nMessage: "+errors[b].text+"\n"+errors[b].ya)}}; pui.editCode=function(b,c){function a(u,z){var A=["","","","nn/n","nn/nn","nn/nn/n","nn/nn/nn","nnn/nn/nn","nn/nn/nnnn","nnn/nn/nnnn"];if(i.dateEdit==="*ymd"){A[8]="nnnn/nn/nn";A[9]="nnnnn/nn/nn"}A=A[v];u=String(u);u=u.replace(".","");u=u.replace(",","");u=u.replace("-","");u="0000000000"+u;u=u.substr(u.length-z);var L="/";if(i.dateEditSeparator!=null)L=i.dateEditSeparator;for(var H=false,M=0,N="",F=0;F<A.length;F++){var C=A.substr(F,1),Q=A.substr(F+1,1);if(C==="/"||Q==="/")H=true;if(C==="/")C=L; else{C=u.substr(M,1);M+=1;if(C==="0")H||(C=" ");else H=true}N+=C}return N}function d(u,z,A){for(u+="";u.length<z;)u+=A;return u}var e=null,g=0,f=null,i={},h=2;if(typeof arguments[h]==="number"){e=arguments[h];h++;if(typeof arguments[h]==="number"){g=arguments[h];h++}}if(typeof arguments[h]==="string"){f=arguments[h];h++}if(typeof arguments[h]==="object"){i=arguments[h];h++}var j=false;if(f==="*astfill"){j=true;f=null}var l=false,m=null,q=false,o=h=false;h=" ";if(pui.appJob&&typeof pui.appJob.decimalFormat=== "string")h=pui.appJob.decimalFormat;var t=h==="I"||h==="J",n=h==="J";if(i.decimalEdit!=null){t=i.decimalEdit===","||i.decimalEdit==="0,";n=i.decimalEdit==="0."||i.decimalEdit==="0,"}if(c>="1"&&c<="4")m="999.00";if(c>="A"&&c<="D")m="999.00CR";if(c>="J"&&c<="M")m="999.00-";if(c>="N"&&c<="Q")m="-999.00";if(c=="1"||c=="A"||c=="J"||c=="N"||c=="2"||c=="B"||c=="K"||c=="O")q=true;h=c=="1"||c=="A"||c=="J"||c=="N"||c=="3"||c=="C"||c=="L"||c=="P"?true:false;if(c=="Z")m="999.00";if(c==="X"||c==="Z")o=true;if(c=== "X")l=true;c>="5"&&c<="9"&&pui.alert("User-defined edit code not supported: "+c+".");c>="1"&&c<="9"||c>="A"&&c<="D"||c>="J"&&c<="Q"||c>="X"&&c<="Z"||pui.alert("Invalid edit code: "+c+".");var k=(b||0)+"",r=parseFloat(k,10)||0,p;p=k.replace(/\..*/,"");if(p==="-0")p="-";if((p==""||p=="-")&&n)p="0";var s;s=k;if(s.indexOf(".")==-1)s+=".";s=s.replace(/.*\./,"");var v=p.length;if(v<3)v=3;var x=s.length;if(typeof e==="number")v=e;if(typeof g==="number")x=g;if(c=="Y"){if(v<3||v>9)pui.alert("Length not valid for edit code Y."); return a(r,v)}e=".";if(t)e=",";if(o)e="";if(x>0){s=d(s,x,"0");if(p==="0"&&!n)p="";k=p+e+s}var E=" ";if(l)E="0";if(j)E="*";if(q){for(g=/(\d+)(\d{3})/;g.test(p);)p=p.replace(g,"$1"+(t?".":",")+"$2");k=p+(x>0?e+s:"")}t=r<0;k=k.replace(/-/g,"");if(m==="(999.00)"){if(t)k="("+k+")"}else if(m==="999.00-")k+=t?"-":" ";else if(m==="999.00CR")k+=t?"CR":" ";else if(m==="-999.00")if(t)k="-"+k;if(f)k=f=="EUR"?k+" EUR":f=="$"?k.substr(0,1)=="-"?"-"+f+k.substr(1):f+k:f+k;if(!h)if(r===0)k="";(function(){var u=v; u+=x&&!o?1:0;if(q)u+=parseInt((v-x-1)/3);if(m==="999.00CR")u+=2;if(m==="999.00-")u+=1;if(m==="-999.00")u+=1;if(typeof f==="string")u+=f.length;var z=k;for(z+="";z.length<u;)z=E+z;k=z})();return k}; pui.editWord=function(b,c,a){function d(){if(n.length>0){var p=n.substr(n.length-1,1);n=n.substr(0,n.length-1);if(p=="0"&&n.length==0&&r)p=k?"*":" "}else{p="0";if(r)p=" ";if(k)p="*"}return p}var e,g;b=String(b);var f={};if(typeof a==="object")f=a;a="$";if(f.currencySymbol!=null)a=f.currencySymbol;var i=c.indexOf("0")+1,h=c.indexOf("*")+1;if(i==0||h!=0&&h<i)i=h;var j=-1;for(e=c.length-1;e>=0;e-=1)if(e+1==i||c.substr(e,1)==" "){j=e;break}h=c.substr(0,j+1);var l="",m="",q=false,o=false,t=c.substr(j+ 1).indexOf("-")>=0||c.substr(j+1).indexOf("CR")>=0;for(e=j+1;e<c.length;e++){g=c.substr(e,1);if(c.substr(e,2)=="CR"){o=true;e++}else if(g=="-")o=true;else if(g!="&")if(!(g=="*"&&!o))if(g.toUpperCase()>="A"&&g.toUpperCase()<="Z"&&t&&!o)c=c.substr(0,e)+" "+c.substr(e+1);else{l=c.substring(j+1,e);m=c.substr(e);q=true;break}}q||(l=c.substr(j+1));g=".";e=" ";if(pui.appJob&&typeof pui.appJob.decimalFormat==="string")e=pui.appJob.decimalFormat;if(typeof f.decimalFormat==="string")e=f.decimalFormat;if(e=== "I"||e==="J")g=",";e=0;g=h.split(g);if(g.length>1)e=g[1].replace(/[^ ]/g,"").length;var n;n=isNaN(Number(b))?"0":String(b);n=n.replace("-","");g=n.split(".");f=g[0];c="";j=null;if(g.length>1)c=g[1];if(j==null||isNaN(j))j=e;for(;c.length>j;)c=c.substr(0,c.length-1);for(;j>c.length;)c+="0";for(n=f+c;n.substr(0,1)=="0";)n=n.substr(1);f="";var k=j=false;var r=c=false;if(i==0)r=true;for(e=h.length-1;e>=0;e-=1){q=g=h.substr(e,1);if(g==" ")q=d();else if(g=="&")q=" ";else if(g=="0"&&e+1==i)q=d();else if(g== "*"){k=true;q=d()}else if(g==a){if(e+2==i){q=d();c=true}}else if(j){q=" ";if(k)q="*"}f=q+f;if(e<=i)r=true;if(r&&n.length==0)j=true}l=l.replace(/&/g," ");l=l.replace(/\*/g," ");if(b>=0){l=l.replace("CR"," ");l=l.replace("-"," ")}f=f+l+m;b=f.length-1;f=G(f);if(k&&f.substr(0,1)!="*")f="*"+f;if(c)f=a+f;a=0;if(f[f.length-1]==="-")a=1;for(;f.length<=b;)f=" "+f;return f}; pui.getRadioGroupValue=function(b){if(typeof b!=="string")return null;if(typeof pui.z!=="object")return null;for(var c=null,a=pui.currentFormatNames,d=a.length-1;d>=0;d--){var e=a[d].toUpperCase()+"."+b.toUpperCase();if(typeof pui.z[e]!=="undefined"){c=pui.z[e];break}}if(c==null)return null;b=null;for(a=0;a<c.length;a++){d=c[a];if(d.checked&&d.radioValue!=null){b=d.radioValue;break}}return b};pui.S=function(){for(var b=document.getElementById("auth-form"),c=document.cookie.split("; "),a=false,d=0;d<c.length;d++){var e=c[d].split("=");if(unescape(e[0])=="pui-signon-"+b.action)if(unescape(e[1])=="1"){a=true;break}}if(typeof Storage!="undefined"){c=K();if(c.workstnid)sessionStorage["atrium-params-workstnid"]=c.workstnid;else try{delete sessionStorage["atrium-params-workstnid"]}catch(g){}if(c.suffixid)sessionStorage["atrium-params-suffixid"]=c.suffixid;else try{delete sessionStorage["atrium-params-suffixid"]}catch(f){}if(c.duplicateid)sessionStorage["atrium-params-duplicateid"]= c.duplicateid;else try{delete sessionStorage["atrium-params-duplicateid"]}catch(i){}}if(a)location.href=b.action;else{if(a=document.getElementById("auth-box"))a.style.display="";b.elements["auth-user"].focus()}}; pui.R=function(){var b=document.getElementById("auth-form"),c=b.elements["auth-user"].value,a=b.elements["auth-password"].value,d=document.getElementById("auth-message"),e={"server unavailable":"The server could not be reached at {connectorURL}.<br>Please check your network connection and try again.","error authenticating":"An error occurred while authenticating the user."},g="";d.innerHTML="";if(I(c)==""){d.innerHTML=authMessages["user required"];b.elements["auth-user"].focus();return false}else if(I(a)== ""){d.innerHTML=authMessages["password required"];b.elements["auth-password"].focus();return false}if(pui.pjsServer){var f="Basic "+btoa(I(c)+":"+I(a));fetch("/profoundui/atrium/authenticate",{method:"POST",headers:{Authorization:f}}).then(function(i){if(i.ok){document.cookie=escape("pui-signon-"+b.action)+"=1; path=/";sessionStorage.setItem("atrium-token",btoa(I(c)+":"+I(a)));location.href=b.action}else if(i.status===401){d.innerHTML=authMessages["invalid credentials"];b.elements["auth-user"].focus()}else if(i.status=== 503)i.qa().then(function(h){g=authMessages["server unavailable"]||e["server unavailable"];d.innerHTML=g.replace(/{connectorURL}/,h.xa);b.elements["auth-user"].focus()});else{g=authMessages["error authenticating"]||e["error authenticating"];d.innerHTML=g;b.elements["auth-user"].focus()}})["catch"](function(i){g=authMessages["error authenticating"]||e["error authenticating"];d.innerHTML=g;b.elements["auth-user"].focus();console.error("Error during Atrium authentication:",i)});return false}pui.k(function(){localStorage["pui-http-auth-invalid"]&& delete localStorage["pui-http-auth-invalid"];var i=new pui.Ajax("/profoundui/pui0005010.pgm");i.async=true;i.method="POST";pui.setReqAuth(i,c,a);i.suppressAlert=true;i.onready=function(h){if(h.e()==200){var j=eval("("+h.d()+")");h=j.days;var l=false;if(j.warn==true)if(h==0){j=authMessages["password expired"];pui.alert(j);l=true}else{j=authMessages["password pending expiration"];j=j.replace(/{DAYS}/g,h);l=confirm(j)}if(l){h="/profoundui/changepass";h+="?user="+encodeURIComponent(c);h+="&next="+encodeURIComponent(b.action); h+="&back="+encodeURIComponent(location.href);location.href=h}else{document.cookie=escape("pui-signon-"+b.action)+"=1; path=/";location.href=b.action}}else{d.innerHTML=authMessages["invalid credentials"];b.elements["auth-user"].focus()}};i.send()});return false}; pui.k=function(b){if(Atrium.pjsServer){sessionStorage.removeItem("atrium-token");b()}else{var c=new pui.Ajax("/profoundui/pui0005010.pgm");c.async=typeof b==="function"?true:false;c.method="POST";pui.setReqAuth(c,"PUI_SIGNOFF_USER","PUI_SIGNOFF_USER");c.suppressAlert=true;if(typeof b==="function")c.onready=function(){typeof b=="function"&&b()};c.send()}};window.pui.signOn=pui.R;window.pui.clearCredentials=pui.k;window.pui.signOnInit=pui.S; pui.Q=function(){var b=K(),c=document.getElementById("change-user"),a=document.getElementById("change-current"),d=c,e=document.getElementById("change-cancel");if(typeof b.user!="undefined"){c.value=b.user.toUpperCase();c.readOnly=true;c.className+=" read-only";d=a}if(typeof b.back=="undefined")e.style.display="none";document.getElementById("change-box").style.display="block";d.focus()};pui.P=function(){var b=K();if(typeof b.back!="undefined")location.href=b.back}; pui.C=function(){if(!Atrium.pjsServer){var b=K(),c=document.getElementById("change-form"),a=c.elements["change-user"].value,d=c.elements["change-current"].value,e=c.elements["change-new"].value,g=c.elements["change-confirm"].value,f=document.getElementById("change-message");f.innerHTML="";if(I(a)==""){f.innerHTML=passMessages["user required"];c.elements["change-user"].focus();return false}else if(I(d)==""){f.innerHTML=passMessages["current required"];c.elements["change-current"].focus();return false}else if(I(e)== ""){f.innerHTML=passMessages["new required"];c.elements["change-new"].focus();return false}else if(I(g)==""){f.innerHTML=passMessages["confirm required"];c.elements["change-confirm"].focus();return false}else if(e!=g){f.innerHTML=passMessages["must match"];c.elements["change-new"].focus();return false}g=new pui.Ajax("/profoundui/pui0005011.pgm");g.async=true;g.method="POST";g.params={};g.params.user=a;g.params.current=d;g.params["new"]=e;g.suppressAlert=true;g.onready=function(i){if(i.e()!=200){f.innerHTML= "HTTP "+i.e()+" - "+i.n()+".";c.elements["change-user"].focus()}else{var h;try{h=eval("("+i.d()+")");if(typeof h.success!="boolean")throw Error("Invalid response format: 'success' is not a boolean.");if(!h.success&&typeof h.error!="string")throw Error("Invalid response format: 'error' is not a string.");}catch(j){h={};h.success=false;h.error="The server response is missing or invalid."}if(h.success==false){f.innerHTML=h.error;c.elements["change-user"].focus()}else{pui.alert(passMessages.success); pui.k(function(){var l=new pui.Ajax("/profoundui/pui0005010.pgm");l.async=true;l.method="POST";pui.setReqAuth(l,a,e);l.suppressAlert=true;l.onready=function(m){if(m.e()==200){if(typeof b.next!="undefined")location.href=b.next}else{pui.alert("HTTP "+m.e()+" - "+m.n()+".");c.elements["change-user"].focus()}};l.send()})}}};g.send();return false}}; pui.setReqAuth=function(b,c,a){var d=navigator.userAgent.indexOf("Edge")!=-1,e=!d&&navigator.userAgent.indexOf("Chrome")!=-1;d=!d&&navigator.userAgent.indexOf("Safari")!=-1&&!e;var g=navigator.userAgent.indexOf("Firefox")!=-1;if(d||e||g){b.user=encodeURIComponent(c);b.password=encodeURIComponent(a)}else{b.user=c;b.password=a}};window.pui.passInit=pui.Q;window.pui.passCancel=pui.P;window.pui.changePass=pui.C;