//Test Code async function ShowExample() { PopMessage("Processing...", "Process"); await delay(3000); PopMessage("This is normal.", "Info"); await delay(3000); PopMessage("Should look into this.", "Warn"); await delay(3000); PopMessage("This is bad.", "Error"); await delay(3000); PopUpCLosed(); } function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } //Type: Process (default), Info, Warn, Error //DisplayTime: -1 = No Timeout, null= Default of 4000, DisplayTime = Timeout in ms. var styles = ` .PopMess { background-color: hsla(81.7, 57.1%, 91.6%, 0.80); padding: 12px 8px 12px 8px; font-size: 20px; min-width: 300px; z-index: 99999; display: inline-block; } .PopMess-Process { border: solid 3px #aeacac; color: black; } .PopMess-Info { border: solid 3px #759f40; color: #759f40; } .PopMess-Warn { border: solid 3px #e18728; color: #e18728; } .PopMess-Error { border: solid 3px red; color: red; } ` var styleSheet = document.createElement("style") styleSheet.innerText = styles document.head.appendChild(styleSheet) var PopCallback; var PoptimeoutHandle; var jqdivPopMess; function PopMessage(Message, Type, DisplayTime, CallBackPop) { PopCallback = (typeof CallBackPop === 'function') ? CallBackPop : null; if (PSIisEmpty(Message)) { $.unblockUI(); return; } if (PSIisEmpty(jqdivPopMess)) { $(document.body).append("
"); jqdivPopMess = $("#divPopMess"); $.blockUI({ message: jqdivPopMess, css: { border: 'none', width: 'auto', left: '50%', top: '50%', transform: 'translate(-50%, -50%)' }, fadeIn: 0, overlayCSS: { opacity: 0.6, cursor: 'wait' }, onUnblock: function () { jqdivPopMess.detach(); jqdivPopMess = ""; } }); } if (PSIisEmpty(Type)) Type = 'Process'; if (Type === 'Process') DisplayTime = -1; jqdivPopMess.removeClass('PopMess-Process PopMess-Info PopMess-Warn PopMess-Error'); jqdivPopMess.addClass(`PopMess-${Type}`); jqdivPopMess.html(Message); if (Type !== 'Process') { $('.blockOverlay').css('cursor', 'default').off('click').on('click', function () { PopUpCLosed(); }); jqdivPopMess.css('cursor', 'default').off('click').on('click', function () { PopUpCLosed(); }); } if (DisplayTime === -1) return; if (PSIisEmpty(DisplayTime)) DisplayTime = 12000; PoptimeoutHandle = setTimeout(PopUpCLosed, DisplayTime); } function PopUpCLosed() { window.clearTimeout(PoptimeoutHandle); PoptimeoutHandle = null; let callback = PopCallback; PopCallback = null; if ($.unblockUI) { $.unblockUI(); } if (typeof callback === 'function') { callback(); } } function PopMessage_Info(Message, CallBackPop) { PopMessage(Message, 'Info', null, CallBackPop); } function PopMessage_Error(Message) { PopMessage(Message, 'Error'); } function DisplayResult(json, CallBackPop) { if (DisplayErrorResult(json) === false) return false; PopMessage_Info(json.UserDisplay, CallBackPop); return true; } function DisplayErrorResultEmpty(json) { if (PSIisEmpty(json)) { PopMessage_Error("Strange Error, tell the developer."); return false; } PopUpCLosed(); return true; } function DisplayErrorResult(json) { if (DisplayErrorResultEmpty(json) === false) { return false; } if (json.Result !== 0) { if (json.ForceRedirect) { window.location.href = json.ForceRedirect; return false; } PopMessage_Error(json.UserDisplay); return false; } PopUpCLosed(); return true; } function DisplayErrorResultOrContinue(json) { if (PSIisEmpty(json)) { PopMessage_Error("Strange Error, tell the developer."); return false; } if (json.Result !== 0) { PopMessage_Error(json.UserDisplay); return false; } return true; } function round(value, decimals) { return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); } function DetectCtrChange(DetectDiv, CallChange){ $("#" + DetectDiv + " :input:not(input[type=submit],.DetNoChg)").each(function (index) { //console.log(index + ' ' + this.id + ' ' + this.tagName + ' ' + $(this).attr("tag") + ' ' + $(this).attr("type")); var ctr = $(this) ctr.change(function () { CallChange() }); ctr.focus(function () { original = $(this).val() }); ctr.keyup(function (event) { if (original !== $(this).val()) { CallChange(); } }); if (ctr.attr("type") === "select") { ctr.change(function () { CallChange() }); }; if(ctr.attr("type") === "checkbox") { ctr.click(function (event) { CallChange() }); }; }) } function DetectCtrChange2(DetectElements, CallChange) { $(DetectElements + " :input:not(input[type=submit],.DetNoChg)").each(function (index) { console.log(index + ' ' + this.id + ' ' + this.tagName + ' ' + $(this).attr("tag") + ' ' + $(this).attr("type")); var ctr = $(this) ctr.change(function () { CallChange() }); ctr.focus(function () { console.log("here"); original = $(this).val() }); ctr.keyup(function (event) { if (original !== $(this).val()) { CallChange(); } }); if (ctr.attr("type") === "select") { ctr.change(function () { CallChange() }); }; if (ctr.attr("type") === "checkbox") { ctr.click(function (event) { CallChange() }); }; }) } function DetectCtrChange3(detectElements, callChange) { $(detectElements).each(function () { var $ctr = $(this); var original = ""; /* console.log(`${this.id} ${this.tagName} ${$ctr.attr("tag")} ${$ctr.attr("type")}`);*/ $ctr.on("focus", function () { original = $ctr.val(); }); $ctr.on("change input", function () { if ($ctr.is(":checkbox")) { callChange(); return; } if (original !== $ctr.val()) { callChange(); } }); }); } function GetVal(s) { return $.trim($("#" + s).val()); } function GetHtml(s) { return $.trim($("#" + s).html()); } function GetCheck(s) { return $("#" + s).prop("checked"); }; $.fn.center = function () { this.css("position", "absolute"); this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px"); this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px"); return this; } function PSIisEmpty(variable) { if (variable === null) return true if (variable === undefined) return true if (variable === "") return true return false; }