//Test Code //psiBlockPage("Processing..."); //setTimeout(function () { // psiBlockPage("This is normal.", "Info"); // setTimeout(function () { // psiBlockPage("Should look into this.", "Warn"); // setTimeout(function () { // psiBlockPage("This is bad.", "Error"); // setTimeout(function () { // psiUnBlockPage(); // }, 3000); // }, 3000); // }, 3000); //}, 3000) //Type: Process (default), Info, Warn, Error //DisplayTime: -1 = No Timeout, null= Default of 4000, DisplayTime = Timeout in ms. var PopCallback; var PoptimeoutHandle; var jqdivPopMess; function PopMessage(Message, Type, DisplayTime, CallBackPop) { PopCallback = CallBackPop; if (isEmpty(Message)) { $.unblockUI(); return; } if (isEmpty(jqdivPopMess)) { $(document.body).append("
"); jqdivPopMessDiv = $("#divPopMess"); jqdivPopMess = $("#divPopMess"); $.blockUI({ message: jqdivPopMessDiv, css: { border: 'none', width: '100%', left: 0 }, fadeIn: 0, overlayCSS: { backgroundColor: '#FFFF', opacity: 0.6, cursor: 'wait' }, onUnblock: function () { jqdivPopMess.detach(); jqdivPopMess = ""; } }); } if (isEmpty(Type)) Type = 'Process'; if (Type === 'Process') { DisplayTime = -1 }; jqdivPopMess.removeClass('PopMess-Process'); jqdivPopMess.removeClass('PopMess-Info'); jqdivPopMess.removeClass('PopMess-Warn'); jqdivPopMess.removeClass('PopMess-Error'); jqdivPopMess.addClass('PopMess-' + Type); jqdivPopMess.html(Message); if (Type !== 'Process') { $('.blockOverlay').css('cursor', 'default'); $('.blockOverlay').click(function () { PopUpCLosed(); }); jqdivPopMess.css('cursor', 'default'); jqdivPopMess.click(function () { PopUpCLosed(); }); } if (DisplayTime === -1) return; if (isEmpty(DisplayTime)) DisplayTime = 12000; PoptimeoutHandle = setTimeout(PopUpCLosed, DisplayTime); } function PopUpCLosed() { window.clearTimeout(PoptimeoutHandle); $.unblockUI(); if (typeof (PopCallback) === 'function') { PopCallback(); }; } function PopMessage_Info(Message, CallBackPop) { PopMessage(Message, 'Info', null, CallBackPop); } function PopMessage_Error(Message) { PopMessage(Message, 'Error'); } function DisplayResult(json) { if (DisplayErrorResult(json) === false) return false; PopMessage_Info(json.UserDisplay); return true; } function DisplayErrorResultEmpty(json) { if (isEmpty(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) { PopMessage_Error(json.UserDisplay); return false; } PopUpCLosed(); 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 () { 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 (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") === "checkbox") { ctr.click(function (event) { 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; }