/** */ function clipboard(value) { navigator.clipboard.writeText(value); } /** */ function isValid(value) { return value != null && value != ""; } /** */ function addClass(id, thisClass) { var item = document.getElementById(id); if( item != null ) { var regex = new RegExp("(^| )" + escapeRegExp(thisClass) + "( |$)", "g"); if( item.className.match(regex) == null ) { item.className = (item.className + " " + thisClass).trim(); return 1; } } return 0; } /** */ function removeClass(id, thisClass) { var item = document.getElementById(id); if( item != null ) { var regex = new RegExp("(^| )" + escapeRegExp(thisClass) + "( |$)", "g"); if( item.className.match(regex) != null ) { item.className = item.className.replace(regex, " ").trim(); return 1; } } return 0; } /** */ function toggleClass(id, thisClass) { var item = document.getElementById(id); if( item != null ) { var regex = new RegExp("(^| )" + escapeRegExp(thisClass) + "( |$)", "g"); if( item.className.match(regex) == null ) { addClass(id, thisClass); return 1; } else { removeClass(id, thisClass); return 1; } } return 0; } /** */ function toggleClasses(id, class1, class2) { var item = document.getElementById(id); if( item != null ) { var regex1 = new RegExp("(^| )" + escapeRegExp(class1) + "( |$)", "g"); var regex2 = new RegExp("(^| )" + escapeRegExp(class2) + "( |$)", "g"); var has1 = item.className.match(regex1) != null; var has2 = item.className.match(regex2) != null; if( has1 && has2 ) { removeClass(id, class2); } else if( has1 ) { removeClass(id, class1); addClass(id, class2); } else if( has2 ) { removeClass(id, class2); addClass(id, class1); } else { addClass(id, class1); } } } /** */ async function collapse(id) { /* // need to cater for instand resizing when invisible, ie setting transition durations to zero addClass(id, 'collapsible-content'); var item = document.getElementById(id); if( !item.style.height && item.clientHeight > 0 ) { item.style.height = item.clientHeight + 'px'; item.setAttribute('tempHeight', true); } var regex = new RegExp("(^| )" + escapeRegExp('collapsed-content') + "( |$)", "g"); if( item.className.match(regex) == null ) { await sleep(0); addClass(id, 'collapsing-content'); await sleep(150); addClass(id, 'collapsed-content'); // removeClass(id, 'collapsing-content'); } */ addClass(id, 'collapsed-content'); } /** */ async function expand(id) { /* addClass(id, 'collapsible-content'); var item = document.getElementById(id); if( !item.style.height && item.clientHeight > 0 ) { item.style.height = item.clientHeight + 'px'; item.setAttribute('tempHeight', true); } var regex = new RegExp("(^| )" + escapeRegExp('collapsed-content') + "( |$)", "g"); if( item.className.match(regex) != null ) { // addClass(id, 'collapsing-content'); removeClass(id, 'collapsed-content'); removeClass(id, 'collapsing-content'); await sleep(150); } if( item.getAttribute('tempHeight') ) { item.removeAttribute('tempHeight'); item.style.height = null; } */ removeClass(id, 'collapsed-content'); } /** */ function toggleCollapsed(id) { var item = document.getElementById(id); var regex = new RegExp("(^| )" + escapeRegExp('collapsed-content') + "( |$)", "g"); if( item.className.match(regex) == null ) { collapse(id); } else { expand(id); } } /** */ function escapeRegExp(value) { return value.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\$&'); } /** * Determine number from string */ function getNumber(value) { result = 0; if( value != null && value != '' && !isNaN(value) ) result = parseFloat(value) return result; } /** * Round to the specified value to given number of decimal places */ function roundNumber(value, decimalPlaces) { if( isNaN(value) ) value = getNumber(value); if( isNaN(decimalPlaces) ) decimalPlaces = getNumber(decimalPlaces); if( decimalPlaces < 0 ) decimalPlaces = 0; var factor = Math.pow(10,decimalPlaces); result = Math.round(value*factor)/factor; return result; } /** * Returns value as a string rounded to specified number of decimal places */ function setDecimalPlaces(value, decimalPlaces) { if( isNaN(decimalPlaces) ) decimalPlaces = getNumber(decimalPlaces); result = "" + roundNumber(value, decimalPlaces); var decimalIndex = result.indexOf("."); if( decimalPlaces > 0 ) { if( decimalIndex == -1 ) { result += "."; decimalIndex = result.indexOf("."); } while( (result.length-decimalIndex-1) < decimalPlaces ) { result += "0"; decimalIndex = result.indexOf("."); } } return result; } /** * Toggle the visibility of an element */ function toggleVisibility(elementId) { var thisElement = document.getElementById(elementId); setVisibility(elementId, (thisElement.style.display == 'none' ? true : false) ) } /** * Set the visibility of an element */ function setVisibility(elementId, isVisible) { var thisElement = document.getElementById(elementId); thisElement.style.display = (isVisible ? '' : 'none'); } /** * Set the visibility of all matching elements */ function setVisibilityForAll(elementIdRegex, isVisible) { var theseElements = document.getElementsByTagName('*'); for( var i=0; i < theseElements.length; i++ ) { if( theseElements[i].id.match(elementIdRegex) ) setVisibility(theseElements[i].id, isVisible); } } /** * Checks if this is a single click, will only return true once every 2 seconds * or more. A purpose for this function is to make sure that html forms are * only called once within the time period which can be done by by placing * onSubmit="return isSingleClick()" in the form tag. */ var hasBeenCalled = false; function isSingleClick() { if( hasBeenCalled ) return false; hasBeenCalled = true; setTimeout("hasBeenCalled = false;", 500); return true; } /** * Checks if the showExitAlert flag has been set, and shows a warning to the * user if so in order to advise them theat they may have unsaved work on the * page. This will provide the option for remaining onthe page. */ var showExitAlert = false; window.onbeforeunload = confirmExit; function confirmExit() { if( showExitAlert ) return "You may have unsaved activity on this page."; } /** * Get Window Width */ function getWindowWidth() { return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0; } /** * Get Window Height */ function getWindowHeight() { return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0; } /** * Get Document Width */ function getDocumentWidth() { var bd = document.body; var ht = document.documentElement; return Math.max( bd.scrollWidth, bd.offsetWidth, ht.clientWidth, ht.scrollWidth, ht.offsetWidth ); } /** * Get Document Height */ function getDocumentHeight() { var bd = document.body; var ht = document.documentElement; return Math.max( bd.scrollHeight, bd.offsetHeight, ht.clientHeight, ht.scrollHeight, ht.offsetHeight ); } /** * Get viewport X offset */ function getViewportXOffset(){ if( typeof window.pageXOffset != 'undefined' ) { return window.pageXOffset; } else { return (document.documentElement.clientWidth ? document.documentElement.scrollLeft : document.body.scrollLeft); } } /** * Get viewport Y offset */ function getViewportYOffset() { if( typeof window.pageYOffset != 'undefined' ) { return window.pageYOffset; } else { return (document.documentElement.clientHeight ? document.documentElement.scrollTop : document.body.scrollTop); } } /** * Send http GET request */ function sendHttpGetRequest(url) { var thisXMLHttpRequest = getXmlHttpObject(); if( thisXMLHttpRequest != null ) { thisXMLHttpRequest.open("GET", url, true); thisXMLHttpRequest.send(); } } /** * Send http POST request */ function sendHttpPostRequest(url, postData) { var thisXMLHttpRequest = getXmlHttpObject(); if( thisXMLHttpRequest != null ) { thisXMLHttpRequest.open("POST", url, true); thisXMLHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); thisXMLHttpRequest.send(postData); } } /** * Get xml http object */ function getXmlHttpObject(handler) { var thisXMLHttpRequest = null; if( window.XMLHttpRequest ) thisXMLHttpRequest = new XMLHttpRequest(); else if( window.ActiveXObject ) thisXMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); return thisXMLHttpRequest; } /** * Get url parameter value */ function getRequestParameter(parameter) { parameter = parameter.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + parameter + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if( results == null ) { return null; } else { return decodeURIComponent(results[1].replace(/\+/g, " ")); } } /** * Decode common html entities */ function htmlEncode(value) { return ('' + value).replace(//g, '>').replace(/"/g, '"'); } /** * Make a field enabled, ensure it has no onclick function then focus it */ function enableField(targetField) { if( targetField.readOnly ) { targetField.onclick = null; targetField.readOnly = false; targetField.focus(); targetField.select(); return true; } else { return false; } } /** * Sleep for given milliseconds, use with await sleep(millis) inside an async function */ function sleep(millis) { return new Promise(resolve => setTimeout(resolve, millis)); } /** * Wait for given milliseconds, processor intensive... */ function wait(millis) { var inDate = new Date(); var then = inDate.getTime(); var now = inDate.getTime(); do { var outDate = new Date(); var now = outDate.getTime(); } while( now < (then+millis) ); return; } /* SORTABLE TABLES */ var sortableTables = new Array(); var sortableMonths = new Array("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"); /** */ function sortableInit() { if( !document.getElementsByTagName ) return; sortableCheckTables = document.getElementsByTagName("table"); for( var i=0; i < sortableCheckTables.length; i++ ) { if( sortableCheckTables[i].className.indexOf("sortable") != -1 ) sortablePrepareTable(sortableCheckTables[i]); } } /** */ function sortablePrepareTable(sortableTable) { if( sortableTable == null || sortableTable.id == null || sortableTable.id == "" ) { console.log("Sortable tables require 'id' attribute to be set"); return; } if( sortableTable.rows == null || sortableTable.rows.length < 1 ) return; if( sortableTable.rows[0].cells == null || sortableTable.rows[0].cells.length < 1 ) return; sortableTables[sortableTables.length] = new Array(); sortableTables[sortableTables.length-1][0] = sortableTable.id; sortableTables[sortableTables.length-1][1] = new Array(); sortableTables[sortableTables.length-1][2] = -1; // Last sort column // Check for default sort var sortBy = sortableTextValue(getRequestParameter("sortBy")); var sortByReverse = false; if( sortBy.indexOf("-") == 0 ) { sortByReverse = true; sortBy = sortBy.substring(1); } var sortByIndex = null; // Assume first row is header, modify with options for( var i=0; i < sortableTable.rows[0].cells.length; i++ ) { if( sortBy != null && sortBy != "" && sortBy == sortableCellValue(sortableTable.rows[0].cells[i]) ) sortByIndex = i; sortableTable.rows[0].cells[i].innerHTML = "" + sortableTable.rows[0].cells[i].innerHTML + ""; } // Iterate and record parsed cell values in an array for( var i=1; i < sortableTable.rows.length; i++ ) { sortableTables[sortableTables.length-1][1][i-1] = new Array(); var sortableTableRow = document.createElement('tr'); sortableTableRow.className = sortableTable.rows[i].className; for( var j=0; j < sortableTable.rows[i].cells.length; j++ ) { sortableTables[sortableTables.length-1][1][i-1][j] = sortableCellValue(sortableTable.rows[i].cells[j]); var sortableTableRowCell = sortableTableRow.insertCell(-1); sortableTableRowCell.innerHTML = sortableTable.rows[i].cells[j].innerHTML; } // Store the whole row sortableTables[sortableTables.length-1][1][i-1][sortableTable.rows[i].cells.length] = sortableTableRow; } // Check for a default sort if( sortByIndex == null && sortableTable.className.indexOf("sortOnLoad") != -1 ) sortByIndex = 0; if( sortByIndex != null ) sortableAction(sortableTable.id, sortByIndex, sortByReverse); } /** */ function sortableCellValue(sortableCell) { // Determine sortable value var sortableValue = sortableCell.innerHTML.toLowerCase().replace(/^\s+/g, '').replace(/\s+$/g, '').replace(/<[^>]*>/g, '').replace(/\s+/g, ' '); return sortableTextValue(sortableValue); } /** */ function sortableTextValue(sortableValue) { if( sortableValue == null ) return ""; // Check for date formats and convert to chronological number // European dates will match before US dates if( sortableValue.match(/([0123]\d)[\-\/]([01]?\d)[\-\/](\d\d\d\d)/) ) { // dd-mm-yyyy sortableValue = "date-" + sortableConvertMonths(sortableValue).replace(/([0123]\d)[\-\/]([01]?\d)[\-\/](\d\d\d\d)/, "$3/$2/$1"); } else if( sortableValue.match(/([01]?\d)[\-\/]([0123]+\d)[\-\/](\d\d\d\d)/) ) { // mm-dd-yyyy sortableValue = "date-" + sortableConvertMonths(sortableValue).replace(/([01]?\d)[\-\/]([0123]+\d)[\-\/](\d\d\d\d)/, "$3/$1/$2"); } else if( sortableValue.match(/([0123]?\d)[\-\/]([a-z][a-z][a-z]+)[\-\/](\d\d\d\d)/) ) { // dd-MMM-yyyy sortableValue = "date-" + sortableConvertMonths(sortableValue.replace(/([0123]?\d)[\-\/]([a-z][a-z][a-z]+)[\-\/](\d\d\d\d)/, "$3/$2/$1")); } else if( sortableValue.match(/([a-z][a-z][a-z]+)[\-\/]([0123]?\d)[\-\/](\d\d\d\d)/) ) { // MMM-dd-yyyy sortableValue = "date-" + sortableConvertMonths(sortableValue.replace(/([a-z][a-z][a-z]+)[\-\/]([0123]?\d)[\-\/](\d\d\d\d)/, "$3/$1/$2")); } // return result return sortableValue; } /** */ function sortableAction(sortableTableId, sortableTableColumn, sortableTableColumnReverse) { for( var i=0; i < sortableTables.length; i++ ) { if( sortableTables[i][0] = sortableTableId ) { // Create sortable array with the relevant column and cells var sortableResults = new Array(); for( var j=0; j < sortableTables[i][1].length; j++ ) { sortableResults[sortableResults.length] = new Array(sortableTables[i][1][j][sortableTableColumn], sortableTables[i][1][j][sortableTables[i][1][j].length-1]); } if( sortableTables[i][2] == sortableTableColumn || sortableTableColumnReverse) { sortableResults.sort(sortableReverseComparison); sortableTables[i][2] = -1; } else { sortableResults.sort(sortableComparison); sortableTables[i][2] = sortableTableColumn; } // Replace old data var sortableTable = document.getElementById(sortableTableId); if( sortableResults.length == sortableTable.rows.length-1 ) { for( var k=0; k < sortableResults.length; k++ ) { for( var l=0; l < sortableTable.rows[k+1].cells.length; l++ ) { sortableTable.rows[k+1].cells[l].innerHTML = sortableResults[k][1].cells[l].innerHTML; } sortableTable.rows[k+1].className = sortableResults[k][1].className; } } } } } /** */ function sortableComparison(sortableRow1, sortableRow2) { var sortableValue1 = sortableRow1[0]; var sortableValue2 = sortableRow2[0]; if( !isNaN(sortableValue1) && !isNaN(sortableValue2) ) { // Number comparison return getNumber(sortableValue1)-getNumber(sortableValue2); } else if( sortableValue1 == sortableValue2 ) { return 0; } else { return (sortableValue1 < sortableValue2 ? -1 : 1); } return 0; } /** */ function sortableReverseComparison(sortableRow1, sortableRow2) { return sortableComparison(sortableRow1, sortableRow2)*-1; } /** */ function sortableConvertMonths(sortableValue) { var sortableYear = getNumber(sortableValue.replace(/(.+)\/(.+)\/(.+)/, "$1")); var sortableMonth = getNumber(sortableValue.replace(/(.+)\/(.+)\/(.+)/, "$2")); var sortableDay = getNumber(sortableValue.replace(/(.+)\/(.+)\/(.+)/, "$3")); if( sortableMonth < 1 ) { var sortableMonthName = sortableValue.replace(/(.+)\/(.+)\/(.+)/, "$2"); for( var i=0; i < sortableMonths.length; i++ ) { if( sortableMonthName.indexOf(sortableMonths[i]) != -1 ) { sortableMonth = i+1; break; } } } return "" + (sortableYear < 10 ? "0" : "") + sortableYear + (sortableMonth < 10 ? "0" : "") + sortableMonth + (sortableDay < 10 ? "0" : "") + sortableDay; } sortableInit(); /* MODALS */ // Global variables var modalType; var modalValue; var modalTargetField; var modalTargetDisplayField; var modalWidth = 0; var modalHeight = 0; var modalTransparent = false; // Initiator variables var modalDate; var modalOrigDate; var modalWeekDays = new Array("S", "M", "T", "W", "T", "F", "S"); var modalMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); /* Initiators */ /** */ function showModalAccount(modalField, modalDisplayField) { modalType = "account"; modalTargetField = modalField; modalTargetDisplayField = modalDisplayField; modalWidth = 0; modalHeight = 0; modalTransparent = false; modalShow(); } /** */ function showModalDay(modalField) { modalType = "day"; modalTargetField = modalField; modalWidth = 0; modalHeight = 0; modalTransparent = false; modalShow(); } /** */ function showModalMonth(modalField) { modalType = "month"; modalTargetField = modalField; modalWidth = 0; modalHeight = 0; modalTransparent = false; modalShow(); } /** */ function showModalYear(modalField) { modalType = "year"; modalTargetField = modalField; modalWidth = 0; modalHeight = 0; modalTransparent = false; modalShow(); } /** */ function showModalSpinner() { showModalContent('
', -1, -1, true); } /** */ function showModalUrl(url, modalDisplayWidth, modalDisplayHeight) { modalType = "url"; modalValue = url; modalWidth = modalDisplayWidth; modalHeight = modalDisplayHeight; modalTransparent = false; modalShow(); } /** */ function showModalContent(content, modalDisplayWidth, modalDisplayHeight, modalDisplayTransparent) { modalType = "content"; modalValue = content; modalWidth = modalDisplayWidth; modalHeight = modalDisplayHeight; modalTransparent = modalDisplayTransparent; modalShow(); } /* Core */ /** */ function modalShow() { var modalElement = document.getElementById("modalElement"); if( modalElement != null ) { modalHide(); } if( modalType != null ) { if( modalTargetField != null ) { if( "day" == modalType || "month" == modalType || "year" == modalType ) { // Pre population modalDate = null; // Do we have an old value var modalDateArray = modalTargetField.value.split(/\//); if( modalDateArray.length == 1 ) modalDateArray.unshift("Jan"); if( modalDateArray.length == 2 ) modalDateArray.unshift("01"); if( modalDateArray.length == 3 ) modalDate = new Date(Date.parse(modalDateArray[1] + " " + modalDateArray[0] + ", " + modalDateArray[2])); } if( modalDate == null || isNaN(modalDate.getTime()) ) modalDate = new Date(); modalOrigDate = new Date(modalDate.getTime()); modalDate.setDate(1); } modalRedraw(); } } /** */ function modalRedraw() { modalHide(); var includeSearchText = false; // Add backgroud modalBackground = document.createElement('div'); modalBackground.setAttribute("id", "modalBackground"); modalBackground.style.position = "fixed"; modalBackground.style.top = "0"; modalBackground.style.left = "0"; modalBackground.style.width = "100%"; modalBackground.style.height = "100%"; modalBackground.style.overflow = "hidden"; modalBackground.style.color = "#444444"; modalBackground.style.backgroundColor = "#f2f2f2CC"; modalBackground.style.zIndex = "1001"; modalBackground.innerHTML = "
"; document.body.appendChild(modalBackground); // Add modal content modalElement = document.createElement('div'); modalElement.setAttribute("id", "modalElement"); modalElement.className = "position-middle-center " + (modalTransparent ? "container" : "elevated impact module" + (modalWidth == null || modalWidth < 0 ? " adaptable-quadruple-width" : "")); if( modalWidth != null && modalWidth > 0 ) modalElement.style.width = modalWidth + "px"; if( modalHeight != null && modalHeight > 0 ) modalElement.style.height = modalHeight + "px"; modalElement.style.overflow = "auto"; // Set content if( modalType == "account" ) { modalValue = "
"; modalValue += ""; modalValue += ""; modalValue += "
"; modalValue += "
"; includeSearchText = true; } else if( modalType == 'year' ) { modalValue = "
"; modalValue += ""; modalValue += ""; modalValue += ""; modalValue += "
"; } else if( modalType == 'month' ) { modalValue = "
"; modalValue += ""; modalValue += ""; modalValue += ""; modalValue += "
"; } else if( modalType == "day" ) { modalValue = ""; modalValue += ""; modalValue += ""; modalValue += ""; modalValue += ""; modalValue += ""; modalValue += "
"; // Headings for( var i=0 ; i < modalWeekDays.length; i++ ) modalValue += "
0 && i < 6 ? "half-wide" : "one-quarter-wide transparent-content") + "\">" + modalWeekDays[i] + "
"; modalValue += "
"; // Month start var modalDisplayDate = new Date(modalDate.getTime()); modalDisplayDate.setDate(1); for( var w=0; w < 6; w++ ) { for( var d=0; d < 7; d++ ) { if( modalDisplayDate.getMonth() != modalDate.getMonth() || (w == 0 && d < modalDisplayDate.getDay() ) ) { modalValue += "
0 && d < 6 ? "half" : "one-quarter") + "-wide transparent-content click-container\">•
"; } else { var modalHighlightDate = (modalOrigDate.getDate() == modalDisplayDate.getDate() && modalOrigDate.getMonth() == modalDisplayDate.getMonth() && modalOrigDate.getYear() == modalDisplayDate.getYear()); modalValue += " 0 && d < 6 ? "half-wide" : "one-quarter-wide transparent-content") + " click-button" + (modalHighlightDate ? " warning" : "") + "\">" + modalDisplayDate.getDate() + ""; modalDisplayDate.setDate(modalDisplayDate.getDate()+1); } } modalValue += "
"; } } modalElement.innerHTML = (modalType != 'url' ? modalValue : "") + "
" + (includeSearchText ? "Search " + modalType + "..." : "") + "
"; document.getElementById('modalContainer').appendChild(modalElement); // External content if( modalType === "url" && modalValue != null ) { modalDisplay("
Loading...
"); try { xmlHttp = getXmlHttpObject(); if( xmlHttp != null ) { xmlHttp.onreadystatechange = modalReceive; xmlHttp.open("GET", modalValue, true); xmlHttp.send(); } } catch(ex) { modalDisplay("
" + ex.description + "
"); } } // If there is a modal search field, select it var modalSearchValueField = document.getElementById('modalSearchValue'); if( modalSearchValueField != null ) { try { modalSearchValueField.focus(); } catch(ex) { // Ignore } } } /** */ function modalReceive() { if( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { try { modalDisplay(xmlHttp.responseText); } catch(ex) { modalDisplay("
" + ex.description + "
"); } } } /** */ function modalDisplay(value) { document.getElementById('modalDynamicContainer').innerHTML = value; } /** */ function modalHide() { var modalElement = document.getElementById("modalElement"); if( modalElement != null ) modalElement.parentNode.removeChild(modalElement); var modalBackground = document.getElementById("modalBackground"); if( modalBackground != null ) modalBackground.parentNode.removeChild(modalBackground); } /** */ function modalHandleClick() { if( 'modalContainer' === event.target.id ) modalHide(); } /* Set field value */ /** */ function modalSet(modalSetValue) { modalSet(modalSetValue, null); } /** */ function modalSet(modalSetValue, modalSetTitle) { if( modalSetTitle == null || modalSetTitle == '' ) modalSetTitle = modalSetValue; modalSetField(modalSetValue); modalSetDisplayField(modalSetTitle); modalHide(); } /** */ function modalSetField(value) { if( modalTargetField != null ) { modalTargetField.value = value; try { modalTargetField.onchange(); } catch(ex) { // Ignore } } } /** */ function modalSetDisplayField(value) { if( modalTargetDisplayField != null ) { modalTargetDisplayField.value = value; try { modalTargetDisplayField.onchange(); } catch(ex) { // Ignore } } } /* Account */ /** */ function modalSearchAccount(value) { try { xmlHttp = getXmlHttpObject(); if( xmlHttp != null ) { xmlHttp.onreadystatechange = modalSearchAccountReceive; xmlHttp.open("GET", "/api/account/?search=" + encodeURIComponent(value), true) xmlHttp.send() } } catch(ex) { modalDisplay("
" + ex.description + "
"); } } /** */ function modalSearchAccountReceive() { if( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { try { var modalSearchResults = null; var modalSearchMessages = null; var json = eval("(" + xmlHttp.responseText + ")"); if( json != null ) { if( json.results != null ) modalSearchResults = json.results; if( json.messages != null ) modalSearchMessages = json.messages; } // Show results var modalDisplayContent = "

"; if( modalSearchMessages != null && modalSearchMessages.length > 0 ) { modalDisplayContent += "

"; for( var i=0; i < modalSearchMessages.length; i++ ) modalDisplayContent += "

" + htmlEncode(modalSearchMessages[i].message) + "

"; modalDisplayContent += "

"; } if( modalSearchResults != null && modalSearchResults.length > 0 ) { for( var i=0; i < modalSearchResults.length; i++ ) modalDisplayContent += "" + htmlEncode(modalSearchResults[i].first_name) + " " + htmlEncode(modalSearchResults[i].last_name) + "
"; } modalDisplayContent += "

"; modalDisplay(modalDisplayContent); } catch(ex) { modalDisplay("
" + ex.description + "
"); } } } /* Calendar */ /** */ function modalRollMonth(increment) { if( modalDate == null ) return; modalDate.setMonth(modalDate.getMonth() + increment); modalRedraw(); } /** */ function modalRollYear(increment) { if( modalDate == null ) return; modalDate.setYear(modalDate.getFullYear() + increment); modalRedraw(); } /** */ function modalSetDay(modalSetDayOfMonth) { modalSetField(modalSetDayOfMonth + "/" + modalMonths[modalDate.getMonth()] + "/" + modalDate.getFullYear()); modalHide(); } /** */ function modalSetMonth() { modalSetField(modalMonths[modalDate.getMonth()] + "/" + modalDate.getFullYear()); modalHide(); } /** */ function modalSetYear() { modalSetField(modalDate.getFullYear()); modalHide(); } /* Commodity */ /** */ window.onresize = function() { var modalElement = document.getElementById("modalElement"); if( modalElement != null ) modalRedraw(); }