if(document.DiscoFunctions||(document.DiscoFunctions={}),document.DiscoFunctions.PropertyChangeHelper||(document.DiscoFunctions.PropertyValue=function(n){return n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="checkbox"?n.is(":checked"):n.val()},document.DiscoFunctions.PropertyChangeHelper=function(n,t,i,r,u,f){var h=document.DiscoFunctions.PropertyValue(n),o=null,e=n.nextAll(".ajaxSave").first(),s=n.nextAll(".ajaxLoading").first(),c=function(){e.hide();var t=document.DiscoFunctions.PropertyValue(n);if(h!=t){if(f&&!f(t))return;h=t;o&&window.clearTimeout(o);o=window.setTimeout(async function(){s.show();const n=new FormData;if(n.append("__RequestVerificationToken",document.body.dataset.antiforgery),u)for(const t in u)n.append(t,u[t]);n.append(r,h);try{const t=await fetch(i,{method:"POST",body:n});t.ok?s.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow"):(alert('Unable to change property "'+r+'":\n'+t.statusText),s.hide())}catch(t){alert('Unable to change property "'+r+'":\n'+t);s.hide()}o=null},500)}};n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="checkbox"?n.click(c):n.change(c);n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="text"&&(n.keydown(function(n){e.show();n.which==13&&$(this).blur()}).blur(function(){e.hide()}).focus(function(){$(this).select()}),t&&n.watermark(t));n[0].nodeName.toLowerCase()=="textarea"&&n.keydown(function(){e.show()}).blur(function(){e.hide()})}),document.DiscoFunctions.DateChangeUserHelper||(document.DiscoFunctions.DateChangeUserHelper=function(n,t,i,r,u,f,e){var h=n.val(),o=null,s=t.next(".ajaxLoading");n.watermark(i).change(function(){var i=n.val();h.toLowerCase()!=i.toLowerCase()&&(h=i,o&&window.clearTimeout(o),o=window.setTimeout(async function(){s.show();const n=new FormData;n.append("__RequestVerificationToken",document.body.dataset.antiforgery);n.append(u,h);try{const i=await fetch(r,{method:"POST",body:n});if(i.ok){const n=await i.json();t.text("by "+n.UserDescription);s.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow")}else alert("Unable to change Date:\n"+i.statusText),s.hide()}catch(i){alert("Unable to change Date:\n"+response.statusText);s.hide()}o=null},500))}).focus(function(){$(this).select()});e?n.datepicker({defaultDate:new Date,minDate:moment(f).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datepicker("setDate",new Date)}}):n.datetimepicker({defaultDate:new Date,ampm:!0,minDate:moment(f).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datetimepicker("setDate",new Date)}})}),document.DiscoFunctions.DateChangeHelper||(document.DiscoFunctions.DateChangeHelper=function(n,t,i,r,u,f){var s=n.val(),e=null,o=n.next(".ajaxLoading");n.watermark(t).change(function(){var t=n.val();s.toLowerCase()!=t.toLowerCase()&&(s=t,e&&window.clearTimeout(e),e=window.setTimeout(async function(){o.show();const n=new FormData;n.append("__RequestVerificationToken",document.body.dataset.antiforgery);n.append(r,s);try{const t=await fetch(i,{method:"POST",body:n});t.ok?o.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow"):(alert("Unable to change Date:\n"+t.statusText),o.hide())}catch(t){alert("Unable to change Date:\n"+response.statusText);o.hide()}e=null},500))}).focus(function(){$(this).select()});f?n.datepicker({defaultDate:new Date,minDate:moment(u).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datepicker("setDate",new Date)}}):n.datetimepicker({defaultDate:new Date,ampm:!0,minDate:moment(u).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datetimepicker("setDate",new Date)}})}),!document.DiscoFunctions.DateDialogCreateUpdater){var dialog,dialogForm,dialogHeader,dialogDateBox,dialogDatePropertyNameBox,updateUrl,friendlyName,dateField,userField,updatePropertyName,notSetDisplay,minDate,useAjax;function n(){if(!dialog){dialog=$("
").attr({"class":"dialog"});dialogForm=$("
").attr({action:"/",method:"post"}).appendTo(dialog);var n=$("

").appendTo(dialogForm);dialogHeader=$("

").attr("autofocus","autofocus").appendTo(n);dialogDatePropertyNameBox=$("").attr({type:"hidden",name:"key"}).appendTo(n);dialogDateBox=$("").attr({type:"datetime",name:"value"}).css({display:"block","margin-top":15,"margin-left":"auto","margin-right":"auto"}).appendTo(n);$("").attr({type:"hidden",name:"redirect"}).val("true").appendTo(n);dialog.dialog({resizable:!1,modal:!0,autoOpen:!1,buttons:{Update:function(){t()},Cancel:function(){$(this).dialog("close")}},open:function(){dialog.dialog("widget").find(".ui-dialog-buttonpane :tabbable:first").focus()}});dialogDateBox.datetimepicker({defaultDate:new Date,ampm:!0,changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd"})}return dialog}async function t(){var r=dialogDateBox.val(),t,n,i;if(useAjax){t=$("#"+dateField);userField&&(n=$("#"+userField));dialog.dialog("close");i=(n?n.next(".ajaxLoading"):t.next(".ajaxLoading")).show();const u=new FormData;u.append("__RequestVerificationToken",document.body.dataset.antiforgery);u.append("key",updatePropertyName);u.append("value",r);try{const r=await fetch(updateUrl,{method:"POST",body:u});if(r.ok){const u=await r.json();u.DateTimeFull?t.attr("data-isodate",u.DateTimeISO8601).attr("data-livestamp",u.DateTimeUnixEpoc).attr("title",u.DateTimeFull).text(u.DateTimeFriendly):t.attr("data-isodate","").attr("data-livestamp","-1").attr("title",notSetDisplay).text(notSetDisplay);n&&n.text("by "+u.UserDescription);i.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow")}else alert("Unable to change "+friendlyName+" Date:\n"+r.statusText),i.hide()}catch(u){alert("Unable to change "+friendlyName+" Date:\n"+response.statusText);i.hide()}}else dialog.dialog("disable"),dialog.dialog("option","buttons",null),dialogDatePropertyNameBox.val(updatePropertyName),dialogForm.attr("action",updateUrl),dialogForm.submit()}function i(t,i,r,u,f,e,o,s){var h,c;updateUrl=t;friendlyName=i;dateField=r;userField=u;updatePropertyName=f;notSetDisplay=e;minDate=o;useAjax=s;h=n();h.dialog("option","title",friendlyName);dialogHeader.text(friendlyName+" Date");c=$("#"+r).attr("data-isodate");c?dialogDateBox.datetimepicker("setDate",new Date(c)):dialogDateBox.datetimepicker("setDate",new Date);o?dialogDateBox.datetimepicker("option","minDate",moment(minDate).toDate()):dialogDateBox.datetimepicker("option","minDate",null);h.dialog("open")}function r(n,t,r,u,f,e,o,s){$("").attr({href:"#","class":"button small",style:"margin-right: 5px;"}).text("Update").click(function(h){h.preventDefault();i(n,t,r,u,f,e,o,s)}).insertBefore("#"+r)}document.DiscoFunctions.DateDialogCreateUpdater=r}