//wlwWeb 1.6.7 // PN2 Lookup Framework function newlookup(type, buttonObj, params) { for (var i = 0; i < buttonObj.form.elements.length; i++) { if (buttonObj.form.elements[i] == buttonObj) { window.open("/WLWWeb/Controller.jpf?type=lookup&field="+escape(type)+"&obj="+escape(buttonObj.form.elements[i-1].name)+"&search="+escape(buttonObj.form.elements[i-1].value)+"&hidden-params="+escape(params),"lookup","dependent=yes,location=no,menubar=no,resizable=yes,personalbar=no,scrollbars=yes,status=yes,toolbar=yes"); } } return false; } function lookup(type, buttonObj) { for (var i = 0; i < buttonObj.form.elements.length; i++) { if (buttonObj.form.elements[i] == buttonObj) { window.open("/WLWWeb/Controller.jpf?type=lookup&field="+escape(type)+"&obj="+escape(buttonObj.form.elements[i-1].name)+"&search="+escape(buttonObj.form.elements[i-1].value),"lookup","dependent=yes,location=no,menubar=no,resizable=yes,personalbar=no,scrollbars=yes,status=yes,toolbar=yes"); } } return false; } //get cookie - helper function function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } //get cookie by name function getCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } //attach event listener to object function addEvent(obj, evType, fn) { if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } //intelligent form clear - clears textfields and textareas, sets dropdown lists to 1st option, unticks checkboxes function clearForm() { var inputs = document.getElementsByTagName('input'); for (var i=0;i 300) { alert('Please enter a zoom level between 30% and 300%'); } else { document.body.style.zoom=val/100; } } //save values of "sticky" fields for future use function saveSearch() { if (!document.getElementsByTagName) { alert ("This feature is not supported on Netscape 4."); return; } //go through input elements var inputs = document.getElementsByTagName('input'); var ff = new Object(); for (var j=0;j 0) ff[inputs[j].name] = inputs[j].value; } if (inputs[j].type=='checkbox' && !inputs[j].readonly && !inputs[j].disabled) { if (inputs[j].className=='sticky') if (inputs[j].checked) ff[inputs[j].name + inputs[j].value] = 'true'; else ff[inputs[j].name + inputs[j].value] = 'false'; } if (inputs[j].type=='radio' && !inputs[j].readonly && !inputs[j].disabled) { if (inputs[j].className=='sticky') if (inputs[j].checked) ff[inputs[j].name] = inputs[j].value; } } inputs = document.getElementsByTagName('textarea'); for (var j=0;j 0 && !inputs[j].readonly && !inputs[j].disabled) ff[inputs[j].name] = inputs[j].value; } inputs = document.getElementsByTagName('select'); for (var j=0;j 0 && !inputs[j].readonly && !inputs[j].disabled) ff[inputs[j].name] = inputs[j].value; } //persist favourite search settings var ffString = ""; for (var ffKey in ff) { if (ffString.length > 0) ffString += "~~~~"; ffString += ffKey + "~~" + ff[ffKey]; } //To check if the cookie has exceeded its maximum size limit of 4KB. var scName = escape(document.title.replace(/\s*/g,"")); var scValue = escape(ffString); var scCurSize = document.cookie.split(';'); var scFnlSize = 0; if (scCurSize.length <= 3) scFnlSize = 0; else { for (var k = 0;k < scCurSize.length - 3;k++) { //Remove white spaces while (scCurSize[k].charAt(0)==' ') scCurSize[k] = scCurSize[k].substring(1,scCurSize[k].length); scFnlSize += scCurSize[k].length; } scFnlSize = (scFnlSize - k) + (k * 74); } var toAddSize = scName.length + scValue.length + 74; if ((scFnlSize + toAddSize) >= 3500) { var scAnswer = confirm("Your cookie has reached its maximum size limit. In order to continue, previous save searches for this web application will be removed. Proceed?"); if (scAnswer) { delCookie(); document.cookie=escape(document.title.replace(/\s*/g,"")) + "=" + escape(ffString) +"; path=/"+escape(document.URL.split("/")[3])+"; expires=Fri, 31 Dec 2010 20:20:20 UTC"; alert("Search saved for future use."); } else{ alert("Search not saved!"); } } else { //Added the WebApp name to this cookie path, so only this WebApp can able to read the cookie back - 20 Apr 06 document.cookie=escape(document.title.replace(/\s*/g,"")) + "=" + escape(ffString) +"; path=/"+escape(document.URL.split("/")[3])+"; expires=Fri, 31 Dec 2010 20:20:20 UTC"; alert("Search saved for future use."); } } var submitted = false; var multiple = false; var childWin; var jsessionid; //apply styles/behaviours after page load function postRender(obj) { //no support for NS4 if (!document.getElementsByTagName) return; //no support for non-HTTP if (window.location.protocol != "http:" && window.location.protocol != "https:") return; //if i am a child, notify my parent that I have loaded. //as a child, don't run postRender() formatting code. if (window.parent != null && window.parent != self) { if (typeof(window.parent.childLoaded) != "undefined") { window.parent.childLoaded(obj); return; } } jsessionid = getCookie("JSESSIONID"); if (jsessionid==null && document.title.indexOf("Error") == -1) { //no cookies, no access location.replace("/WLWWeb/cookie_error.jsp"); return; } //colorize tables var tables = document.getElementsByTagName('table'); for (var i=0;i 0) { document.body.style.zoom=zoomPer/100; inputs[i].value=zoomPer; } //create favourite vessel / voyage dropdown if (inputs[i].type=='text' && inputs[i].className.indexOf('voy')!=-1 & fvvArray.length>0) { var newSelect = document.createElement("select"); //add title var newOption = document.createElement("option"); newOption.text = "-- (favourites) --"; newOption.value = ""; newOption.style.cssText="color:#aaaaaa"; newSelect.options.add(newOption); //sort vsls/voys alphabetically and add var fvvSortArray = new Array(); for (var j = 0; j < fvvArray.length; j++) { fvvSortArray[j] = fvvArray[j]; } fvvSortArray.sort(); for (var j = 0; j < fvvArray.length; j++) { newSelect.options[newSelect.options.length] = new Option(fvvSortArray[j],fvvSortArray[j]); } //add onchange handler to the select to populate the textfields newSelect.vsl = inputs[i - 1]; for (var j = i - 1; j >= 0; j--) { if (inputs[j].className.indexOf('vsl') != -1) { newSelect.vsl = inputs[j]; break; } } newSelect.voy = inputs[i]; newSelect.onchange = function () { if (this.value!=null && this.value.length > 0) { this.vsl.value = this.value.split(" / ")[0]; this.voy.value = this.value.split(" / ")[1]; } else { this.vsl.value = ""; this.voy.value = ""; } } ; //add to DOM inputs[i].parentNode.appendChild(document.createTextNode(" ")); inputs[i].parentNode.appendChild(newSelect); } } //for textarea elements, add handler to uppercase & trim //populate favourite search inputs = document.getElementsByTagName('textarea'); for (var i=0;i= 0; k--) { if (inputs[k].className.indexOf('vsl') != -1) { currVsl = inputs[k].value; break; } } var currVoy = inputs[j].value; if (currVsl.length > 0 && currVoy.length > 0) { var currVslVoy = currVsl + " / " + currVoy; //move duplicates to front of queue for (var k = 0; k < fvvArray.length; k++) { if (fvvArray[k] == currVslVoy) { fvvArray.splice(k,1); } } fvvArray[fvvArray.length] = currVslVoy; if (fvvArray.length > 10) { fvvArray.splice(0, fvvArray.length - 10); } } } else if (inputs[j].name=="pagezoom") { // Added on 12 May 06 // Save the user's page zoom customization to "pgzoom" cookie // If user change the page zoom back to 100, // this part delets the existing "pgzoom" cookie var zoomVal = inputs[j].value; if(zoomVal != 100) { document.cookie="pgzoom=" +escape(zoomVal)+"; expires=Fri, 31 Dec 2010 20:20:20 UTC"; } else { if(getCookie("pgzoom") != null) { expiryDate=new Date(); expiryDate.setDate(expiryDate.getDate()-1); document.cookie="pgzoom="+escape(zoomVal)+"; expires="+expiryDate.toGMTString(); } } } } } inputs = document.getElementsByTagName('textarea'); for (var j=0;j\n' + window.rpc.document.documentElement.innerHTML + '\n'; childWin.document.open('text/html'); childWin.document.write(newHTML); childWin.document.close(); childWin.focus(); submitted = false; } else { if (typeof(childWin)!="undefined" && childWin!=null) { childWin.close(); childWin=null; } var newHTML = '<' + window.rpc.document.documentElement.tagName + '>\n' + window.rpc.document.documentElement.innerHTML + '\n'; var newDoc = document.open("text/html", "replace"); newDoc.write(newHTML); newDoc.close(); } } // This function will trigger a warning to the user to extend the session, once n millisecs have passed. function prepareTimeoutWarning() { if (top.nav != null) { clearTimeout(); // reset the timer setTimeout('displayTimeoutWarning()', 45 * 1000 * 60); // display timeout warning after n millisecs of inactivity, n = 45 * 1000 * 60 (or 45 minutes) } } // This function warns the user to extend the session to avoid being logged out. // If the user responds 'Ok' within x millisecs, the session will be extended and the timeout warning will be resetted. // Else if the user responds 'Cancel' within x millisecs, the session(s) will be invalidated and the user would see the logout page. // Else if the user does not respond within x millisecs, the user would see the timeout page. function displayTimeoutWarning() { if (top.nav != null) { var before = new Date(); var answer = window.confirm("Your session will be terminated in 15 minutes. \nPlease respond to avoid being logged out. \nWould you like to continue?"); var now = new Date(); if (now.getTime() - before.getTime() < 15 * 1000 * 60) // x millisecs before actual user session timeout, x = 15 * 1000 * 60 (or 15 minutes) { if (answer) { top.nav.location.reload(); // refresh the session if he would like to continue prepareTimeoutWarning(); // re-prepare for session timeout warning } else { top.location.replace('/MENUWeb/com/pn2/menu/web/logout.do'); // log the user out normally (i.e. invalidate sessions) if he does not wish to continue } } else { top.location.replace('/WebPublic/timeout.jsp'); // log the user out nonetheless (i.e. sessions already timed out) } } } //This enables the autoTab function. function autoTab(eCtrl, e) { var agent = navigator.userAgent.toLowerCase(); var isNN = (agent.indexOf("netscape")!=-1); var keyCode; var filter; if (isNN) { keyCode = e.which; filter = [0,8,9]; }else{ keyCode = e.keyCode; filter = [0,8,9,16,17,18,37,38,39,40,46]; } if (eCtrl.value.length >= eCtrl.getAttribute("maxlength") && !containsElement(filter,keyCode)) { eCtrl.value = eCtrl.value.slice(0, eCtrl.getAttribute("maxlength")); eCtrl.form[(getIndex(eCtrl)+1) % eCtrl.form.length].focus(); } function containsElement(arr, ele) { var found = false, index = 0; while (!found && index < arr.length) if (arr[index] == ele) found = true; else index++; return found; } function getIndex(eCtrl) { var index = -1, i = 0, found = false; while (i < eCtrl.form.length && index == -1) if (eCtrl.form[i] == eCtrl) index = i; else i++; return index; } return true; } //Delete all existing cookies. function delCookie() { var ca = document.cookie.split(';'); for(var i=0;i < ca.length - 3;i++) { //Remove white spaces while (ca[i].charAt(0)==' ') ca[i] = ca[i].substring(1,ca[i].length); var ckname = ca[i].split('='); var expires = -1; var value = ""; var cookie_date = new Date ( ); cookie_date.setTime ( cookie_date.getTime() - 1 ); document.cookie=escape(ckname[0]) + "=; path=/"+escape(document.URL.split("/")[3])+"; expires=" + cookie_date.toGMTString(); } }