// function sleep(ms) { // return new Promise(res => setTimeout(res, ms)); // } /* this is custum alert without title */ window.alert = function aalert(msg) { // zeev: this is no working well when we reload the page, the msg disappear too fast so i replace is with the app.alert below if (typeof msg != 'undefined') { bootbox.alert({ message: msg, backdrop: true }); } // var alertType='info'; // var alerticon='info'; // if (msg.toLowerCase().indexOf('error')>-1 || msg.toLowerCase().indexOf('faile')>-1 || msg.indexOf('שגיאה')>-1){ // alertType='danger' // alerticon='warning' // } // if (msg.toLowerCase().indexOf('success')>-1 || msg.indexOf('הצלחה')>-1){ // alertType='success' // alerticon='check' // } // // App.alert({ // container: $('#alert_container').val(), // alerts parent container // place: 'Prepend', // place: 'append'/'Prepend' // message: ' ' + msg, // closeInSeconds: 10, // auto close after defined seconds // type: alertType, // alert's type // reset: false, // close all previouse alerts first // close: true, // make alert closable // icon:alerticon, // focus: true, // auto scroll to the alert after shown // });// put icon class before the message // await sleep(4000); } function isMobile() { if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { return true; } return false } function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } /* This is the global javascript code used by this site */ /* Defenition of global variables */ //Defenition of globals and methods for working with show and hide values /*Array to be used to store for each field a list of fields to hide or show for a change in a given field, the arary will be used as a has table the key for the hash table is the name of the field and the values will be arrays wich will hold the designated value, the id of the group and true/false for show and hide*/ var showList = new Array(); //CONST TO BE USED AS PLACE HOLDERS FOR TRIPLET MEMEBER TYPE var FLD_VALUE=0; var FLD_GROUP=1; var FLD_ShowOrHide=2; var FLD_NonExclusive=3; function addShowListMemeber(field,value,group,ShowOrHide,NonExclusive){ var valArr = new Array(); if (!showList[field] || !isArray(showList[field])) showList[field] = new Array(); valArr[FLD_VALUE]=value; valArr[FLD_GROUP]=group; valArr[FLD_ShowOrHide]=ShowOrHide; valArr[FLD_NonExclusive] = (NonExclusive == 'True'); /** this option is cancelled. if the rule not met - do nothing - 15/11/2016**/ //valArr[FLD_NonExclusive] = true; showList[field][showList[field].length] = valArr; //Add item to list return; } /* this array will hold a list of memebers that belong to the same show / hide group */ var showGroupList = new Array(); function addShowGroupMember(group,sendAnyway,field) { if (!showGroupList[group] || !isArray(showGroupList[group])) showGroupList[group] = new Array(); //Append field to the end of the list showGroupList[group][showGroupList[group].length] = {field:field,sendAnyway:sendAnyway}; return; } //This function will go over the show and hide groups and will show and hide fields on form acordingly function showAndHideForField(fld_id){ var index = 0 //Check if there is a list for this field if (!showList[fld_id] || !isArray(showList[fld_id])){ //alert("Client script error: can't find show list for field " + fld_id); return; } var list = showList[fld_id]; //List of groups to show for this fields value var groupNeedShow = new Array(); var fld = document.getElementById(fld_id); //First hide all rows for (index=0; index < list.length; ++index) { var theID = fld_id.substr(fld_id.lastIndexOf("_") + 1); // console.log(fld, theID, list[index]); if (list[index][FLD_ShowOrHide]==0) { if ((list[index][FLD_VALUE]==fld.value) || (theID==0 && list[index][FLD_VALUE]==fld.value)) { //show this group showFieldGroup(list[index][FLD_GROUP],0); } else if (!list[index][FLD_NonExclusive]) { //hide this group showFieldGroup(list[index][FLD_GROUP],1); continue; } } else if (list[index][FLD_ShowOrHide]==1) { // alert(list[index][FLD_GROUP]+'true'); if ((list[index][FLD_VALUE]==fld.value) || (theID==0 && list[index][FLD_VALUE]=fld.value)) { //disable this group showFieldGroup(list[index][FLD_GROUP],2); } else { //enable this group showFieldGroup(list[index][FLD_GROUP],3); continue; } } else if (list[index][FLD_ShowOrHide]==3){ if ((list[index][FLD_VALUE]==fld.value) || (theID==0 && list[index][FLD_VALUE]>=fld.value)) { //enable this group showFieldGroup(list[index][FLD_GROUP],3); } else { //disable this group showFieldGroup(list[index][FLD_GROUP],2); continue; } } } ////Now show rows in show list //for (index=0; index < groupNeedShow.length; ++index){ // showFieldGroup(groupNeedShow[index],1); //} ////alert("FINISHED SHOW AND HIDE"); } //This function will show(0) / hide(1) / enable(2) / disable(3) a group of fields function showFieldGroup(group, show) { var displayVal = (show==1)?'none':''; //Show / Hide labels and description var lblList = document.getElementsByTagName("span"); for (var lblIndex=0; lblIndex < lblList.length; ++lblIndex){ var lbl = lblList[lblIndex] if (lbl){ if (lbl.getAttribute("show_group")==group) lbl.style.display=displayVal; } } //Show/Hide fields var fldList = new Array(); //only so that edit will know fldList as array var fld; var inputFld; fldList = showGroupList[group]; if (!fldList || !isArray(fldList)){ //alert("Client script error: can't find field list for group " + group); return; } var rowId = new String(); for (var index = 0; index < fldList.length; ++index) { if (fldList[index].field.indexOf("_GROUP") > 0) { rowId = "collapse_panel_"+fldList[index].field; }else{ rowId = fldList[index].field+"_BLOCK"; } var shouldSend = fldList[index].sendAnyway==-1; fld = $("#"+rowId);//document.getElementById(rowId); //inputFld = $(fldList[index]); if (fld.length>0) { switch(show) { case 0: if(shouldSend) fld.css('visibility', 'visible'); else fld.show(); break; case 1: if(shouldSend) fld.css('visibility', 'hidden'); else fld.hide(); break; case 2: fld.find("*").attr('disabled', false); break; case 3: fld.find("*").attr('disabled', true); break; } } } } //END OF SHOW / HIDE FIELDS SYSTEM // you can override this function on the page_script , see example on sba project at page_script_2761.ascx var cb = (function (fld_id, fn) { }); var customScript = (function (fld_id, cb) { }); //This function will handle on change events from all fields function onFieldChange(fld_id){ if (fld_id=="") return; // לא עובד טוב בכרום var fld if (isNumber(fld_id)) fld = document.getElementById("FIELD_" + fld_id); else fld = document.getElementById(fld_id); // var fld = $('#FIELD_' + fld_id); //alert(typeof(fld)); if (!fld) { console.log("Client script error: can't find field " + fld_id+" element"); return; } showAndHideForField(fld.id); } //Global var to hold reference to form on screen var frm; //Run the onchange function of all visible fields on form //obsolete, is not used anywhere. function activateAllFieldsOnChange(){ for (var index=0; index0) { var alertText = ""; for (var i = 0; i < logicDataObject.errors.length; i++) { alertText += logicDataObject.errors[i] + "\n"; } alert(alertText); if (customErrorLogicFunction !== undefined) customErrorLogicFunction(alertText); } var addressToUse = "" if (logicDataObject.nextPageId !== undefined && logicDataObject.nextPageId > 0) { addressToUse=".?page_id=" + logicDataObject.nextPageId } else { addressToUse = logicDataObject.nextPageAddress; } if (logicDataObject.shouldGoToNextPage) { if (!logicDataObject.openInNewWindow) { if (window.location.href == addressToUse) { window.location.reload(); } else { window.location.href = addressToUse } } } else { if (addressToUse !== undefined) if (logicDataObject.errors.length == 0) { window.open(addressToUse, '_blank'); } } return logicDataObject; } //This function will process form before submition function submitForm(nextPageId){ frm.NextPage_Id.value = nextPageId; if (validateForm()){ disableHiddenControls(); frm.submit(); } } function cancelEventAndSubmitForm(nextPageId) { submitForm(nextPageId); return false; } function submitFormForPassword(nextPageId){ frm.NextPage_Id.value = nextPageId; frm.submit(); } //This function will try to validate data on form function validateForm(){ var errMsg = ""; var value; //list of fields with errors var faultyFields = new Array(); //Validate must fields if (enforceMust) for (var i in fieldMust){ var fld = document.getElementById(i); if (fld){ fld.style.background='white'; //Check if field is visible value = Trim(fld.value); if (isFieldVisible(fld) && value.length==0) faultyFields[i]=true; } } //Check min length of fields for (var i in fieldMin){ var fld = document.getElementById(i); if (fld){ fld.style.background='white'; //Check if field is visible value = Trim(fld.value); if (isFieldVisible(fld)) if (value.length!=0 && value.length < fieldMin[i]) faultyFields[i]=true; } } //Validate by field type for (var i in fieldType){ var fld = document.getElementById(i); if (fld){ fld.style.background='white'; //Check if field is visible value = Trim(fld.value); var fldErr = false; if (isFieldVisible(fld) && value.length!=0){ switch(fieldType[i]){ case FIELD_TYPE_EMAIL: fldErr = fldErr || !isValidEmail(value); break; case FIELD_TYPE_Year: fldErr = fldErr || isNaN(value) || !isInteger(value) || Number(value) > (new Date()).getFullYear(); break; case FIELD_TYPE_ID: fldErr = fldErr || isNaN(value) || !isInteger(value) || !CheckId(value); } if (fldErr) faultyFields[i]=true; } } } //Mark fields with errors var fualtyFieldCount= 0 for (var i in faultyFields){ var fld = document.getElementById(i); fld.style.background='#ff9999'; ++fualtyFieldCount; } /* if (fualtyFieldCount==0){ //Check if there is a custom logic for this page var pageId = document.getElementById('page_id'); var methodExists = false; var method = 'validateForm_'+pageId.value; eval('if ('+method+') {methodExists=true; method='+method+';}'); if (methodExists){ fualtyFieldCount = method(); } } */ //Report error to user if (fualtyFieldCount > 0) alert("נמצאו שגיאות בחלק משדות הטופס\nהשדות השגויים סומנו באדום\nסה''כ ישנם " + fualtyFieldCount + " שדות שגויים"); else { return true; } return false; } //This function will set controls that are hidden to be disabled so that //they wont be submitted with the form function disableHiddenControls(){ var fld; for (var index=0; index= 48 && key <= 57) || (key == 46)){ if (key != 46) return true; else{ if (field.value.search(/\./) == -1 && field.value.length > 0) return true; else return false; } } return false; } //Validate that key event is HEBREW function validateHE(e,field) { var key = getKeyEvent(e) if (specialKey(key)) return true; if ((key >= 1488 )&&(key <= 1514) ||(key == 32)) return true; else if (key >= 30 && key <= 57) return true; else if (key >= 123 && key <= 126) return true; else if (key >= 91 && key <= 96) return true; return false; } //Validate that key event is English function validateEN(e,field) { var key = getKeyEvent(e) if (specialKey(key)) return true; //if ((key >= 65 && key <= 90) || (key == 32) || (key >= 96 && key <= 126)) if ((key >= 65 && key <= 126) || (key == 32)) return true; else if (key >= 30 && key <= 57) return true; return false; } function IsValidSingelEmail(elementValue) { //Regex value to validate email var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; // Return true if the value is valid and false if not valid return emailPattern.test(elementValue); } function isValidEmail(str) { // 01/07/2021 fix code to chack multipule emails comma seprated var message = "" //Get comma seprated string value from input var inputs = str; if (!inputs.indexOf(',') > -1) { inputs+=',' } // Convert this comma separated string value to array var inputsArr = inputs.split(','); for (let i = 0; i < inputsArr.length; i++) { var email = inputsArr[i] //Remove white space from email email = email.replace(/\s/g, ''); //Validate the email value if (email != '') { message = true; if (IsValidSingelEmail(email)) { // valid } else { //Invalid message = false; break; } } } return message; } function isNumbersOnly(str) { var re = /[0-9]+/g; return re.test(str); } //Logon screen, forgot possowrd button function submitForgotPassword(nextPageId){ //hide password row var row = document.getElementById('FIELD_PASSWORD_ROW') if (row) row.style.display='none'; submitForm(nextPageId); } //Validate that NATIONAL ID is valid function CheckId(id) { if (isNumeric(id) && parseInt(id) == 0) return false; if (id.toString().length>9) return false; var j = 0, startmult = 0, total = 0, result = 0, Down = 0, idstart = 0, Up = 0; var mult="121212121"; var addstr="",myid=""; var zerotoadd=9-id.length; for(i=0;i57)) return false; Up=myid.charAt(i); Down=mult.charAt(i); if ((Up!=0)&&(startmult==0)) startmult=1; result=Up*Down; if ( result > 9 ) { resultx = Math.floor ( result/10 ) ; result = resultx + ( result - resultx*10 ); } total=total + result; } total = Math.ceil ( total/10 ) *10 -total; if ((myid.charCodeAt(L-1)<=57)&&(myid.charCodeAt(L-1)>=48)) add=myid.charAt(L-1); if (L==9) idstart=1; if (total != add) //אם הת.ז לא תקינה בודקים האם מדובר בח.פ. if (myid.length!=9){ return false; } else { if (myid.substr(1, 2) != '51') { return false; } else { return myid; } } else return myid; } /** * This function returns true if there were changes in the modified form */ function thereAreChanges(){ var form_modified = document.getElementById('frm'); var skip_field_list=''; var tmp=false; if (form_modified) tmp = isFormModified(form_modified,'',skip_field_list); return tmp; } function initNextPage(menu, urlNextPage,subKind) { $.ajax({ type: "POST", url: "builder/Services/InitSession.asmx/InitStatus", async: false, data: { "numMenu": menu, "kindMenu": subKind }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("AJAX failed!", XMLHttpRequest.responseText, errorThrown); }, success: function (result, status) { } }); window.location.href = urlNextPage; } //function initNextPageMainMenu(menu, urlNextPage) { // $.ajax({ // type: "POST", // url: "builder/Services/InitSession.asmx/InitStatusMainMenu", // async: false, // data: { "numMenu": menu }, // error: function (XMLHttpRequest, textStatus, errorThrown) { // console.log("AJAX failed!", XMLHttpRequest.responseText, errorThrown); // }, // success: function (result, status) { // } // }); // window.location.href = urlNextPage; //} /** * This function used in a onclick events to check if there was any change on * a form before browsing to the link */ function menu_validate(){ //return true; var prompt = "בחרת לעבור לדף אחר מבלי לשמור את השינויים שביצעת" +"\nכדי לעבור לדף אחר לחץ על אישור" +"\nכדי להישאר בדף זה לחץ על ביטול" ; // if (thereAreChanges() && !window.confirm(prompt)) // return false; // else return true; } function saveField(field,cb) { if (field.id == undefined) { field = field [0]} $("#" + field.id + "_LABEL").remove(); fieldToAdd = $(""); fieldToAdd.appendTo($("#Status")).slideDown("slow"); //animate entrance so it will be seen //$("#" + field.id + "_LABEL").show().slideDown("slow"); //var fieldToSend = field.name.substr(field.name.lastIndexOf("_") + 1); var fieldInGrid = field.name.split("_").length - 1 // console.log("fieldInGrid" + fieldInGrid); if (fieldInGrid == 2) { // this is field in a grid var fieldToSend = field.name.substr(field.name.indexOf("_") + 1, (field.name.lastIndexOf("_")) - (field.name.indexOf("_") + 1)); } else { var fieldToSend = field.name.substr(field.name.lastIndexOf("_") + 1); } if (field.multiple == true) { var valToSave = ""; for (var i = 0; i < field.selectedOptions.length; i++) { if (field.attributes.def_value.value == 'ID') { valToSave += field.selectedOptions[i].value + ","; }else{ valToSave += field.selectedOptions[i].label + ","; } } var theValue = valToSave; } else theValue = field.value; var keyToUse = document.getElementById('PageKeyToUse').value; //console.log(field, fieldToSend, theValue); // var find = "'"; // var regularExp = new RegExp(find, 'g'); // theValue = theValue.replace(regularExp, "''"); theValue = theValue.replaceAll('<', '~~') $.ajax({ type: "POST", //url: "builder/Services/SaveFieldService.asmx/SaveField", //data: { "field": fieldToSend, "value": theValue }, url: "builder/Services/SaveFieldService.asmx/SaveFieldWithKey", data: { "field": fieldToSend, "value": ((field.className.includes("tcalInput") && theValue == "") ? "null" : theValue), "keyToUse": keyToUse }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("AJAX failed!",fieldToSend,theValue,XMLHttpRequest.responseText); if (XMLHttpRequest.responseText.indexOf("No Session")>=0) { alert('תם תוקפו של החיבור'); location.reload(); } //Cannot insert duplicate key if (XMLHttpRequest.responseText.indexOf("Cannot insert duplicate key") >= 0) { alert('הערך לא נשמר, ערך זה כבר קיים במערכת והוא שדה ייחודי'); location.reload(); } }, success: function (result, status) { $("#" + field.id + "_LABEL").slideUp("slow", function () { $(this).remove(); }); if (typeof cb !== 'undefined') { cb(); } } }); } function saveFieldWithID(theFieldFullName,value,key,theTable,isANumber, cb) { var fieldToSend = theFieldFullName.substr(theFieldFullName.indexOf("_") + 1, (theFieldFullName.lastIndexOf("_")) - (theFieldFullName.indexOf("_") + 1)); value = value.replaceAll('<','~~') $.ajax({ type: "POST", url: "builder/Services/SaveFieldService.asmx/SaveFieldWithIDGrid", data: { "field": fieldToSend, "value": value, "keyToUse": key }, //url: "builder/Services/SaveFieldService.asmx/SaveFieldWithID", //data: { "fieldName": theFieldFullName, "value": value, "keyToUse": key, "table": theTable, "isANumber": isANumber }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("AJAX failed!"); }, success: function (result, status) { console.log("success", theFieldFullName); if (typeof cb !== 'undefined') { cb(); } } }); } function sendOrchangeValue(field, obj) { if (!obj.value) obj.value = true; else saveField(field); } function getMustFieldsList(pageId, callback) { ans = []; $.ajax({ url: "builder/Services/ValidationService.asmx/getEmptyMustFields", data: { "pageId": pageId }, dataType: "text", async:false, type: 'POST', cache: false, timeout: 30000, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("Server error"); }, fail: function (xhr, textStatus, errorThrown) { alert(xhr.responseText); }, success: function (msg) { while (msg.indexOf("/string") >= 0) { var subText = msg.substring(0, msg.indexOf("/string") + "/string>".length); msg = msg.replace(subText, ""); var val = getValueFromXmlNode(subText); ans.push(val); } } }); callback(ans); } function displayMustFields(pageId,callback) { getMustFieldsList(pageId, function (mustFields) { var i; if (mustFields.length == 0) { callback(""); return; } var msg = ""; for(i=0;i")+1), ""); return newValue; } function getPairsArrayValues(text) { var ans = []; while (text.indexOf("/Pair") >= 0) { var subText = text.substring(0, text.indexOf("/Pair") + "/Pair>".length); text = text.replace(subText, ""); //sometimes first appears before second, we need to do something about that var valToLookForFirst= "/First"; var valToLookForSecond= "/Second"; var firstVal = subText.substring(0, subText.indexOf(valToLookForFirst) + valToLookForFirst.length); //subText = subText.replace(firstVal, ""); var secondVal = subText.substring(0, subText.indexOf(valToLookForSecond) + valToLookForSecond.length); firstVal = getValueFromXmlNode(firstVal); secondVal = getValueFromXmlNode(secondVal); ans.push([firstVal, secondVal]); } return ans; } function checkSubmenus() { $.each($(".SubMenuItem:hidden"), function( index, value ) { var theIdToUse = value.id; $.ajax({ type: "POST", url: "builder/Services/ConfirmService.asmx/SubmenuConfirmation", data: {"menuName":theIdToUse}, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("AJAX failed!", XMLHttpRequest.responseText, errorThrown); if (XMLHttpRequest.responseText.indexOf("No Session") >= 0) { alert('תם תוקפו של החיבור' ); //location.reload(); } }, success: function (result, status) { if ($($(result)[0].children[0])[0].innerHTML=='true') $("#" + theIdToUse).slideDown("slow"); } }); }); //SubmenuConfirmation } function findAllCombosToRefresh(id,theNewVal, theMainField, idToUse) { $.ajax({ type: "POST", url: "builder/Services/SaveFieldService.asmx/getRefreshList", data: { "id": theMainField.toString() }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("AJAX failed!"); }, success: function (result, status) { // console.log(result); var theNumbers = $($(result)[0].children)[0].children; for (var i=0; i" + theNewVal + ""); theSelect.append(divToAdd); theSelect.change(); } else { if(idToUse.split('_').length-1<2) { divToAdd = $(""); theSelect.append(divToAdd); } } }); } } }); } function getNewField(id, isEditable, rawValue, actualTableName, keyToUse, callback) { $.ajax({ type: "POST", url: "builder/Services/FieldsServices.asmx/getFieldObject", data: { "fieldId": id, "isEditable": isEditable, "rawValue": rawValue, "actualTableName": actualTableName, "keyToUse": keyToUse }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("AJAX FAILED!"); }, success: function (result, status) { if (callback !== undefined) { //console.log($.parseHTML($($(result).children()[0]).text())); callback(($($(result).children()[0]).text())); } } }); } function getGridRow(ids, isEditable, rawValues, actualTableName, keyToUse, fieldId, rowNumber, isDeletable, confirmDelete,checkChilds, callback, hasDisplayPage) { $.ajax({ type: "POST", url: "builder/Services/FieldsServices.asmx/getGridRow", data: { "fieldIds": ids, "isEditable": isEditable, "rawValues": rawValues, "actualTableName": actualTableName, "keyToUse": keyToUse, "fieldId": fieldId, "rowNumber": rowNumber, "isDeletable": isDeletable, "confirmNeeded": confirmDelete, "checkChilds": checkChilds, "hasDisplayPage": hasDisplayPage }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("AJAX FAILED!"); }, success: function (result, status) { if (callback !== undefined) { //console.log($.parseHTML($($(result).children()[0]).text())); callback(($($(result).children()[0]).text())); } } }); } //function getGridRow(ids, isEditable, rawValues, actualTableName, keyToUse, fieldId, rowNumber, canAdd, confirmDelete, callback) { // $.ajax({ // type: "POST", // url: "builder/Services/FieldsServices.asmx/getGridRow", // data: { "fieldIds": ids, "isEditable": isEditable, "rawValues": rawValues, "actualTableName": actualTableName, "keyToUse": keyToUse, "fieldId": fieldId, "rowNumber": rowNumber, "canAdd": canAdd, "confirmNeeded": confirmDelete }, // error: function (XMLHttpRequest, textStatus, errorThrown) { // console.log("AJAX FAILED!"); // }, // success: function (result, status) { // if (callback !== undefined) { // //console.log($.parseHTML($($(result).children()[0]).text())); // callback(($($(result).children()[0]).text())); // } // } // }); //} var functionsForControlReady=[]; function controlReady(id, theFunction) { var found = false; if (functionsForControlReady[id]!==undefined) functionsForControlReady[id].push(theFunction); else { functionsForControlReady[id]=[]; functionsForControlReady[id].push(theFunction); } } function callControlReady(id) { if (functionsForControlReady[id]===undefined) return; for(var i=0; i= 3) { number = number.replace(/(\d{3})(\d{1})/, "$1-$2"); } $(this).val(number); }); $('.phone').on('input', function () { var number = $(this).val().replace(/[^\d]/g, ''); if (number.length >= 2) { number = number.replace(/(\d{2})(\d{1})/, "$1-$2"); } $(this).val(number); }); $('.creditCard').on('input', function () { var number = $(this).val().replace(/[^\d^X]/g, ''); if (number.length >= 12) { number = number.replace(/(.{4})(.{4})(.{4})(.{1})/, "$1-$2-$3-$4"); } else if (number.length >= 8) { number = number.replace(/(.{4})(.{4})(.{1})/, "$1-$2-$3"); } else if (number.length >= 4) { number = number.replace(/(.{4})(.{1})/, "$1-$2"); } $(this).val(number); }); }); //var colorClassArr = ['aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', //'lime', 'maroon', 'navy', 'olive', 'orange', 'purple', 'red', //'silver', 'teal', 'white', 'yellow']; var colorClassArr; $(document).ready(function () { colorClassArr = ['blue', 'green' , 'yellow' , 'yellow-gold' , 'red-haze' , 'blue-steel' , 'red' , 'green-meadow' , 'yellow-lemon' , 'purple' , 'green-jungle' , 'red-pink' ]; }); function convert(str) { var mnths = { Jan:"01", Feb:"02", Mar:"03", Apr:"04", May:"05", Jun:"06", Jul:"07", Aug:"08", Sep:"09", Oct:"10", Nov:"11", Dec:"12" }, date = str.split(" "); return [ date[2], mnths[date[1]], date[3] ].join("/"); } function deleteCookie(cname) { document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT'; // setCookie(cname, "", -1); } function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function checkCookie() { var user = getCookie("user"); var password = getCookie("password"); if (user != "" && password != "") { $("#eMail").val(user); $("#Password").val(password); setCookie("user", "s", 30); setCookie("password", "", 30); $("#frm").submit(); } else { var data = $("#ErrorRepeater").val(); // console.log(data); if (data > "") { setCookie("user", "", -1); setCookie("password", "", -1); alert(); } else { setCookie("user", "s", 30); setCookie("password", "", 30); alert(); } } } function signOut() { var auth2 = gapi.auth2.getAuthInstance(); auth2.signOut().then(function () { console.log('User signed out.'); }); } var GlobalHTMLToTranslate="" function traslateHTMLWithQuery(textToTranslate, DOMElemName) { GlobalHTMLToTranslate= textToTranslate var QueryArr = []; var beginQueryOperator = "({"; var EndQueryOperator = "})"; var Query=""; QueryArr = getParams(textToTranslate, beginQueryOperator, EndQueryOperator); for (var i = 0; QueryArr.length > i; i++) { Query = getQueryParamsFromDom(QueryArr[i], getParams(QueryArr[i], "[[", "]]"), "[[", "]]"); if( Query != "nullParam") { Query = Query.split(">").join("<"); Query = Query.split("<").join(">"); $.ajax({ type: "POST", url: "builder/Services/SaveFieldService.asmx/returnQueryData", data: {"Query" :Query }, async:false, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("AJAX failed!", XMLHttpRequest.responseText, errorThrown); }, success: function (result, status) { // console.log("xmlresult", result); // console.log("QueryResult", $(result.documentElement)[0].textContent); var qStr = '({' + QueryArr[i] + '})' oldparam = GlobalHTMLToTranslate.substring(GlobalHTMLToTranslate.indexOf(qStr) + qStr.length, GlobalHTMLToTranslate.indexOf('', GlobalHTMLToTranslate.indexOf(qStr) + qStr.length)) param = $(result.documentElement)[0].textContent; GlobalHTMLToTranslate = GlobalHTMLToTranslate.replace(qStr + oldparam + "", qStr + param + ""); // console.log("GlobalHTMLToTranslate", GlobalHTMLToTranslate); $('#'+DOMElemName)[0].innerHTML = GlobalHTMLToTranslate; } }); } else {console.log (" חסר ערכים בשאילתה: " +QueryArr[i]); break;} } } $(window).on('load', function () { $('input').each(function(){ var onload = $(this).attr("onload"); if(!(typeof(onload) === "undefined")){ eval(onload); $(this).change(); } }) }) // $("#FIELD_9667_tabs-1")[0].innerHTML = function getParams(srtWithParams, beginOperator, EndOperator) { var arr = []; var param = ""; while (srtWithParams.indexOf(EndOperator) > 0) { param = ""; param = srtWithParams.substring( srtWithParams.indexOf(EndOperator), srtWithParams.indexOf(beginOperator) + beginOperator.length); //if(param.includes("SESSION_")) param="{{"+param+"}}" arr.push(param) srtWithParams = srtWithParams.slice(srtWithParams.indexOf(EndOperator) + EndOperator.length) } return arr; } function getQueryParamsFromDom(QuerySTR, paramArr, beginOperator, EndOperator) { for (var i = 0; paramArr.length > i; i++) { if (!paramArr[i].includes("SESSION_") ){ if ( $("[name='" + paramArr[i] + "']") && $("[name='" + paramArr[i] + "']")[0] && $("[name='" + paramArr[i] + "']").val()) { QuerySTR=QuerySTR.replace(beginOperator+paramArr[i]+ EndOperator, $("[name='" + paramArr[i] + "']").val()); } else return "nullParam" } else QuerySTR=QuerySTR.replace("[["+paramArr[i]+"]]","{{"+paramArr[i]+"}}") } return QuerySTR; } $(document).ready(function () { $('a[title="יציאה"]').click(function () { deleteCookie("UserSettings"); deleteCookie("session"); signOut(); //window.location.href = '?page_id=' +2263 window.location.reload(true); }); $("#loginButton").click(function () { setCookie("UserSettings", "UserName=" + $("#eMail").val() + "&Password=" + $("#Password").val() + "&Token=0", 30); }); }); $(document).ready(function () { $('.cellphone').on('input', function () { var number = $(this).val().replace(/[^\d]/g, ''); if (number.length >= 3) { number = number.replace(/(\d{3})(\d{1})/, "$1-$2"); } $(this).val(number); }); $('.phone').on('input', function () { var number = $(this).val().replace(/[^\d]/g, ''); if (number.length >= 2) { number = number.replace(/(\d{2})(\d{1})/, "$1-$2"); } $(this).val(number); }); convertTo2Digit(); }); function convertTo2Digit() { $('.currency').each(function () { if ($(this).val() != '') { $(this).val((parseFloat($(this).val()).toFixed(2)).toLocaleString()); } }); } /* Converts integer to timespan string. Parameters: interval in minutes Returns: timespan string "hours:minutes" */ function minutesToTimeSpan(minutes) { if (minutes == 0) return ""; var m = minutes % 60; var h = (minutes - m) / 60; if (m == 0) return h.toString() + ":00"; if (m < 10) return h.toString() + ":0" + m.toString(); return h.toString() + ":" + m.toString(); } function addRecord(pageNum, tableName,mainFieldName,sqlForComboText, cFldNameListForUpdate) { var newPkCode="" $.ajax({ type: "POST", url: "builder/Services/FieldsServices.asmx/AddRecord", data: JSON.stringify({"tableName":tableName}), contentType: 'application/json', async: false }).done(function (response) { console.log("response", response); $('body').css({ 'cursor': 'default' }); newPkCode = response.d; openRecordWindow(pageNum, newPkCode, false, mainFieldName, sqlForComboText, cFldNameListForUpdate); }).fail(function (jqXHR, textStatus) { }); } function editRecord(pageNum, tableName, mainFieldName, sqlForComboText, cFldNameListForUpdate, theFKCode) { $.ajax({ method: "POST", url: "builder/Services/FieldsServices.asmx/setRecordPkInSession", data: JSON.stringify({ "tableName": tableName,"theFKCode": theFKCode}), contentType: 'application/json', async: false }).done(function (response) { openRecordWindow(pageNum, theFKCode, true, mainFieldName, sqlForComboText, cFldNameListForUpdate); }); } function openRecordWindow(pageNum, pkCode, isEdit, mainFieldName, sqlForComboText, cFldNameListForUpdate) { var theRetData; var windowURL = "?page_id=" + pageNum + "&isEdit=" + isEdit + "&IsPopup=True&newPkCode=" + pkCode; let h = $(window).height(); let w = $(window).width(); h -= 100; w -= 100; console.log("page opened"); new_window = window.open(windowURL, "_blank", "toolbar=no, scrollbars=no, resizable=no, menubar=no, status=no, titlebar=no, top=100, left=100, width=" + w + ", height=" + h); var winClosed = setInterval(function () { if (new_window.closed) { clearInterval(winClosed); getRecordDetails(pageNum, pkCode, mainFieldName, sqlForComboText, cFldNameListForUpdate); } }, 250); $('body').css({ 'cursor': 'default' }); console.log("Completed..."); $(this).blur(); return theRetData; } function getRecordDetails(pageNum, pkCode, mainFieldName, sqlForComboText, cFldNameListForUpdate) { var cFldNameList = cFldNameListForUpdate.split(","); var theVal; $.ajax({ method: "POST", url: "builder/Services/FieldsServices.asmx/getRecordDetails", data: JSON.stringify({"pageNum":pageNum, "thePKCode": pkCode }), contentType: 'application/json', async: false }).done(function (response) { console.log(response); var data = JSON.parse(response.d); //put the data on the main field var comboText=""; $.ajax({ method: "POST", url: "builder/Services/FieldsServices.asmx/getComboSpecialDetails", data: JSON.stringify({ "sqlForComboText": sqlForComboText, "mainFieldName": mainFieldName, "thePKCode": pkCode }), contentType: 'application/json', async: false }).done(function (response) { if (response.d != "") { comboText = response.d; var o = new Option(comboText, data[0][mainFieldName.replace('FKCode', 'PKCode')], true, true); $(o).html(comboText); $("[cfldname='" + mainFieldName + "']").append(o); $("[cfldname='" + mainFieldName + "']").val(data[0][mainFieldName.replace('FKCode', 'PKCode')]).keyup().change(); } }).fail(function (jqXHR, textStatus) { }); //put the data on the other fields for (var i = 0; i < cFldNameList.length; i++) { theVal = cFldNameList[i].includes("FKCode")?data[0][cFldNameList[i].replace('FKCode', 'PKCode')]:data[0][cFldNameList[i]]; if (theVal != null) { $("[cfldname='" + cFldNameList[i] + "']").val(theVal).keyup().change(); } } }).fail(function (jqXHR, textStatus) { }); } function deleteAllCookies() { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; } } function forgotPassword(eMail) { $.ajax({ method: "POST", contentType: 'application/json', url: "builder/Services/LoginScreenService.asmx/forgotPassword", data: JSON.stringify({ "userEMail": eMail }), dataType: "text", type: 'POST', async: false, cache: false, timeout: 30000, error: function () { ans = false; }, success: function (result, status) { var msg = JSON.parse(result) alert(msg.d); } }); } function GenericGotoPage(rowID, TableName, PageID) { $.ajax({ type: "POST", url: "builder/Services/SearchService.asmx/setRowIdInSession", data: { "rowID": rowID, "table": TableName }, async: false, error: function (XMLHttpRequest, textStatus, errorThrown) { //alert("AJAX failed!"); }, success: function (result, status) { deleteAllCookies(); location.href='.?page_id='+PageID } }); } function reloadField(fieldName, tableName, key) { $.ajax({ method: "POST", url: "/builder/Services/SaveFieldService.asmx/reloadField", data: JSON.stringify({ "theField": fieldName, "theTable": tableName, "KeyToUse": key }), contentType: 'application/json' }).done(function (response) { if ($("[cfldname='" + fieldName + "']").length > 0) var $el = $("[cfldname='" + fieldName + "']"); else var $el = $("[cfldname='" + fieldName + "_" + key + "']"); if ($el.length > 0) $el.val(response.d.replace("
", "\\\n").replace("
", "\\\n").replace("\\", "").replace("\\", "")); }).fail(function (jqXHR, textStatus) { }) } function downloadFile(filename) { var element = document.createElement('a'); element.setAttribute('href', filename); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } function RefreshedComboValues(fldId) { $.ajax({ type: "POST", url: "builder/Services/SaveFieldService.asmx/getRefreshedComboValuesList", data: { "id": fldId }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("AJAX failed!"); }, success: function (result, status) { var theData = $.parseJSON($(result.children[0])[0].innerHTML); var found = []; $("#FIELD_" + fldId).find("option").each(function () { var valueToSearch = this.value; for (i = 0; i < theData.length; i++) { if (theData[i]["ID"] == valueToSearch.toString()) { found.push(theData[i]); return; } } $(this).remove(); }); for (var i = 0; i < theData.length; i++) { var elem = theData[i]; if ($.inArray(elem, found) == -1) { $("#FIELD_" + fldId).append($("")); } }; } }); }