diff --git a/CHANGELOG.md b/CHANGELOG.md index 280b1d1..fcf6cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 1.0.5 - 2021-10-15 +### Changed +- Updated the test file settings to show a more syntax-safe JSON object. + +### Fixed +- Script will not hide the `html` element while it's determining if it should render a message. + ## 1.0.4 - 2021-09-27 ### Added - Added `README.md`. diff --git a/dist/assets/sunset-to-sunset-legacy.min.js b/dist/assets/sunset-to-sunset-legacy.min.js index 2751155..e4ec7f8 100644 --- a/dist/assets/sunset-to-sunset-legacy.min.js +++ b/dist/assets/sunset-to-sunset-legacy.min.js @@ -1,2 +1,2 @@ -!function(){var t=document.createElement("style");t.innerHTML='.sts-banner{--tw-bg-opacity: 1;background-color:rgba(251,191,36,var(--tw-bg-opacity));position:relative;padding:.75rem;text-align:center;font-family:Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"}.sts-banner .sts-closing-time,.sts-banner .sts-opening-time{font-weight:600}html.sts-during-sabbath,html.sts-during-sabbath body{overflow:hidden}html.sts-during-sabbath body{max-height:100vh}.sts-full-message__container{top:0px;right:0px;bottom:0px;left:0px;position:absolute;--tw-bg-opacity: 1;background-color:rgba(255,255,255,var(--tw-bg-opacity));pointer-events:auto;overflow-y:scroll;z-index:500}.sts-full-message__heading{margin-bottom:1rem;font-size:3rem;font-weight:600}.sts-layout{display:flex;flex-wrap:wrap;margin-left:-.5rem;margin-right:-.5rem}.sts-layout .sts-layout__item{padding-left:.5rem;padding-right:.5rem}.sts-modal{width:90%;margin-left:auto;margin-right:auto;margin-top:7%;max-width:640px;justify-content:center}.sts-message-area{font-size:1rem;line-height:1.5rem;width:100%;text-align:center;padding-bottom:1rem}.sts-time-area{width:100%;text-align:center;border-top:1px solid lightgrey;padding-top:1rem}\n',document.head.appendChild(t),System.register([],(function(){"use strict";return{execute:function(){const t=(t,e)=>Object.assign(t,e),e=(t,e)=>{const n="cccc, LLLL d 'at' h:mm a ZZZZ";for(let s=0;s{console.log("Intializing Sunset to Sunset...");const n=luxon.DateTime,s=luxon.Duration,o=n.now();let a={};a["Current Time"]={Date:o.toLocaleString(n.DATE_FULL),Time:o.toLocaleString(n.TIME_WITH_SHORT_OFFSET)};const i=document.querySelector("template#sts-settings");let l={};i.dataset.days&&(l=JSON.parse(i.dataset.days));l=t(t({},{closing:5,opening:6}),l);const r=()=>l.closing,c=()=>l.opening,m=o.weekday==r()||o.weekday==c();let d={};i.dataset.settings&&(d=JSON.parse(i.dataset.settings)),d=t(t({},{guardDuration:{minutes:30},bannerDuration:{hours:3},location:{lat:0,long:0},simulateTime:!1,debug:!1}),d);const u=document.getElementsByTagName("html")[0];(m||d.simulateTime)&&(u.style.display="none"),d.simulateTime&&console.warn("%cThe `simulateTime` option is enabled for the Sunset to Sunset plugin. Remember to disable this option once you are done verifying the settings.","font-size: 16px"),d.debug&&(console.group("Sunset to Sunset intialized with the following options:"),console.dir(d),console.groupEnd());const g=()=>d.location,p=async t=>{const e=t.split("T")[0],s=await fetch("https://api.sunrise-sunset.org/json?&lat="+g().lat+"&lng="+g().long+"&date="+e+"&formatted=0"),o=await s.json();return n.fromISO(o.results.sunset)},b=()=>{let t=r()-o.weekday;const e=n.fromISO(o.plus({days:t})).toString();return p(e)},f=()=>{let t=c()-o.weekday;const e=n.fromISO(o.plus({days:t})).toString();return p(e)},h=()=>d.guardDuration,y=t=>t.minus(s.fromObject(d.bannerDuration)),S=(t,e)=>{let n;return"closing"==e&&(n=t.minus(h())),"opening"==e&&(n=t.plus(h())),n};if(m||d.simulateTime){let t=!1,s=!1,i=!1,l=!1;if(d.simulateTime)switch(d.simulateTime){case"preparation-day":t=!0;break;case"banner-up":s=!0;break;case"during-sabbath":i=!0;break;case"after-sabbath":l=!0}(async()=>{const t=Promise.all([b(),f()]);return await t})().then((([m,g])=>{const p=S(m,"closing"),b=S(g,"opening");if(d.simulateTime||(t=oy(p)&&o=p&&o<=b&&o.weekday>=r(),l=o>b&&o>=c()),t){const t=y(p).diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(s){((t,n)=>{const s=document.querySelector("template#sts-banner-template");let o;if(s)o=s;else{let t=document.createElement("template");t.innerHTML='\n\t\t\t
\n\t\t\t\tBecause of religious beliefs our store will be closed over the Sabbath hours.\n\t\t\t\tClosing on and will re-open on .\n\t\t\t
\n\t\t',o=t}const a=o.content.cloneNode(!0),i=a.querySelectorAll(".sts-closing-time");e(i,t);const l=a.querySelectorAll(".sts-opening-time");e(l,n),document.body.insertBefore(a,document.body.firstChild)})(p,b);const t=p.diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(i){(t=>{const n=document.querySelector("template#sts-full-message-template"),s=document.querySelector("template#sts-message-template"),o=n||s;let a;if(o)a=o.content.cloneNode(!0),a=a.firstElementChild;else{let t=document.createElement("div");t.innerHTML="\n\t\t\t

\n\t\t\t\tIn a world that seems to be spinning faster every day, we choose to stop \n\t\t\t\tand rest every Sabbath (Saturday). It’s a day for us to relax, refresh, \n\t\t\t\trefocus and worship; worship a God who loved us so much that He built a \n\t\t\t\tday of rest into Creation week and then commanded us to keep it \n\t\t\t\t(knowing we probably wouldn’t do it otherwise—even though it is for \n\t\t\t\tour best good).\n\t\t\t

\n\t\t",a=t}let i=document.createElement("template");i.innerHTML='\n\t\t
\n\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

Sabbath

\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

\n\t\t\t\t\t\tWe will re-open on .\n\t\t\t\t\t

\n\t\t\t\t
\n\t\t\t
\n\t\t\n\t\t
\n\t';const l=i.content.cloneNode(!0);if(n){let t=l.querySelector(".sts-full-message__container");for(;t.firstElementChild;)t.removeChild(t.firstChild);t.insertBefore(a,null)}else s&&l.querySelector(".sts-message-area").insertBefore(a,null);document.getElementsByTagName("html")[0].classList.add("sts-during-sabbath");const r=l.querySelectorAll(".sts-opening-time");e(r,t),document.body.insertBefore(l,document.body.firstChild)})(b);const t=b.diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(u.style.display="block",d.debug){let e={Enabled:{"Preparation day":t,"Banner up":s,"During the Sabbath":i,"After Sabbath":l}};console.group("Sunset to Sunset time checks"),console.table(e),console.groupEnd(),a["Banner up"]={Date:y(p).toLocaleString(n.DATE_FULL),Time:y(p).toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing guard"]={Date:p.toLocaleString(n.DATE_FULL),Time:p.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing sunset"]={Date:m.toLocaleString(n.DATE_FULL),Time:m.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening sunset"]={Date:g.toLocaleString(n.DATE_FULL),Time:g.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening guard"]={Date:b.toLocaleString(n.DATE_FULL),Time:b.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},console.group("Sunset to Sunset times"),console.table(a),console.groupEnd()}}))}else u.style.display="block",console.log("Sunset to Sunset: Exiting because today is not closing day")})()}}}))}(); +!function(){var t=document.createElement("style");t.innerHTML='.sts-banner{--tw-bg-opacity: 1;background-color:rgba(251,191,36,var(--tw-bg-opacity));position:relative;padding:.75rem;text-align:center;font-family:Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"}.sts-banner .sts-closing-time,.sts-banner .sts-opening-time{font-weight:600}html.sts-during-sabbath,html.sts-during-sabbath body{overflow:hidden}html.sts-during-sabbath body{max-height:100vh}.sts-full-message__container{top:0px;right:0px;bottom:0px;left:0px;position:absolute;--tw-bg-opacity: 1;background-color:rgba(255,255,255,var(--tw-bg-opacity));pointer-events:auto;overflow-y:scroll;z-index:500}.sts-full-message__heading{margin-bottom:1rem;font-size:3rem;font-weight:600}.sts-layout{display:flex;flex-wrap:wrap;margin-left:-.5rem;margin-right:-.5rem}.sts-layout .sts-layout__item{padding-left:.5rem;padding-right:.5rem}.sts-modal{width:90%;margin-left:auto;margin-right:auto;margin-top:7%;max-width:640px;justify-content:center}.sts-message-area{font-size:1rem;line-height:1.5rem;width:100%;text-align:center;padding-bottom:1rem}.sts-time-area{width:100%;text-align:center;border-top:1px solid lightgrey;padding-top:1rem}\n',document.head.appendChild(t),System.register([],(function(){"use strict";return{execute:function(){const t=(t,e)=>Object.assign(t,e),e=(t,e)=>{const n="cccc, LLLL d 'at' h:mm a ZZZZ";for(let o=0;o{console.log("Intializing Sunset to Sunset...");const n=luxon.DateTime,o=luxon.Duration,s=n.now();let a={};a["Current Time"]={Date:s.toLocaleString(n.DATE_FULL),Time:s.toLocaleString(n.TIME_WITH_SHORT_OFFSET)};const i=document.querySelector("template#sts-settings");let l={};i.dataset.days&&(l=JSON.parse(i.dataset.days));l=t(t({},{closing:5,opening:6}),l);const r=()=>l.closing,c=()=>l.opening,m=s.weekday==r()||s.weekday==c();let d={};i.dataset.settings&&(d=JSON.parse(i.dataset.settings)),d=t(t({},{guardDuration:{minutes:30},bannerDuration:{hours:3},location:{lat:0,long:0},simulateTime:!1,debug:!1}),d),d.simulateTime&&console.warn("%cThe `simulateTime` option is enabled for the Sunset to Sunset plugin. Remember to disable this option once you are done verifying the settings.","font-size: 16px"),d.debug&&(console.group("Sunset to Sunset intialized with the following options:"),console.dir(d),console.groupEnd());const u=()=>d.location,g=async t=>{const e=t.split("T")[0],o=await fetch("https://api.sunrise-sunset.org/json?&lat="+u().lat+"&lng="+u().long+"&date="+e+"&formatted=0"),s=await o.json();return n.fromISO(s.results.sunset)},p=()=>{let t=r()-s.weekday;const e=n.fromISO(s.plus({days:t})).toString();return g(e)},b=()=>{let t=c()-s.weekday;const e=n.fromISO(s.plus({days:t})).toString();return g(e)},f=()=>d.guardDuration,h=t=>t.minus(o.fromObject(d.bannerDuration)),S=(t,e)=>{let n;return"closing"==e&&(n=t.minus(f())),"opening"==e&&(n=t.plus(f())),n};if(m||d.simulateTime){let t=!1,o=!1,i=!1,l=!1;if(d.simulateTime)switch(d.simulateTime){case"preparation-day":t=!0;break;case"banner-up":o=!0;break;case"during-sabbath":i=!0;break;case"after-sabbath":l=!0}(async()=>{const t=Promise.all([p(),b()]);return await t})().then((([m,u])=>{const g=S(m,"closing"),p=S(u,"opening");if(d.simulateTime||(t=sh(g)&&s=g&&s<=p&&s.weekday>=r(),l=s>p&&s>=c()),t){const t=h(g).diff(s,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(o){((t,n)=>{const o=document.querySelector("template#sts-banner-template");let s;if(o)s=o;else{let t=document.createElement("template");t.innerHTML='\n\t\t\t
\n\t\t\t\tBecause of religious beliefs our store will be closed over the Sabbath hours.\n\t\t\t\tClosing on and will re-open on .\n\t\t\t
\n\t\t',s=t}const a=s.content.cloneNode(!0),i=a.querySelectorAll(".sts-closing-time");e(i,t);const l=a.querySelectorAll(".sts-opening-time");e(l,n),document.body.insertBefore(a,document.body.firstChild)})(g,p);const t=g.diff(s,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(i){(t=>{const n=document.querySelector("template#sts-full-message-template"),o=document.querySelector("template#sts-message-template"),s=n||o;let a;if(s)a=s.content.cloneNode(!0),a=a.firstElementChild;else{let t=document.createElement("div");t.innerHTML="\n\t\t\t

\n\t\t\t\tIn a world that seems to be spinning faster every day, we choose to stop \n\t\t\t\tand rest every Sabbath (Saturday). It’s a day for us to relax, refresh, \n\t\t\t\trefocus and worship; worship a God who loved us so much that He built a \n\t\t\t\tday of rest into Creation week and then commanded us to keep it \n\t\t\t\t(knowing we probably wouldn’t do it otherwise—even though it is for \n\t\t\t\tour best good).\n\t\t\t

\n\t\t",a=t}let i=document.createElement("template");i.innerHTML='\n\t\t
\n\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

Sabbath

\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

\n\t\t\t\t\t\tWe will re-open on .\n\t\t\t\t\t

\n\t\t\t\t
\n\t\t\t
\n\t\t\n\t\t
\n\t';const l=i.content.cloneNode(!0);if(n){let t=l.querySelector(".sts-full-message__container");for(;t.firstElementChild;)t.removeChild(t.firstChild);t.insertBefore(a,null)}else o&&l.querySelector(".sts-message-area").insertBefore(a,null);document.getElementsByTagName("html")[0].classList.add("sts-during-sabbath");const r=l.querySelectorAll(".sts-opening-time");e(r,t),document.body.insertBefore(l,document.body.firstChild)})(p);const t=p.diff(s,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(d.debug){let e={Enabled:{"Preparation day":t,"Banner up":o,"During the Sabbath":i,"After Sabbath":l}};console.group("Sunset to Sunset time checks"),console.table(e),console.groupEnd(),a["Banner up"]={Date:h(g).toLocaleString(n.DATE_FULL),Time:h(g).toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing guard"]={Date:g.toLocaleString(n.DATE_FULL),Time:g.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing sunset"]={Date:m.toLocaleString(n.DATE_FULL),Time:m.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening sunset"]={Date:u.toLocaleString(n.DATE_FULL),Time:u.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening guard"]={Date:p.toLocaleString(n.DATE_FULL),Time:p.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},console.group("Sunset to Sunset times"),console.table(a),console.groupEnd()}}))}else console.log("Sunset to Sunset: Exiting because today is not closing day")})()}}}))}(); //# sourceMappingURL=sunset-to-sunset-legacy.min.js.map diff --git a/dist/assets/sunset-to-sunset.min.js b/dist/assets/sunset-to-sunset.min.js index 9626125..13a0a1c 100644 --- a/dist/assets/sunset-to-sunset.min.js +++ b/dist/assets/sunset-to-sunset.min.js @@ -1,2 +1,2 @@ -export function __vite_legacy_guard(){import("data:text/javascript,")}const t=(t,e)=>Object.assign(t,e),e=(t,e)=>{const n="cccc, LLLL d 'at' h:mm a ZZZZ";for(let s=0;s{console.log("Intializing Sunset to Sunset...");const n=luxon.DateTime,s=luxon.Duration,o=n.now();let a={};a["Current Time"]={Date:o.toLocaleString(n.DATE_FULL),Time:o.toLocaleString(n.TIME_WITH_SHORT_OFFSET)};const i=document.querySelector("template#sts-settings");let l={};i.dataset.days&&(l=JSON.parse(i.dataset.days));l=t(t({},{closing:5,opening:6}),l);const r=()=>l.closing,c=()=>l.opening,d=o.weekday==r()||o.weekday==c();let u={};i.dataset.settings&&(u=JSON.parse(i.dataset.settings)),u=t(t({},{guardDuration:{minutes:30},bannerDuration:{hours:3},location:{lat:0,long:0},simulateTime:!1,debug:!1}),u);const m=document.getElementsByTagName("html")[0];(d||u.simulateTime)&&(m.style.display="none"),u.simulateTime&&console.warn("%cThe `simulateTime` option is enabled for the Sunset to Sunset plugin. Remember to disable this option once you are done verifying the settings.","font-size: 16px"),u.debug&&(console.group("Sunset to Sunset intialized with the following options:"),console.dir(u),console.groupEnd());const g=()=>u.location,p=async t=>{const e=t.split("T")[0],s=await fetch("https://api.sunrise-sunset.org/json?&lat="+g().lat+"&lng="+g().long+"&date="+e+"&formatted=0"),o=await s.json();return n.fromISO(o.results.sunset)},S=()=>{let t=r()-o.weekday;const e=n.fromISO(o.plus({days:t})).toString();return p(e)},T=()=>{let t=c()-o.weekday;const e=n.fromISO(o.plus({days:t})).toString();return p(e)},f=()=>u.guardDuration,b=t=>t.minus(s.fromObject(u.bannerDuration)),y=(t,e)=>{let n;return"closing"==e&&(n=t.minus(f())),"opening"==e&&(n=t.plus(f())),n};if(d||u.simulateTime){let t=!1,s=!1,i=!1,l=!1;if(u.simulateTime)switch(u.simulateTime){case"preparation-day":t=!0;break;case"banner-up":s=!0;break;case"during-sabbath":i=!0;break;case"after-sabbath":l=!0}(async()=>{const t=Promise.all([S(),T()]);return await t})().then((([d,g])=>{const p=y(d,"closing"),S=y(g,"opening");if(u.simulateTime||(t=ob(p)&&o=p&&o<=S&&o.weekday>=r(),l=o>S&&o>=c()),t){const t=b(p).diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(s){((t,n)=>{const s=document.querySelector("template#sts-banner-template");let o;if(s)o=s;else{let t=document.createElement("template");t.innerHTML='\n\t\t\t
\n\t\t\t\tBecause of religious beliefs our store will be closed over the Sabbath hours.\n\t\t\t\tClosing on and will re-open on .\n\t\t\t
\n\t\t',o=t}const a=o.content.cloneNode(!0),i=a.querySelectorAll(".sts-closing-time");e(i,t);const l=a.querySelectorAll(".sts-opening-time");e(l,n),document.body.insertBefore(a,document.body.firstChild)})(p,S);const t=p.diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(i){(t=>{const n=document.querySelector("template#sts-full-message-template"),s=document.querySelector("template#sts-message-template"),o=n||s;let a;if(o)a=o.content.cloneNode(!0),a=a.firstElementChild;else{let t=document.createElement("div");t.innerHTML="\n\t\t\t

\n\t\t\t\tIn a world that seems to be spinning faster every day, we choose to stop \n\t\t\t\tand rest every Sabbath (Saturday). It’s a day for us to relax, refresh, \n\t\t\t\trefocus and worship; worship a God who loved us so much that He built a \n\t\t\t\tday of rest into Creation week and then commanded us to keep it \n\t\t\t\t(knowing we probably wouldn’t do it otherwise—even though it is for \n\t\t\t\tour best good).\n\t\t\t

\n\t\t",a=t}let i=document.createElement("template");i.innerHTML='\n\t\t
\n\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

Sabbath

\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

\n\t\t\t\t\t\tWe will re-open on .\n\t\t\t\t\t

\n\t\t\t\t
\n\t\t\t
\n\t\t\n\t\t
\n\t';const l=i.content.cloneNode(!0);if(n){let t=l.querySelector(".sts-full-message__container");for(;t.firstElementChild;)t.removeChild(t.firstChild);t.insertBefore(a,null)}else s&&l.querySelector(".sts-message-area").insertBefore(a,null);document.getElementsByTagName("html")[0].classList.add("sts-during-sabbath");const r=l.querySelectorAll(".sts-opening-time");e(r,t),document.body.insertBefore(l,document.body.firstChild)})(S);const t=S.diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(m.style.display="block",u.debug){let e={Enabled:{"Preparation day":t,"Banner up":s,"During the Sabbath":i,"After Sabbath":l}};console.group("Sunset to Sunset time checks"),console.table(e),console.groupEnd(),a["Banner up"]={Date:b(p).toLocaleString(n.DATE_FULL),Time:b(p).toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing guard"]={Date:p.toLocaleString(n.DATE_FULL),Time:p.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing sunset"]={Date:d.toLocaleString(n.DATE_FULL),Time:d.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening sunset"]={Date:g.toLocaleString(n.DATE_FULL),Time:g.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening guard"]={Date:S.toLocaleString(n.DATE_FULL),Time:S.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},console.group("Sunset to Sunset times"),console.table(a),console.groupEnd()}}))}else m.style.display="block",console.log("Sunset to Sunset: Exiting because today is not closing day")})(); +export function __vite_legacy_guard(){import("data:text/javascript,")}const t=(t,e)=>Object.assign(t,e),e=(t,e)=>{const n="cccc, LLLL d 'at' h:mm a ZZZZ";for(let s=0;s{console.log("Intializing Sunset to Sunset...");const n=luxon.DateTime,s=luxon.Duration,o=n.now();let a={};a["Current Time"]={Date:o.toLocaleString(n.DATE_FULL),Time:o.toLocaleString(n.TIME_WITH_SHORT_OFFSET)};const i=document.querySelector("template#sts-settings");let l={};i.dataset.days&&(l=JSON.parse(i.dataset.days));l=t(t({},{closing:5,opening:6}),l);const r=()=>l.closing,c=()=>l.opening,u=o.weekday==r()||o.weekday==c();let d={};i.dataset.settings&&(d=JSON.parse(i.dataset.settings)),d=t(t({},{guardDuration:{minutes:30},bannerDuration:{hours:3},location:{lat:0,long:0},simulateTime:!1,debug:!1}),d),d.simulateTime&&console.warn("%cThe `simulateTime` option is enabled for the Sunset to Sunset plugin. Remember to disable this option once you are done verifying the settings.","font-size: 16px"),d.debug&&(console.group("Sunset to Sunset intialized with the following options:"),console.dir(d),console.groupEnd());const m=()=>d.location,g=async t=>{const e=t.split("T")[0],s=await fetch("https://api.sunrise-sunset.org/json?&lat="+m().lat+"&lng="+m().long+"&date="+e+"&formatted=0"),o=await s.json();return n.fromISO(o.results.sunset)},p=()=>{let t=r()-o.weekday;const e=n.fromISO(o.plus({days:t})).toString();return g(e)},S=()=>{let t=c()-o.weekday;const e=n.fromISO(o.plus({days:t})).toString();return g(e)},T=()=>d.guardDuration,f=t=>t.minus(s.fromObject(d.bannerDuration)),b=(t,e)=>{let n;return"closing"==e&&(n=t.minus(T())),"opening"==e&&(n=t.plus(T())),n};if(u||d.simulateTime){let t=!1,s=!1,i=!1,l=!1;if(d.simulateTime)switch(d.simulateTime){case"preparation-day":t=!0;break;case"banner-up":s=!0;break;case"during-sabbath":i=!0;break;case"after-sabbath":l=!0}(async()=>{const t=Promise.all([p(),S()]);return await t})().then((([u,m])=>{const g=b(u,"closing"),p=b(m,"opening");if(d.simulateTime||(t=of(g)&&o=g&&o<=p&&o.weekday>=r(),l=o>p&&o>=c()),t){const t=f(g).diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(s){((t,n)=>{const s=document.querySelector("template#sts-banner-template");let o;if(s)o=s;else{let t=document.createElement("template");t.innerHTML='\n\t\t\t
\n\t\t\t\tBecause of religious beliefs our store will be closed over the Sabbath hours.\n\t\t\t\tClosing on and will re-open on .\n\t\t\t
\n\t\t',o=t}const a=o.content.cloneNode(!0),i=a.querySelectorAll(".sts-closing-time");e(i,t);const l=a.querySelectorAll(".sts-opening-time");e(l,n),document.body.insertBefore(a,document.body.firstChild)})(g,p);const t=g.diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(i){(t=>{const n=document.querySelector("template#sts-full-message-template"),s=document.querySelector("template#sts-message-template"),o=n||s;let a;if(o)a=o.content.cloneNode(!0),a=a.firstElementChild;else{let t=document.createElement("div");t.innerHTML="\n\t\t\t

\n\t\t\t\tIn a world that seems to be spinning faster every day, we choose to stop \n\t\t\t\tand rest every Sabbath (Saturday). It’s a day for us to relax, refresh, \n\t\t\t\trefocus and worship; worship a God who loved us so much that He built a \n\t\t\t\tday of rest into Creation week and then commanded us to keep it \n\t\t\t\t(knowing we probably wouldn’t do it otherwise—even though it is for \n\t\t\t\tour best good).\n\t\t\t

\n\t\t",a=t}let i=document.createElement("template");i.innerHTML='\n\t\t
\n\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

Sabbath

\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

\n\t\t\t\t\t\tWe will re-open on .\n\t\t\t\t\t

\n\t\t\t\t
\n\t\t\t
\n\t\t\n\t\t
\n\t';const l=i.content.cloneNode(!0);if(n){let t=l.querySelector(".sts-full-message__container");for(;t.firstElementChild;)t.removeChild(t.firstChild);t.insertBefore(a,null)}else s&&l.querySelector(".sts-message-area").insertBefore(a,null);document.getElementsByTagName("html")[0].classList.add("sts-during-sabbath");const r=l.querySelectorAll(".sts-opening-time");e(r,t),document.body.insertBefore(l,document.body.firstChild)})(p);const t=p.diff(o,"milliseconds").toObject();t.milliseconds>=0&&setTimeout((()=>{location.reload()}),t.milliseconds)}if(d.debug){let e={Enabled:{"Preparation day":t,"Banner up":s,"During the Sabbath":i,"After Sabbath":l}};console.group("Sunset to Sunset time checks"),console.table(e),console.groupEnd(),a["Banner up"]={Date:f(g).toLocaleString(n.DATE_FULL),Time:f(g).toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing guard"]={Date:g.toLocaleString(n.DATE_FULL),Time:g.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Closing sunset"]={Date:u.toLocaleString(n.DATE_FULL),Time:u.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening sunset"]={Date:m.toLocaleString(n.DATE_FULL),Time:m.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},a["Opening guard"]={Date:p.toLocaleString(n.DATE_FULL),Time:p.toLocaleString(n.TIME_WITH_SHORT_OFFSET)},console.group("Sunset to Sunset times"),console.table(a),console.groupEnd()}}))}else console.log("Sunset to Sunset: Exiting because today is not closing day")})(); //# sourceMappingURL=sunset-to-sunset.min.js.map diff --git a/dist/assets/test-legacy.min.js b/dist/assets/test-legacy.min.js index 9be7aaa..de1a53a 100644 --- a/dist/assets/test-legacy.min.js +++ b/dist/assets/test-legacy.min.js @@ -1,2 +1,2 @@ -!function(){var e=document.createElement("style");e.innerHTML='*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a1a1aa}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a1a1aa}input::placeholder,textarea::placeholder{opacity:1;color:#a1a1aa}button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(228,228,231,var(--tw-border-opacity))}.relative{position:relative}.block{display:block}.table{display:table}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}@-webkit-keyframes ping{75%,to{transform:scale(2);opacity:0}}@keyframes ping{75%,to{transform:scale(2);opacity:0}}@-webkit-keyframes pulse{50%{opacity:.5}}@keyframes pulse{50%{opacity:.5}}@-webkit-keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}@keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}*,:before,:after{--tw-shadow: 0 0 #0000}*,:before,:after{--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgba(59, 130, 246, .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000}\n',document.head.appendChild(e),System.register(["./sunset-to-sunset-legacy.min.js"],(function(){"use strict";return{setters:[function(){}],execute:function(){}}}))}(); +!function(){var e=document.createElement("style");e.innerHTML='*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a1a1aa}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a1a1aa}input::placeholder,textarea::placeholder{opacity:1;color:#a1a1aa}button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(228,228,231,var(--tw-border-opacity))}.relative{position:relative}.table{display:table}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}@-webkit-keyframes ping{75%,to{transform:scale(2);opacity:0}}@keyframes ping{75%,to{transform:scale(2);opacity:0}}@-webkit-keyframes pulse{50%{opacity:.5}}@keyframes pulse{50%{opacity:.5}}@-webkit-keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}@keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}*,:before,:after{--tw-shadow: 0 0 #0000}*,:before,:after{--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgba(59, 130, 246, .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000}\n',document.head.appendChild(e),System.register(["./sunset-to-sunset-legacy.min.js"],(function(){"use strict";return{setters:[function(){}],execute:function(){}}}))}(); //# sourceMappingURL=test-legacy.min.js.map diff --git a/dist/assets/test.css b/dist/assets/test.css index 8a107c9..38f0e62 100644 --- a/dist/assets/test.css +++ b/dist/assets/test.css @@ -1 +1 @@ -*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a1a1aa}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a1a1aa}input::placeholder,textarea::placeholder{opacity:1;color:#a1a1aa}button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(228,228,231,var(--tw-border-opacity))}.relative{position:relative}.block{display:block}.table{display:table}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}@-webkit-keyframes ping{75%,to{transform:scale(2);opacity:0}}@keyframes ping{75%,to{transform:scale(2);opacity:0}}@-webkit-keyframes pulse{50%{opacity:.5}}@keyframes pulse{50%{opacity:.5}}@-webkit-keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}@keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}*,:before,:after{--tw-shadow: 0 0 #0000}*,:before,:after{--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgba(59, 130, 246, .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000} +*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a1a1aa}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a1a1aa}input::placeholder,textarea::placeholder{opacity:1;color:#a1a1aa}button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(228,228,231,var(--tw-border-opacity))}.relative{position:relative}.table{display:table}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}@-webkit-keyframes ping{75%,to{transform:scale(2);opacity:0}}@keyframes ping{75%,to{transform:scale(2);opacity:0}}@-webkit-keyframes pulse{50%{opacity:.5}}@keyframes pulse{50%{opacity:.5}}@-webkit-keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}@keyframes bounce{0%,to{transform:translateY(-25%);-webkit-animation-timing-function:cubic-bezier(.8,0,1,1);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;-webkit-animation-timing-function:cubic-bezier(0,0,.2,1);animation-timing-function:cubic-bezier(0,0,.2,1)}}*,:before,:after{--tw-shadow: 0 0 #0000}*,:before,:after{--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgba(59, 130, 246, .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000} diff --git a/dist/tests/index.html b/dist/tests/index.html index 64d3497..3b8c581 100644 --- a/dist/tests/index.html +++ b/dist/tests/index.html @@ -843,20 +843,20 @@