!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.moment=t()}(this,function(){"use strict";var H;function f(){return H.apply(null,arguments)}function a(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function F(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function c(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function L(e){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(e).length;for(var t in e)if(c(e,t))return;return 1}function o(e){return void 0===e}function u(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function V(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function G(e,t){for(var n=[],s=e.length,i=0;i>>0,s=0;sAe(e)?(r=e+1,t-Ae(e)):(r=e,t);return{year:r,dayOfYear:n}}function qe(e,t,n){var s,i,r=ze(e.year(),t,n),r=Math.floor((e.dayOfYear()-r-1)/7)+1;return r<1?s=r+P(i=e.year()-1,t,n):r>P(e.year(),t,n)?(s=r-P(e.year(),t,n),i=e.year()+1):(i=e.year(),s=r),{week:s,year:i}}function P(e,t,n){var s=ze(e,t,n),t=ze(e+1,t,n);return(Ae(e)-s+t)/7}s("w",["ww",2],"wo","week"),s("W",["WW",2],"Wo","isoWeek"),t("week","w"),t("isoWeek","W"),n("week",5),n("isoWeek",5),v("w",p),v("ww",p,w),v("W",p),v("WW",p,w),Te(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=g(e)});function Be(e,t){return e.slice(t,7).concat(e.slice(0,t))}s("d",0,"do","day"),s("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),s("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),s("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),s("e",0,0,"weekday"),s("E",0,0,"isoWeekday"),t("day","d"),t("weekday","e"),t("isoWeekday","E"),n("day",11),n("weekday",11),n("isoWeekday",11),v("d",p),v("e",p),v("E",p),v("dd",function(e,t){return t.weekdaysMinRegex(e)}),v("ddd",function(e,t){return t.weekdaysShortRegex(e)}),v("dddd",function(e,t){return t.weekdaysRegex(e)}),Te(["dd","ddd","dddd"],function(e,t,n,s){s=n._locale.weekdaysParse(e,s,n._strict);null!=s?t.d=s:m(n).invalidWeekday=e}),Te(["d","e","E"],function(e,t,n,s){t[s]=g(e)});var Je="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Qe="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Xe="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Ke=k,et=k,tt=k;function nt(){function e(e,t){return t.length-e.length}for(var t,n,s,i=[],r=[],a=[],o=[],u=0;u<7;u++)s=l([2e3,1]).day(u),t=M(this.weekdaysMin(s,"")),n=M(this.weekdaysShort(s,"")),s=M(this.weekdays(s,"")),i.push(t),r.push(n),a.push(s),o.push(t),o.push(n),o.push(s);i.sort(e),r.sort(e),a.sort(e),o.sort(e),this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+r.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+i.join("|")+")","i")}function st(){return this.hours()%12||12}function it(e,t){s(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function rt(e,t){return t._meridiemParse}s("H",["HH",2],0,"hour"),s("h",["hh",2],0,st),s("k",["kk",2],0,function(){return this.hours()||24}),s("hmm",0,0,function(){return""+st.apply(this)+r(this.minutes(),2)}),s("hmmss",0,0,function(){return""+st.apply(this)+r(this.minutes(),2)+r(this.seconds(),2)}),s("Hmm",0,0,function(){return""+this.hours()+r(this.minutes(),2)}),s("Hmmss",0,0,function(){return""+this.hours()+r(this.minutes(),2)+r(this.seconds(),2)}),it("a",!0),it("A",!1),t("hour","h"),n("hour",13),v("a",rt),v("A",rt),v("H",p),v("h",p),v("k",p),v("HH",p,w),v("hh",p,w),v("kk",p,w),v("hmm",ge),v("hmmss",we),v("Hmm",ge),v("Hmmss",we),D(["H","HH"],x),D(["k","kk"],function(e,t,n){e=g(e);t[x]=24===e?0:e}),D(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),D(["h","hh"],function(e,t,n){t[x]=g(e),m(n).bigHour=!0}),D("hmm",function(e,t,n){var s=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s)),m(n).bigHour=!0}),D("hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s,2)),t[N]=g(e.substr(i)),m(n).bigHour=!0}),D("Hmm",function(e,t,n){var s=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s))}),D("Hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[x]=g(e.substr(0,s)),t[T]=g(e.substr(s,2)),t[N]=g(e.substr(i))});k=de("Hours",!0);var at,ot={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Ce,monthsShort:Ue,week:{dow:0,doy:6},weekdays:Je,weekdaysMin:Xe,weekdaysShort:Qe,meridiemParse:/[ap]\.?m?\.?/i},R={},ut={};function lt(e){return e&&e.toLowerCase().replace("_","-")}function ht(e){for(var t,n,s,i,r=0;r=t&&function(e,t){for(var n=Math.min(e.length,t.length),s=0;s=t-1)break;t--}r++}return at}function dt(t){var e;if(void 0===R[t]&&"undefined"!=typeof module&&module&&module.exports&&null!=t.match("^[^/\\\\]*$"))try{e=at._abbr,require("./locale/"+t),ct(e)}catch(e){R[t]=null}return R[t]}function ct(e,t){return e&&((t=o(t)?mt(e):ft(e,t))?at=t:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),at._abbr}function ft(e,t){if(null===t)return delete R[e],null;var n,s=ot;if(t.abbr=e,null!=R[e])Q("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=R[e]._config;else if(null!=t.parentLocale)if(null!=R[t.parentLocale])s=R[t.parentLocale]._config;else{if(null==(n=dt(t.parentLocale)))return ut[t.parentLocale]||(ut[t.parentLocale]=[]),ut[t.parentLocale].push({name:e,config:t}),null;s=n._config}return R[e]=new K(X(s,t)),ut[e]&&ut[e].forEach(function(e){ft(e.name,e.config)}),ct(e),R[e]}function mt(e){var t;if(!(e=e&&e._locale&&e._locale._abbr?e._locale._abbr:e))return at;if(!a(e)){if(t=dt(e))return t;e=[e]}return ht(e)}function _t(e){var t=e._a;return t&&-2===m(e).overflow&&(t=t[O]<0||11We(t[Y],t[O])?b:t[x]<0||24P(r,u,l)?m(s)._overflowWeeks=!0:null!=h?m(s)._overflowWeekday=!0:(d=$e(r,a,o,u,l),s._a[Y]=d.year,s._dayOfYear=d.dayOfYear)),null!=e._dayOfYear&&(i=bt(e._a[Y],n[Y]),(e._dayOfYear>Ae(i)||0===e._dayOfYear)&&(m(e)._overflowDayOfYear=!0),h=Ze(i,0,e._dayOfYear),e._a[O]=h.getUTCMonth(),e._a[b]=h.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=c[t]=n[t];for(;t<7;t++)e._a[t]=c[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[x]&&0===e._a[T]&&0===e._a[N]&&0===e._a[Ne]&&(e._nextDay=!0,e._a[x]=0),e._d=(e._useUTC?Ze:je).apply(null,c),r=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[x]=24),e._w&&void 0!==e._w.d&&e._w.d!==r&&(m(e).weekdayMismatch=!0)}}function Tt(e){if(e._f===f.ISO_8601)St(e);else if(e._f===f.RFC_2822)Ot(e);else{e._a=[],m(e).empty=!0;for(var t,n,s,i,r,a=""+e._i,o=a.length,u=0,l=ae(e._f,e._locale).match(te)||[],h=l.length,d=0;de.valueOf():e.valueOf()"}),i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},i.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},i.eraName=function(){for(var e,t=this.localeData().eras(),n=0,s=t.length;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},i.isLocal=function(){return!!this.isValid()&&!this._isUTC},i.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},i.isUtc=At,i.isUTC=At,i.zoneAbbr=function(){return this._isUTC?"UTC":""},i.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},i.dates=e("dates accessor is deprecated. Use date instead.",ke),i.months=e("months accessor is deprecated. Use month instead",Ge),i.years=e("years accessor is deprecated. Use year instead",Ie),i.zone=e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),i.isDSTShifted=e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e,t={};return $(t,this),(t=Nt(t))._a?(e=(t._isUTC?l:W)(t._a),this._isDSTShifted=this.isValid()&&0 { if (event.data.type === 'whitelabelChange') { $('#hfWhitelabel').val("true"); // Make colour changes $('#hfPrimaryColour').val(event.data.colours.primaryColour); $('#hfSecondaryColour').val(event.data.colours.secondaryColour); $('#hfPrimaryTextColour').val(event.data.colours.primaryTextColour); $('#hfSecondaryTextColour').val(event.data.colours.secondaryTextColour); // Make settings changes $('#hfDisableGradient').val(event.data.settings.disableGradient); $('#hfInvertBlackWhite').val(event.data.settings.invertBlackWhite); // Make text changes event.data.text.forEach(textChange => $(`#${textChange.target}`).text(textChange.val)) initStyleSheets(); } }); $(document).ready(function () { var embed = false; var randomValue = 15; var externalService = false; var hfEmbed = document.getElementById('hfEmbed') if (hfEmbed !== null && hfEmbed.value.toLowerCase() === 'true') embed = true; if (embed) { $('.embedHide').hide(); } initialise(); $(':radio').mousedown(function (e) { var $self = $(this); if ($self.is(':checked')) { var uncheck = function () { setTimeout(function () { $self.removeAttr('checked'); }, 0); }; var unbind = function () { $self.unbind('mouseup', up); }; var up = function () { uncheck(); unbind(); }; $self.bind('mouseup', up); $self.one('mouseout', unbind); } }); var dateInputs = document.getElementsByClassName('showDateFormat'); for (var i = 0; i < dateInputs.length; i++) { dateInputs[i].onfocus = function () { if ($(this).val() == 'dd-mm-yyyy') $(this).val(''); else if ($(this).val() == '') $(this).val('dd-mm-yyyy'); } } /* Update time saved value step 2 with random integer between 10 and 20 */ function randomiseTimeSavedValue() { randomValue = Math.round(Math.random() * (20 - 10) + 10); $('.timeSavedValue').text(randomValue); } /* Initialise all fields, estimate consumption using populated step 2 options * and randomise time saved value */ function initialise() { /* * Jquery Custom Validation */ initStyleSheets(); randomiseTimeSavedValue(); $('.showDateFormat').val('dd-mm-yyyy'); $.datepicker.inputFormats = ["dd-mm-yy", "dd/mm/yy", "dd mm yy"];//list formats to be accepted here $.datepicker.originalParseDate = $.datepicker.parseDate; $('.defaultPastAndCurrent').datepicker({ dateFormat: "dd-mm-yy", showButtonPanel: true, changeYear: true, changeMonth: true, yearRange: "-10:+10", defaultDate: moment(new Date()).format("DD-MM-YYYY") }).focus(function () { $('button.ui-datepicker-current').hide(); }); $('.defaultCurrent').datepicker({ dateFormat: "dd-mm-yy", showButtonPanel: true, changeYear: true, changeMonth: true, yearRange: "-1:+10", defaultDate: moment(new Date()).format("DD-MM-YYYY") }).focus(function () { $('button.ui-datepicker-current').hide(); }); $('.defaultFuture').datepicker({ dateFormat: "dd-mm-yy", changeYear: true, showButtonPanel: true, changeMonth: true, yearRange: "-0:+1", }).focus(function () { $('button.ui-datepicker-current').show(); }); $('.defaultFutureNoWeekends').datepicker({ dateFormat: "dd-mm-yy", changeYear: true, showButtonPanel: true, changeMonth: true, yearRange: "-0:+1", beforeShowDay: $.datepicker.noWeekends // disable weekends }).focus(function () { $('button.ui-datepicker-current').show(); }); $('.defaultFutureOnly').attr('placeholder', 'dd-mm-yyyy').change(function () { $(this).datepicker('setDate', $(this).datepicker('getDate')); }).datepicker({ dateFormat: "dd-mm-yy", changeYear: true, showButtonPanel: true, changeMonth: true, yearRange: "-0:+1", minDate: 0 }).focus(function () { $('button.ui-datepicker-current').show(); }); $('.default7DaysFutureOnly').attr('placeholder', 'dd-mm-yyyy').change(function () { $(this).datepicker('setDate', $(this).datepicker('getDate')); }).datepicker({ dateFormat: "dd-mm-yy", changeYear: true, showButtonPanel: true, changeMonth: true, yearRange: "-0:+1", minDate: 7 }).focus(function () { $('button.ui-datepicker-current').show(); }); $('.default100YearsPast').attr('placeholder', 'dd-mm-yyyy').change(function () { $(this).datepicker('setDate', $(this).datepicker('getDate')); }).datepicker({ dateFormat: "dd-mm-yy", showButtonPanel: true, changeYear: true, changeMonth: true, yearRange: "-100:+0" }).focus(function () { $('button.ui-datepicker-current').show(); }); $('.monthYear-picker').attr('placeholder', 'mm-yyyy').datepicker({ dateFormat: "mm-yy", showButtonPanel: true, changeYear: true, changeMonth: true, yearRange: "-10:+10", }).focus(function () { $('button.ui-datepicker-current').hide(); }); $('.disconnectionDateValidation').attr('placeholder', 'dd-mm-yyyy').change(function () { $(this).datepicker('setDate', $(this).datepicker('getDate')); }).datepicker({ dateFormat: "dd-mm-yy", changeYear: true, showButtonPanel: true, changeMonth: true, yearRange: "-0:+1", minDate: addBusinessDays(new Date(), 4), beforeShowDay: $.datepicker.noWeekends // disable weekends }).focus(function () { $('button.ui-datepicker-current').show(); }); $('input[type="datetime"].date-auto-format,input[type="text"].date-auto-format').on('keydown paste input', function () { var element = this; var result = element.value; if (result.length > 2) { var dateFormat = $(element).datepicker('option', 'dateFormat'); if (dateFormat == null) { dateFormat = element.placeholder; } if (dateFormat == 'dd-mm-yy' || dateFormat == 'dd-mm-yyyy') { if (result.length > 2 && result.substr(2, 1) != '-') { result = result.substring(0, 2) + '-' + result.substring(2, result.length); } if (result.length > 5 && result.substr(5, 1) != '-') { result = result.substring(0, 5) + '-' + result.substring(5, result.length); } } else if (dateFormat == 'mm-yy' || dateFormat == 'mm-yyyy') { if (result.length > 2 && result.substr(2, 1) != '-') { result = result.substring(0, 2) + '-' + result.substring(2, result.length); } } element.value = result; } }); } var elements = $('.forceDisable'); for (var i = 0; i < elements.length; i++) { $(elements[i]).attr("disabled", "disabled") } }); function addBusinessDays(d, n) { d = new Date(d.getTime()); var day = d.getDay(); d.setDate(d.getDate() + n + (day === 6 ? 2 : +!day) + (Math.floor((n - 1 + (day % 6 || 1)) / 5) * 2)); return d; } //****************************************************************** // Start Copy to Clipboard function copyText(event, link, value) { copyTextToClipboard(link, value); event.stopPropagation(); event.preventDefault(); } function copyURL(event) { var link = $(event.target).siblings('a')[0]; if (link === null || link === undefined) link = $(event.target).parent('a').first().siblings('a')[0]; if (link !== null && link !== undefined) copyTextToClipboard(link, link.href); event.stopPropagation(); event.preventDefault(); } function fallbackCopyTextToClipboard(element, text) { var textArea = document.createElement("textarea"); textArea.value = text; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var success = document.execCommand('copy'); var msg = success ? 'successful' : 'unsuccessful'; console.log('Fallback: Copying text command was ' + msg); showCopyTooltip(element, success); } catch (err) { console.error('Fallback: Oops, unable to copy', err); showCopyTooltip(element, false); } document.body.removeChild(textArea); } function copyTextToClipboard(element, text) { if (!navigator.clipboard) { fallbackCopyTextToClipboard(element, text); return; } navigator.clipboard.writeText(text).then(function () { console.log('Async: Copying to clipboard was successful!'); showCopyTooltip(element, true); }, function (err) { console.error('Async: Could not copy text: ', err); showCopyTooltip(element, false); }); } function showCopyTooltip(element, success) { if (element === undefined || element === null) return; if (!$(element).hasClass('copy-to-clipboard')) element = $(element).siblings('a.copy-to-clipboard').first(); if (element === undefined || element === null) return; var successMsg = $(element).attr('data-tooltip'); if (successMsg == '') { successMsg = 'Link Copied'; } $(element).attr('data-original-title', success ? successMsg : 'Error Copying Link'); $(element).tooltip('show'); setTimeout(function () { $(element).tooltip('hide'); }, 750); } //End Copy to Clipboard //****************************************************************** //urlPrefix when passed must include Content/Images in path function getImageLanguageUrlPrefix(urlPrefix) { if (urlPrefix == undefined) { urlPrefix = 'Content/Images'; } if (urlPrefix == '') { urlPrefix = 'Content/Images'; } var imgPrefix = document.getElementById('hfImagePathPrefix'); var langUrl = ''; if (imgPrefix != undefined && typeof (imgPrefix) != 'undefined' && imgPrefix != null) { langUrl = urlPrefix + '/' + imgPrefix.value; } else { langUrl = urlPrefix + '/en-AU'; } return langUrl; } //Returns true if hidden function isElementHidden(elem) { return elem.style.display == "none" || !( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); } function getCookie(cookieName) { var name = cookieName + "="; var decodedCookie = decodeURIComponent(document.cookie); var cookieItems = decodedCookie.split(';'); for (var i = 0; i < cookieItems.length; i++) { var c = cookieItems[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function getKeyValueInCookie(keyName, cookieName) { var cookieValue = getCookie(cookieName); var name = keyName + "="; var keyValues = cookieValue.split('&'); for (var i = 0; i < keyValues.length; i++) { var c = keyValues[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } $.fn.bindFirst = function (name, fn) { // bind as you normally would // don't want to miss out on any jQuery magic this.on(name, fn); // Thanks to a comment by @Martin, adding support for // namespaced events too. this.each(function () { var handlers = $._data(this, 'events')[name.split('.')[0]]; //console.log(handlers); // take out the handler we just inserted from the end var handler = handlers.pop(); // move it at the beginning handlers.splice(0, 0, handler); }); }; var expiryTime; /* check session expiry... * on page load * in (expiry - now) time * on step change */ // call this on document.ready() function manageSession(pageName) { reloadIfExpired(pageName); setTimeout(function () { sessionExpired(); }, (expiryTime - new Date())); } // call this to simply check if session has expired function isSessionExpired(pageName) { if (expiryTime === undefined) { var cookieSessionExpiry = getKeyValueInCookie("SessionExpiryUtc", pageName); if (cookieSessionExpiry == "") { return true; } expiryTime = new moment(cookieSessionExpiry).utc().toDate(); if (isNaN(expiryTime.getTime())) { return false; } } return new Date().getTime() >= expiryTime.getTime(); } // call this on, for example, tab changes function reloadIfExpired(pageName) { // Disable this functionality for now, return false always return false; if (isSessionExpired(pageName)) { sessionExpired(); return true; } return false; } function sessionExpired() { // warn user // $('#modalSessionExpired').on('hidden.bs.modal', function (e) { // // persist entered data? // // reload // window.location.reload(true); // }).modal('show'); } function initStyleSheets() { if ($('#hfWhitelabel').val() != null && $('#hfWhitelabel').val() != undefined) { if ($('#hfWhitelabel').val().toLowerCase() == 'true') { var primaryColour = $('#hfPrimaryColour').val(); var secondaryColour = $('#hfSecondaryColour').val(); var headerColour = $('#hfHeaderColour').val(); var primaryTextColour = $('#hfPrimaryTextColour').val(); var secondaryTextColour = $('#hfSecondaryTextColour').val(); var invertBlackWhite = $('#hfInvertBlackWhite').val(); var disableBackgroundGradient = $('#hfDisableGradient').val(); const root = document.documentElement; // Setting primary and secondary colours root.style.setProperty('--primaryColourOverride', primaryColour); root.style.setProperty('--secondaryColourOverride', secondaryColour); root.style.setProperty('--headerColourOverride', headerColour); root.style.setProperty('--primaryTextColourOverride', primaryTextColour); root.style.setProperty('--secondaryTextColourOverride', secondaryTextColour); // Inverting black and white text in buttons if (invertBlackWhite?.toLocaleLowerCase() == 'true') { root.style.setProperty('--overrideWhite', '#000000'); root.style.setProperty('--overrideBlack', '#FFFFFF') } else { root.style.removeProperty('--overrideWhite'); root.style.removeProperty('--overrideBlack'); } // Disabling background gradients if (disableBackgroundGradient?.toLocaleLowerCase() == 'true') { root.style.setProperty('--overrideGradient', 'white'); } else { root.style.removeProperty('--overrideGradient'); } createCSSSelector('input[type=range]::-webkit-slider-thumb', 'background-image: none'); createCSSSelector('input[type=range]::-webkit-slider-thumb', 'background: ' + primaryColour + ' !important'); createCSSSelector('input[type=range]::-webkit-slider-thumb', 'background-color: ' + primaryColour + ' !important'); } } } var siteUtilities = function () { this.IsMobile = function () { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) return true; return false; } this.MinIEVersion = function (version) { return (!window.document.documentMode || window.document.documentMode >= version); } this.GetSpinner = function (message) { var html = ''; if (message != null && message != "") { html = html + "
" + message + "
"; } html = html + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
"; return html; } } var whitelabelUtilities = function () { //need to be get methods after document is populated this.whitelabelEnabled = function () { var on = $('#hfWhitelabel'); if (on != null && $(on).val().toLowerCase() == 'true') { return true; } return false; } this.getMovingEnabled = function () { var on = $('#hfWhitelabelMovingEnabled'); if (on != null && $(on).val().toLowerCase() == 'true') { return true; } return false; } this.getSwitchingEnabled = function () { var on = $('#hfWhitelabelSwitchingEnabled'); if (on != null && $(on).val().toLowerCase() == 'true') { return true; } return false; } this.getPrimaryColour = function () { return $('#hfPrimaryColour').val(); } this.getSecondaryColour = function () { return $('#hfSecondaryColour').val(); } }; function createCSSSelector(selector, style) { if (!document.styleSheets) return; if (document.getElementsByTagName('head').length == 0) return; var styleSheet, mediaType; if (document.styleSheets.length > 0) { for (var i = 0, l = document.styleSheets.length; i < l; i++) { if (document.styleSheets[i].disabled || (document.styleSheets[i].href == null || !document.styleSheets[i].href.includes("/Site_"))) continue; var media = document.styleSheets[i].media; mediaType = typeof media; if (mediaType === 'string') { if (media === '' || (media.indexOf('screen') !== -1)) { styleSheet = document.styleSheets[i]; } } else if (mediaType == 'object') { if (media.mediaText === '' || (media.mediaText.indexOf('screen') !== -1)) { styleSheet = document.styleSheets[i]; } } if (typeof styleSheet !== 'undefined') break; } } if (typeof styleSheet === 'undefined') { var styleSheetElement = document.createElement('style'); styleSheetElement.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(styleSheetElement); for (i = 0; i < document.styleSheets.length; i++) { if (document.styleSheets[i].disabled) { continue; } styleSheet = document.styleSheets[i]; } mediaType = typeof styleSheet.media; } if (mediaType === 'string') { for (var i = 0, l = styleSheet.rules.length; i < l; i++) { if (styleSheet.rules[i].selectorText && styleSheet.rules[i].selectorText.toLowerCase() == selector.toLowerCase()) { styleSheet.rules[i].style.cssText = style; return; } } styleSheet.addRule(selector, style); } else if (mediaType === 'object') { var styleSheetLength = (styleSheet.cssRules) ? styleSheet.cssRules.length : 0; for (var i = 0; i < styleSheetLength; i++) { if (styleSheet.cssRules[i].selectorText && styleSheet.cssRules[i].selectorText.toLowerCase() == selector.toLowerCase()) { styleSheet.cssRules[i].style.cssText = style; return; } } styleSheet.insertRule(selector + '{' + style + '}', styleSheetLength); } } function inputsValid(inputs, allowEmpty, validateHidden) { if (allowEmpty == undefined) { allowEmpty = true; } if (validateHidden == undefined) { validateHidden = false; } if (inputs.length == 0) return true; return Array.from(inputs).every(function (input) { input = $(input); var inputOriginallyHidden = input.is(":hidden"); var inputIsHiddenType = input.attr('type') === 'hidden'; if (!allowEmpty && input.val().trim() == "") { return false; } // offsetParent will not work with body, html, or fixed elements var hiddenEl; if (validateHidden && inputOriginallyHidden) { hiddenEl = $(input).parents('[style*="display: none;"], .hidden-np'); if (hiddenEl.length > 0) { $(hiddenEl).show(); } else if (inputIsHiddenType) { input.removeAttr('type'); } else { input.show(); } } var valid = input.valid(); //restore them to original visibility if (validateHidden && hiddenEl != null) { if (hiddenEl.length > 0) { $(hiddenEl).hide(); } else if (inputIsHiddenType) { input.attr('type', 'hidden'); } else { input.hide(); } } return valid; }); } $.validator.methods.date = function (value, element) { var isValid = this.optional(element) || moment(value, "DD.MM.YYYY", false).isValid(); return isValid; }; jQuery.validator.addMethod("requiredif", function (value, element, params) { if (element.type == 'radio') { var radios = $('input[type=radio][name="' + element.name + '"]:checked'); if (radios != null && radios.length > 0) { return true; } } else { if ($(element).val() != '') { return true; } } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + params.other + '"], select[name$="' + path + '.' + params.other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return params.comp == 'isequalto' ? (otherVal.toLowerCase() != params.value.toLowerCase()) : (otherVal.toLowerCase() == params.value.toLowerCase()); } }); jQuery.validator.unobtrusive.adapters.add("requiredif", ["other", "comp", "value"], function (options) { options.rules['requiredif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value }; options.messages['requiredif'] = options.message; } ); jQuery.validator.addMethod("trueif", function (value, element, params) { if ($(element).val() != '') { var value = false; if (element.type.toUpperCase() == "CHECKBOX") { value = element.checked ? 'true' : 'false'; } else { value = element.value } if (value.toLowerCase() == 'true') { return true; } } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + params.other + '"], select[name$="' + path + '.' + params.other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return params.comp == 'isequalto' ? (otherVal.toLowerCase() != params.value.toLowerCase()) : (otherVal.toLowerCase() == params.value.toLowerCase()); } }); jQuery.validator.unobtrusive.adapters.add("trueif", ["other", "comp", "value"], function (options) { options.rules['trueif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value }; options.messages['trueif'] = options.message; } ); jQuery.validator.addMethod("rangeif", function (value, element, params) { if ($(element).val() != '' && parseInt($(element).val()) >= params.min && parseInt($(element).val()) <= params.max) { return true; } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + params.other + '"], select[name$="' + path + '.' + params.other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return params.comp == 'isequalto' ? (otherVal.toLowerCase() != params.value.toLowerCase()) : (otherVal.toLowerCase() == params.value.toLowerCase()); } }); jQuery.validator.unobtrusive.adapters.add("rangeif", ["other", "comp", "value", "min", "max"], function (options) { options.rules['rangeif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, min: options.params.min, max: options.params.max }; options.messages['rangeif'] = options.message; } ); jQuery.validator.addMethod("lengthif", function (value, element, params) { return validateLengthIf(element, params.other, params.comp, params.value, params.requiredlength); }); jQuery.validator.unobtrusive.adapters.add("lengthif", ["other", "comp", "value", "requiredlength"], function (options) { options.rules['lengthif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, requiredlength: options.params.requiredlength }; options.messages['lengthif'] = options.message; } ); jQuery.validator.addMethod("lengthifmultiple", function (value, element, params) { var others = params.other.split('!'); var comps = params.comp.split('!'); var values = params.value.split('!'); var requiredlengths = params.requiredlength.split('!'); var messages = params.errorMsgs.split('!'); var errMsg = ""; var invalid = true; for (var i = 0; i < others.length; i++) { invalid = !validateLengthIf(element, others[i], comps[i], values[i], requiredlengths[i]); if (invalid) { errMsg = messages[i]; break; } } var evalStr = 'this.settings.messages["' + $(element).attr("name") + '"].lengthifmultiple="' + errMsg + '"'; eval(evalStr); return !invalid; }); jQuery.validator.unobtrusive.adapters.add("lengthifmultiple", ["other", "comp", "value", "requiredlength"], function (options) { options.rules['lengthifmultiple'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, requiredlength: options.params.requiredlength, errorMsgs: options.message }; options.messages['lengthifmultiple'] = ""; //options.message; } ); function validateLengthIf(element, other, comp, value, requiredlength) { if ($(element).val().length == requiredlength) { return true; } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + other + '"], select[name$="' + path + '.' + other + '"]') if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return comp == 'isequalto' ? (otherVal.toLowerCase() != value.toLowerCase()) : (otherVal.toLowerCase() == value.toLowerCase()); } } jQuery.validator.addMethod("minlengthif", function (value, element, params) { return validateMinLengthIf(element, params.other, params.comp, params.value, params.min); }); jQuery.validator.unobtrusive.adapters.add("minlengthif", ["other", "comp", "value", "min"], function (options) { options.rules['minlengthif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, requiredlength: options.params.min }; options.messages['minlengthif'] = options.message; } ); jQuery.validator.addMethod("minlengthifmultiple", function (value, element, params) { var others = params.other.split('!'); var comps = params.comp.split('!'); var values = params.value.split('!'); var mins = params.min.split('!'); var messages = params.errorMsgs.split('!'); var errMsg = ""; var invalid = true; for (var i = 0; i < others.length; i++) { invalid = !validateMinLengthIf(element, others[i], comps[i], values[i], mins[i]); if (invalid) { errMsg = messages[i]; break; } } var evalStr = 'this.settings.messages["' + $(element).attr("name") + '"].minlengthifmultiple="' + errMsg + '"'; eval(evalStr); return !invalid; }); jQuery.validator.unobtrusive.adapters.add("minlengthifmultiple", ["other", "comp", "value", "min"], function (options) { options.rules['minlengthifmultiple'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, min: options.params.min, errorMsgs: options.message }; options.messages['minlengthifmultiple'] = ""; //options.message; } ); function validateMinLengthIf(element, other, comp, value, requiredlength) { if ($(element).val() != '' && $(element).val().length >= requiredlength) { return true; } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + other + '"], select[name$="' + path + '.' + other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return comp == 'isequalto' ? (otherVal.toLowerCase() != value.toLowerCase()) : (otherVal.toLowerCase() == value.toLowerCase()); } } jQuery.validator.addMethod("maxlengthif", function (value, element, params) { return validateMaxLengthIf(element, params.other, params.comp, params.value, params.requiredlength); }); jQuery.validator.unobtrusive.adapters.add("maxlengthif", ["other", "comp", "value", "max"], function (options) { options.rules['maxlengthif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, maxlength: options.params.maxlength }; options.messages['maxlengthif'] = options.message; } ); jQuery.validator.addMethod("maxlengthifmultiple", function (value, element, params) { var others = params.other.split('!'); var comps = params.comp.split('!'); var values = params.value.split('!'); var maxs= params.max.split('!'); var messages = params.errorMsgs.split('!'); var errMsg = ""; var invalid = true; for (var i = 0; i < others.length; i++) { invalid = !validateMaxLengthIf(element, others[i], comps[i], values[i], maxs[i]); if (invalid) { errMsg = messages[i]; break; } } var evalStr = 'this.settings.messages["' + $(element).attr("name") + '"].maxlengthifmultiple="' + errMsg + '"'; eval(evalStr); return !invalid; }); jQuery.validator.unobtrusive.adapters.add("maxlengthifmultiple", ["other", "comp", "value", "max"], function (options) { options.rules['maxlengthifmultiple'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, max: options.params.max, errorMsgs: options.message }; options.messages['maxlengthifmultiple'] = ""; //options.message; } ); function validateMaxLengthIf(element, other, comp, value, maxlength) { if ($(element).val().length <= maxlength) { return true; } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + other + '"], select[name$="' + path + '.' + other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return comp == 'isequalto' ? (otherVal.toLowerCase() != value.toLowerCase()) : (otherVal.toLowerCase() == value.toLowerCase()); } } jQuery.validator.addMethod("notequalif", function (value, element, params) { return validateNotEqualIf(element, params.other, params.comp, params.value, params.notequal); }); jQuery.validator.unobtrusive.adapters.add("notequalif", ["other", "comp", "value", "notequal"], function (options) { options.rules['notequalif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, notequal: options.params.notequal }; options.messages['notequalif'] = options.message; } ); jQuery.validator.addMethod("notequalifmultiple", function (value, element, params) { var others = params.other.split('!'); var comps = params.comp.split('!'); var values = params.value.split('!'); var notequals = params.notequal.split('!'); var messages = params.errorMsgs.split('!'); var errMsg = ""; var invalid = true; for (var i = 0; i < others.length; i++) { invalid = !validateNotEqualIf(element, others[i], comps[i], values[i], notequals[i]); if (invalid) { errMsg = messages[i]; break; } } var evalStr = 'this.settings.messages["' + $(element).attr("name") + '"].notequalifmultiple="' + errMsg + '"'; eval(evalStr); return !invalid; }); jQuery.validator.unobtrusive.adapters.add("notequalifmultiple", ["other", "comp", "value", "max"], function (options) { options.rules['notequalifmultiple'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, notequal: options.params.notequal, errorMsgs: options.message }; options.messages['notequalifmultiple'] = ""; //options.message; } ); function validateNotEqualIf(element, other, comp, value, notequal) { if ($(element).val() != '' && $(element).val() != notequal) { return true; } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + other + '"], select[name$="' + path + '.' + other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return comp == 'isequalto' ? (otherVal.toLowerCase() != value.toLowerCase()) : (otherVal.toLowerCase() == value.toLowerCase()); } } jQuery.validator.addMethod("istrue", function (value, element, param) { if ($(element).val() != '') { var value = 'false'; if (element.type.toUpperCase() == "CHECKBOX") { value = element.checked ? 'true' : 'false'; } else { value = element.value } if (value.toLowerCase() == 'true') { return true; } } return value == 'true'; }); jQuery.validator.unobtrusive.adapters.add("istrue", function (options) { options.rules['istrue'] = { }; options.messages['istrue'] = options.message; }); jQuery.validator.addMethod("isfalse", function (value, element, params) { if ($(element).val() != '') { var value = false; if (element.type.toUpperCase() == "CHECKBOX") { value = element.checked ? 'false' : 'true'; } else { value = element.value; } if (value.toLowerCase() == 'false') { return true; } } return false; }); jQuery.validator.unobtrusive.adapters.add("isfalse", function (options) { options.rules['isfalse'] = { }; options.messages['isfalse'] = options.message; }); jQuery.validator.addMethod("validdaysif", function (value, element, params) { return validateVaidDaysIf(element, params.other, params.comp, params.value, params.daysofweek); }); jQuery.validator.unobtrusive.adapters.add("validdaysif", ["other", "comp", "value", "daysofweek"], function (options) { options.rules['validdaysif'] = { other: options.params.other, comp: options.params.comp, value: options.params.value, daysofweek: options.params.daysofweek, errorMsgs: options.message }; options.messages['validdaysif'] = options.message; } ); jQuery.validator.addMethod("validdays", function (value, element, params) { return validateVaidDaysIf(element, params, "isequalto", true, params.daysofweek); }); jQuery.validator.unobtrusive.adapters.add("validdays", ["other", "comp", "value", "daysofweek"], function (options) { options.rules['validdays'] = { daysofweek: options.params.daysofweek }; options.messages['validdays'] = options.message; } ); function validateVaidDaysIf(element, other, comp, value, daysofweek) { if (daysofweek == null || daysofweek == "" || element == null || $(element).val() == null || $(element).val() == "") { } else { var days = JSON.parse(daysofweek); var inputVal = new moment($(element).val(), 'DD/MM/YYYY'); if (!inputVal._isValid) { //return false; } else if (days.includes(inputVal._d.getDay())) { return true; } } var path = element.name.substr(0, element.name.lastIndexOf(".")); var elementSearch = $('input[name$="' + path + '.' + other + '"], select[name$="' + path + '.' + other + '"]'); if (elementSearch != null && (elementSearch.length == 1 || (elementSearch.length == 2 && elementSearch[0].type.toUpperCase() == "CHECKBOX") || (elementSearch.length > 1 && !!Array.from(elementSearch).reduce(function (a, b) { return (a.value === b.value) ? a : NaN; })))) { var $other = elementSearch[0]; var otherVal = ($other.type.toUpperCase() == "CHECKBOX") ? ($other.checked ? "true" : "false") : $other.value; return comp == 'isequalto' ? (otherVal.toLowerCase() != value.toLowerCase()) : (otherVal.toLowerCase() == value.toLowerCase()); } } jQuery.validator.addMethod("dateinthefuture", function (value, element, params) { return moment(value, "DD-MM-YYYY HH:mm", true) > new moment(); }); jQuery.validator.unobtrusive.adapters.add("dateinthefuture", function (options) { options.rules['dateinthefuture'] = { }; options.messages['dateinthefuture'] = options.message; }); const sitehelper = new siteUtilities(); const whitelabelhelper = new whitelabelUtilities(); const sanitizeFileName = (filename) => { return decodeURI(filename).replace(/[^\-\w.()]+/gi, "_").replace(/[-]+/gi, "-"); } function GooglePlaces() { this.tbAddress = null; this.tbStreetNo = null; this.tbStreet = null; this.tbSuburb = null; this.ddlState = null; this.tbPostCode = null; this.hfLat = null; this.hfLong = null; this.geocoder = null; this.lat = null; this.long = null; this.manualAddressCollapse = null; this.aManualAddressCollapse = null; } GooglePlaces.prototype = { initialise: function (tbAddress, tbStreetNo, tbStreet, tbSuburb, ddlState, tbPostCode, manualAddressCollapse, aManualAddressCollapse, mapID, hfLat, hfLong, onChangeCallBack) { var helper = this; helper.tbAddress = document.getElementById(tbAddress); helper.tbStreetNo = document.getElementById(tbStreetNo); helper.tbStreet = document.getElementById(tbStreet); helper.tbSuburb = document.getElementById(tbSuburb); helper.ddlState = document.getElementById(ddlState); helper.tbPostCode = document.getElementById(tbPostCode); helper.manualAddressCollapse = document.getElementById(manualAddressCollapse); helper.aManualAddressCollapse = document.getElementById(aManualAddressCollapse); helper.hfLat = document.getElementById(hfLat); helper.hfLong = document.getElementById(hfLong); var options = { componentRestrictions: { country: 'au' } }; // Add google places auto complete to address search box helper.searchBox = new google.maps.places.Autocomplete(helper.tbAddress, options); helper.map = new google.maps.Map(document.getElementById(mapID), {}); helper.placesService = new google.maps.places.PlacesService(helper.map); // Enable enter key or tab key within search box for triggering auto complete logic (function pacSelectFirst(tbAddress) { // store the original event binding function var _addEventListener = (tbAddress.addEventListener) ? tbAddress.addEventListener : tbAddress.attachEvent; function addEventListenerWrapper(type, listener) { // Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected, // and then trigger the original listener. if (type === "keydown") { var orig_listener = listener; listener = function (event) { // If there is more than one google places search result, // fire arrow down event to select & trigger place_changed event var suggestion_selected = $(".pac-item-selected").length > 0; if (event.which >= 9 && event.which <= 13 && !suggestion_selected) { var simulated_downarrow = $.Event("keydown", { keyCode: 40, which: 40 }); orig_listener.apply(tbAddress, [simulated_downarrow]); } orig_listener.apply(tbAddress, [event]); }; } _addEventListener.apply(tbAddress, [type, listener]); } tbAddress.addEventListener = addEventListenerWrapper; tbAddress.attachEvent = addEventListenerWrapper; helper.searchBox = new google.maps.places.Autocomplete(tbAddress, options); })(helper.tbAddress); // Perform address search logic whenever user changes the selected google place in search box helper.searchBox.addListener('place_changed', function () { var place = helper.searchBox.getPlace(); selectedPlaceID = place.place_id; helper.performAddressSearch(helper); if (onChangeCallBack != null) { onChangeCallBack(); } }); if (this.aManualAddressCollapse != null) { // Initialise collapse up/down symbols for accordions $(this.aManualAddressCollapse.querySelectorAll('span.down')).show(); $(this.aManualAddressCollapse.querySelectorAll('span.up')).hide(); $(this.manualAddressCollapse).on('show.bs.collapse', function () { helper.tbAddress.value = ''; selectedPlaceID = ''; $(helper.aManualAddressCollapse.querySelectorAll('span.down')).hide(); $(helper.aManualAddressCollapse.querySelectorAll('span.up')).show(); }); $(this.manualAddressCollapse).on('hide.bs.collapse', function () { $(helper.aManualAddressCollapse.querySelectorAll('span.down')).show(); $(helper.aManualAddressCollapse.querySelectorAll('span.up')).hide(); }); } }, performAddressSearch: function (helper) { var place = helper.searchBox.getPlace(); if (place.name == '') { // TODO return; } if (place == null || place.address_components == undefined) { var findPlaceRequest = { query: place.name, fields: ['name', 'place_id'] }; placesService.findPlaceFromQuery(findPlaceRequest, function (results, status) { if (status != google.maps.places.PlacesServiceStatus.OK) { // TODO return; } var getDetailsRequest = { placeId: results[0].place_id, fields: ['place_id', 'name', 'address_component'] }; placesService.getDetails(getDetailsRequest, function (place, status) { if (status != google.maps.places.PlacesServiceStatus.OK) { // TODO return; } this.populateAddressFromPlace(place); }); }); } else { this.populateAddressFromPlace(place, helper); } }, populateAddressFromPlace: function (place, helper) { var streetNo = ''; var street = ''; var suburb = ''; var postcode = ''; var state = ''; if (place.address_components !== undefined && place !== null && place.name !== '') { if (!isElementHidden(helper.tbStreetNo)) { $(helper.manualAddressCollapse).collapse('hide'); } selectedPlaceID = place.place_id; console.log(selectedPlaceID); for (var i = 0; i < place.address_components.length; i++) { var componentType = place.address_components[i].types[0]; if (componentType === 'street_number') { streetNo = place.address_components[i].long_name.trim(); helper.tbStreetNo.value = streetNo; } else if (componentType === 'route') { street = place.address_components[i].long_name; helper.tbStreet.value = street; /* The Google Places API does not handle units/addresses with a subpremise well * E.g. if 805/37 Archer Street Toowong QLD 4066 is returned as the formatted address from the API, * the address components WILL NOT contain 805 in the street no or any other component. As a result * we repalce the streetNo retrieved from the street_number address component with all characters * that appear prior to the street name (first occurence, this handles if a street name and suburb * name are the same). */ // Get the part of the formatted address that appears prior to the street name var regex = RegExp('^(.*?)' + street); var result = regex.exec(helper.tbAddress.value); //console.log(result); // Replace the streetNo with whatever appears in front of the street name of the formatted address if (Array.isArray(result)) { streetNo = result[1].trim(); } helper.tbStreetNo.value = streetNo; } else if (componentType === 'locality') { suburb = place.address_components[i].long_name; helper.tbSuburb.value = suburb; } else if (componentType === 'postal_code') { postcode = place.address_components[i].long_name; helper.tbPostCode.value = postcode; } else if (componentType === 'administrative_area_level_1') { state = place.address_components[i].short_name; $('#' + helper.ddlState.id + ' option') .filter(function () { return $(this).text() == state; }).prop('selected', true); $(helper.ddlState).trigger('change'); } } helper.tbAddress.value = streetNo + ' ' + street + ' ' + suburb + ' ' + state + ' ' + postcode; this.populateLatLong(place, helper) } }, populateLatLong: function (place, helper) { if (helper.hfLat != null) { helper.hfLat.value = place.geometry.location.lat(); } if (helper.hfLong != null) { helper.hfLong.value = place.geometry.location.lng(); } } } //$(function () { // //$("input[type=datetime]").datepicker({ dateFormat: "dd-mm-yy" }); // $("input[type=datetime]").flatpickr({ // dateFormat: "d-m-Y", allowInput: true, onclose: function (selectedDates, dateStr, instance) { // if (instance.isMobile) { // $('form input[type="date"][step="any"]').removeAttr('step'); // } // } }); // //$.validator.methods.date = function (value, element) { // // return this.optional(element) || moment(value, "DD-MM-YYYY", true).isValid(); // //}; //}); //$(function () { // $("input[type=datetime]").datepicker({ // dateFormat: "dd-mm-yy", // changeYear: true, // changeMonth: true, // showButtonPanel: true, // yearRange: "-100:+1", // last hundred years // defaultDate: '15-06-1990' // }) // .focus(function () { // $('button.ui-datepicker-current').hide(); // }); // $.validator.methods.date = function (value, element) { // var isValid = this.optional(element) || moment(value, "DD.MM.YYYY", false).isValid(); // return isValid; // }; //}); $(document).ready(function () { initialise(); var modalSecondaryMobileText = $('#hfModalSecondaryMobileText').val(); var modalMobileBody = $('#hfModalMobileBody').val(); var modalEmailText = $('#hfModalEmailText').val(); var modalEmailBody = $('#hfModalEmailBody').val(); function initialise() { var success = $('#Success').val(); if (success === 1 || success === 'True') { $('#newOccupantDetails').hide(); $("#existingOccupantDetails").fadeIn(); $('#successMessage').show(); } else { $('#successMessage').hide(); } // modal pop-up $('#dialog').hide(); $('#errorModal').modal({ show: false }); //document.getElementById('form').onsubmit = function () { // return true //}; function isValidForm() { if (validateMobile('tbMobile') === false) { $('#tbMobile').addClass('input-validation-error'); SetErrorModal(modalSecondaryMobileText, modalMobileBody); customError = true; return false; } else { $('#tbMobile').removeClass('input-validation-error'); } if (validateEmail('Email') === false) { $('#Email').addClass('input-validation-error'); SetErrorModal(modalEmailText, modalEmailBody); customError = true; return false; } else { $('#Email').removeClass('input-validation-error'); } if ($("form").valid()) { $('#modalLoading').modal('show'); return true; } else { return false; } } function validateMobile(elementID) { var mobile = document.getElementById(elementID); // remove any non numerical characters var strippedMobile = mobile.value.replace(/\D/g, ''); // if stripped mobile begins with 614, replace the 61 with a 0 if (strippedMobile.substring(0, 3) === '614') strippedMobile = '0' + strippedMobile.substring(2); // if stripped mobile begins with 610, replace the 610 with a 0 if (strippedMobile.substring(0, 3) === '610') strippedMobile = '0' + strippedMobile.substring(3); mobile.value = strippedMobile; var validMobilePattern = /04[\d]{8}/g; // Ensure mobile starts with a 04 followed by 8 numeric digits var valid = validMobilePattern.test(strippedMobile); return valid; } function validateEmail(elementID) { var email = document.getElementById(elementID); validEmailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/g; var valid = validEmailPattern.test(email.value); return valid; } function SetErrorModal(title, body) { //these hfs store the translated text var modal = $('#errorModal'); var ModalErrorTitle = $('#hfModalErrorTitle').val(); var ModalErrorBody = $('#hfModalErrorBody').val(); if (title !== null) { ModalErrorTitle = title; } if (body !== null) { ModalErrorBody = body; } modal.find('.modal-body').text(ModalErrorBody); modal.find('.modal-title').text(ModalErrorTitle); $('#errorModal').modal('show'); } } }); // (AH) TODO: Move to standard js class syntax // (AH) TODO: Use a generic post method with data and endpoint params function PortalAPI(hostUrl, apiKey) { if (hostUrl === null || hostUrl === undefined || hostUrl === '') { this.hostUrl = 'https://api.movemein.com.au/API' } else { this.hostUrl = hostUrl; } this.apiKey = apiKey; } PortalAPI.prototype = { getAuthorizationHeader: function() { if (this.apiKey === null || this.apiKey.trim() === '') return {}; return { 'Authorization': 'API_KEY ' + this.apiKey }; }, energisationStatus: function(appToken) { return $.ajax({ url: this.hostUrl + '/App/EnergisationStatus/' + appToken, headers: this.getAuthorizationHeader(), async: true, method: 'GET', xhrFields: { withCredentials: true } }); }, getIdentification: function (appToken, occupantToken, dob, mobile) { var params = new URLSearchParams(); params.append('dateOfBirth', dob); params.append('mobile', mobile); return $.ajax({ url: this.hostUrl + '/App/Request/' + appToken + '/Identity/' + occupantToken + '?' + params.toString(), headers: this.getAuthorizationHeader(), async: true, method: 'GET', xhrFields: { withCredentials: true } }); }, getProviderConnectionDates: function (appToken, elecProviderPlans, gasProviderPlans, electricityDistributor, gasDistributorZone, dateTimeOverride) { return $.ajax({ url: this.hostUrl + '/App/Request/AppToken/' + appToken + '/GetProviderConnectionDates', headers: this.getAuthorizationHeader(), data: { 'appToken': appToken, 'elecProviderPlans': elecProviderPlans, 'gasProviderPlans': gasProviderPlans, 'electricityDistributor': electricityDistributor, 'gasDistributorZone': gasDistributorZone, 'dateTimeOverride': dateTimeOverride }, async: true, dataType: 'json', method: 'GET', xhrFields: { withCredentials: true } }); }, validateAddress: function(streetNumber, street, suburb, postcode, state) { return $.ajax({ url: this.hostUrl + '/App/ValidateAddress', headers: this.getAuthorizationHeader(), data: { 'streetNo': streetNumber, 'street': street, 'suburb': suburb, 'postcode': postcode, 'state': state }, dataType: 'json', async: false, method: 'GET', xhrFields: { withCredentials: true } }); }, electricityEstimate: function(occupantToken, duration, dailyConsumption, hasSolarPanels, encryptedPlanDTOs, billingUploadJson, allowDifferentBillTariff) { return $.ajax({ url: this.hostUrl + '/TypicalConsumptions/Electricity/Estimate', headers: this.getAuthorizationHeader(), data: { 'occupantToken': occupantToken, 'duration': duration, 'dailyConsumption': dailyConsumption, 'solarpanels': hasSolarPanels, 'encryptedPlanDTOs': encryptedPlanDTOs, 'billingUploadJSON': billingUploadJson, 'allowDifferentBillTariff': allowDifferentBillTariff }, dataType: 'json', async: false, method: 'POST', xhrFields: { withCredentials: true } }); }, gasEstimate: function(occupantToken, duration, dailyConsumption, encryptedPlanDTOs, billingUploadJson) { return $.ajax({ url: this.hostUrl + '/TypicalConsumptions/Gas/Estimate', headers: this.getAuthorizationHeader(), data: { 'occupantToken': occupantToken, 'duration': duration, 'dailyConsumption': dailyConsumption, 'encryptedPlanDTOs': encryptedPlanDTOs, 'billingUploadJSON': billingUploadJson }, dataType: 'json', async: false, method: 'POST', xhrFields: { withCredentials: true } }); }, typicalConsumptions: function(numberOccupants, duration, hasPool, hasGas, state) { return $.ajax({ url: this.hostUrl + '/TypicalConsumptions', headers: this.getAuthorizationHeader(), data: { 'occupants': numberOccupants, 'duration': duration, 'pool': hasPool, 'gas': hasGas, 'state': state }, dataType: 'json', async: true, method: 'GET', xhrFields: { withCredentials: true } }); }, uploadedBillEstimate: function(duration, dailyConsumption, uploadId, modelJson) { return $.ajax({ url: this.hostUrl + '/TypicalConsumptions/UploadedBill/Estimate', headers: this.getAuthorizationHeader(), data: { 'duration': duration, 'dailyConsumption': dailyConsumption, 'uploadID': uploadId, 'json': modelJson }, dataType: 'json', async: false, method: 'POST', xhrFields: { withCredentials: true } }); }, paymentDetails: function (providerID) { return $.ajax({ url: this.hostUrl + '/Provider/PaymentDetails', headers: this.getAuthorizationHeader(), data: { 'providerID': providerID }, dataType: 'json', async: false, method: 'GET', xhrFields: { withCredentials: true } }); }, // PxPay (Payment Gateway) pxPayURL: function (mmiRequestToken, providerID) { return $.ajax({ url: this.hostUrl + '/Provider/PxPayURL', headers: this.getAuthorizationHeader(), data: { 'mmiRequestToken': mmiRequestToken, 'providerID': providerID }, dataType: 'json', async: true, method: 'GET', xhrFields: { withCredentials: true } }); }, pxPayStatus: function (providerID, mmiRequestToken, pxPayTransactionToken) { return $.ajax({ url: this.hostUrl + '/App/PxPayStatus', headers: this.getAuthorizationHeader(), data: { 'providerID': providerID, 'pxPayTransactionToken': pxPayTransactionToken, 'mmiRequestToken': mmiRequestToken, }, dataType: 'json', async: true, method: 'GET', xhrFields: { withCredentials: true } }); }, setWhitelabelOverride: async function (mmiRequestToken, whitelabelId) { try { return $.ajax({ url: this.hostUrl + '/App/SetRequestWhitelabel', headers: this.getAuthorizationHeader(), data: { 'mmiRequestToken': mmiRequestToken, 'whitelabelId': whitelabelId }, method: 'GET', xhrFields: { withCredentials: true } }); } catch (e) { console.log(e); return false; } } };