// True opt-in (added 2026-11-20). Nothing about this device is remembered, sent or counted until its owner says yes. // The choices live in one cookie, pt_opt, one letter per yes: s = remember this device k = back up my settings t = count help topics I open window.PTOPT=(function(){ function get(){ var m=/(?:^|;\s*)pt_opt=([a-z]*)/.exec(document.cookie||''); return m?m[1]:'' } function has(l){ return get().indexOf(l)>-1 } function set(l,on){ var v=get().replace(l,''); if(on) v+=l; document.cookie='pt_opt='+v+'; Path=/; Max-Age='+(v?31536000:0)+'; SameSite=Lax'+(location.protocol==='https:'?'; Secure':''); try{ fetch('/whereami?visit=1',{cache:'no-store',headers:{'x-pt-set':'1'}}).catch(function(){}) }catch(e){} } // "Forget this device": the site erases every note it set here, and the page clears what it saved. function forget(cb){ fetch('/whereami?forget=1',{cache:'no-store',headers:{'x-pt-forget':'1'}}).catch(function(){}).then(function(){ try{ Object.keys(localStorage).forEach(function(k){ if(/^pt[-_]/.test(k)) localStorage.removeItem(k) }); sessionStorage.clear() }catch(e){} if(cb) cb() }) } return {get:get,has:has,set:set,forget:forget}; })(); // Every request this page makes to its own site carries a random key that lives only in this device's storage. The notes // the site keeps here are sealed with it, so a copied cookie cannot be opened anywhere else. Made only after a yes. (function(){ var of=window.fetch; if(!of||window.PTKEY) return; function key(make){ var k=null; try{ k=localStorage.getItem('pt-k'); if(!k&&make){ var a=new Uint8Array(16); (window.crypto||window.msCrypto).getRandomValues(a); k=Array.prototype.map.call(a,function(x){return ('0'+x.toString(16)).slice(-2)}).join(''); localStorage.setItem('pt-k',k) } }catch(e){} return k } window.PTKEY=key; window.fetch=function(u,o){ try{ var url=new URL(typeof u==='string'?u:u.url,location.href); if(url.origin===location.origin&&!(o&&o.credentials==='omit')){ var yes=/(?:^|;\s*)pt_opt=[a-z]*s/.test(document.cookie||'')||/(?:^|;\s*)pt_role=family/.test(document.cookie||''), k=key(yes); if(k){ o=Object.assign({},o||{}); var h=new Headers(o.headers||{}); if(!h.has('x-pt-k')) h.set('x-pt-k',k); o.headers=h; } } }catch(e){} return of.call(window,u,o) }; })(); // Park Terrace Resident Hub — shared helpers for the public pages. Own code, no libraries. (function(){ var TZ='America/Phoenix'; // Saving on the device follows the same rule as everything else: text size and contrast are saved when you tap them; // anything more (pet, game progress, districts, choices on Tech help) is saved only if you said yes to "remember this device". var store={get:function(k){try{return localStorage.getItem(k)}catch(e){return null}},set:function(k,v){try{ if(k==='pt_size'||k==='pt_contrast'||(window.PTOPT&&PTOPT.has('s'))) localStorage.setItem(k,v) }catch(e){}},canKeep:function(){return !!(window.PTOPT&&PTOPT.has('s'))}}; function esc(s){return String(s==null?'':s).replace(/[&<>"]/g,function(c){return {'&':'&','<':'<','>':'>','"':'"'}[c]})} function dayKey(d){var p=new Intl.DateTimeFormat('en-CA',{timeZone:TZ,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(d||new Date()),o={};p.forEach(function(x){o[x.type]=x.value});return o.year+'-'+o.month+'-'+o.day} function addDays(k,n){var d=new Date(k+'T12:00:00Z');d.setUTCDate(d.getUTCDate()+n);return d.toISOString().slice(0,10)} function fmtDay(k,opt){return new Date(k+'T12:00:00Z').toLocaleDateString('en-US',Object.assign({timeZone:'UTC',weekday:'long',month:'long',day:'numeric'},opt||{}))} function fmtStamp(iso){try{return new Date(iso).toLocaleDateString('en-US',{timeZone:TZ,month:'long',day:'numeric',year:'numeric'})}catch(e){return iso}} function nowMins(){var p=new Intl.DateTimeFormat('en-US',{timeZone:TZ,hour:'numeric',minute:'2-digit',hour12:false}).formatToParts(new Date()),o={};p.forEach(function(x){o[x.type]=x.value});return (+o.hour%24)*60+ +o.minute} function mins(s){var m=/(\d+):(\d+)\s*(am|pm)/i.exec(s||'');if(!m)return 0;var h=+m[1]%12;if(/pm/i.test(m[3]))h+=12;return h*60+ +m[2]} function ageDays(iso){return Math.floor((Date.now()-new Date(iso).getTime())/86400000)} // Line icons, drawn for this site (no icon library). var IC={ home:'', dining:'', notices:'', fire:'', phone:'', games:'', news:'', market:'', cards:'', onsite:'', bus:'', cal:'', pet:'', print:'', tech:'', back:'', contrast:'', mark:'' }; function icon(n){return ''} // Desert scene behind the header: sun, two ridgelines and a saguaro. Drawn for this site. var SCENE=''; var NAV=[['index.html','Home','home'],['menu.html','Dining','dining'],['notices.html','Notices','notices'],['resources.html','Help','phone'],['toys.html','Games','games']]; function greeting(){var h=Math.floor(nowMins()/60);return h<12?'Good morning':(h<17?'Good afternoon':'Good evening')} // Header panel + text-size and contrast controls + navigation. Same on every page; choices are remembered on the device. function chrome(title,sub,opt){ var top=document.getElementById('top'); if(!top) return; opt=opt||{}; var here=(location.pathname.split('/').pop()||'index.html').replace(/^$/,'index.html'); if(here.indexOf('.')<0) here+='.html'; function cur(h){return h===here?' aria-current="page"':''} var links=NAV.map(function(n){return ''+n[1]+''}).join(''); top.innerHTML= '
'+SCENE+'
'+ (opt.home?''+icon('mark')+'The TerraceResident Hub' :''+icon('back')+'Home')+ ''+ '
'+ ''+ ''+ '
'+ '
'+(opt.home?'

'+esc(fmtDay(dayKey()))+'

'+greeting()+'

'+esc(title)+'

' :'

'+esc(title)+'

'+(sub?'

'+esc(sub)+'

':''))+(opt.home?'
':'')+'
'; var body=document.body,sizes=['','rf-large','rf-xl'],i=0; function sz(){body.classList.remove('rf-large','rf-xl');if(sizes[i])body.classList.add(sizes[i]);store.set('pt_size',String(i))} var s=store.get('pt_size'); if(s!==null){i=Math.max(0,Math.min(2,parseInt(s,10)||0));sz()} document.getElementById('rfB').onclick=function(){i=Math.min(2,i+1);sz()}; document.getElementById('rfS').onclick=function(){i=Math.max(0,i-1);sz()}; var c=document.getElementById('rfC'); // a setting is saved only when the person taps the button, never just by visiting function ct(on,save){body.classList.toggle('rf-contrast',on);c.setAttribute('aria-pressed',on?'true':'false');if(save)store.set('pt_contrast',on?'1':'0')} ct(store.get('pt_contrast')==='1',false); c.onclick=function(){ct(!body.classList.contains('rf-contrast'),true)}; var nav=document.getElementById('nav')||document.body.appendChild(document.createElement('div')); nav.innerHTML=''; Array.prototype.forEach.call(document.querySelectorAll('[data-i]'),function(e){e.innerHTML=icon(e.getAttribute('data-i'))}); if(!opt.noAsk&&!window.PTASK){ window.PTASK=1; var as=document.createElement('script'); as.src='ask.js?v=1203a'; document.head.appendChild(as); } // "Ask the hub" search box (runs on the phone) var ft=document.querySelector('footer'); if(ft&&!/privacy/.test(location.pathname)&&!ft.querySelector('[data-know]')) ft.insertAdjacentHTML('beforeend',' Your privacy and your choices'); } // "Copied from the community calendar on " line; stronger wording once the copy is over 30 days old. function asOf(el,what){ if(!el||!window.PTPUB) return; var a=ageDays(PTPUB.pulledAt), when=fmtStamp(PTPUB.pulledAt); el.innerHTML=(a>30?'This copy is '+a+' days old. ':'')+esc(what)+' as copied from the community’s resident calendar on '+esc(when)+'. '+ 'Repeating items are shown as scheduled then; changes made since are not here. The posted calendar and the front desk have the last word.'; } window.HUB={esc:esc,dayKey:dayKey,addDays:addDays,fmtDay:fmtDay,fmtStamp:fmtStamp,nowMins:nowMins,mins:mins,ageDays:ageDays,chrome:chrome,asOf:asOf,store:store,icon:icon}; })(); // ---- Neighbor Check-In heartbeat (added 2026-11-20). Runs only on a device its owner linked on the Check-In page. // Using the Hub is itself a sign of life: every page view tells the shared list "this device was used", with the day's running count, // plus whether it was at Park Terrace. Location, when the owner allowed it, is compared on the device; only yes/no is sent. (function(){ var SITE={lat:33.6252,lon:-112.1152,r:350}; function get(k){try{return JSON.parse(localStorage.getItem(k)||'null')}catch(e){return null}} function kind(){var u=navigator.userAgent||'';if(/iPad|Tablet/.test(u)||(navigator.platform==='MacIntel'&&navigator.maxTouchPoints>1))return 'tablet';if(/Mobi|iPhone|Android/.test(u))return 'phone';return 'computer'} function devId(){var d=null;try{d=localStorage.getItem('pt-dev');if(!d){d=Date.now().toString(36)+Math.random().toString(36).slice(2,8);localStorage.setItem('pt-dev',d)}}catch(e){}return d} // every page view counts: a running total for today, kept on this device and sent along function visits(){ var d=new Date().toDateString(), v=get('pt-visits')||{}; if(v.d!==d) v={d:d,n:0}; return v.n } function bump(){ var d=new Date().toDateString(), v=get('pt-visits')||{}; if(v.d!==d) v={d:d,n:0}; v.n++; try{localStorage.setItem('pt-visits',JSON.stringify(v))}catch(e){} } if(get('pt-me')) bump(); function near(pos){var R=6371000,a=Math.PI/180,dl=(pos.coords.latitude-SITE.lat)*a,dn=(pos.coords.longitude-SITE.lon)*a*Math.cos(SITE.lat*a); return Math.sqrt(dl*dl+dn*dn)*R <= SITE.r+Math.min(pos.coords.accuracy||0,150)} function send(me,geo,cb){ fetch('/api/checkin',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({op:'beat',id:me.id,dev:devId(),kind:kind(),geo:geo,n:visits()})}) .then(function(r){return r.ok?r.json():null}).then(function(j){ if(j&&j.gone){try{localStorage.removeItem('pt-me')}catch(e){}} try{localStorage.setItem('pt-beat',String(Date.now()))}catch(e){} if(cb)cb(j) }).catch(function(){ if(cb)cb(null) }); } function beat(force,cb){ var me=get('pt-me'); if(!me||!me.id||me.auto===false){ if(cb)cb(null); return; } if(me.gps&&navigator.geolocation){ var done=false, fin=function(g){ if(done)return; done=true; send(me,g,cb) }; navigator.geolocation.getCurrentPosition(function(p){fin(near(p))},function(){fin(null)},{maximumAge:600000,timeout:8000}); setTimeout(function(){fin(null)},9000); } else send(me,null,cb); } window.PTBEAT=beat; if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',function(){beat(false)}); else beat(false); })(); // ---- First visit: "Do you live at Park Terrace?" (added 2026-11-20). The answer is kept in a cookie for a year and only // shapes what the page offers. It opens nothing: whether a device is a resident's is decided by the server (see /whereami). (function(){ function get(){ var m=/(?:^|;\s*)pt_role=([a-z]+)/.exec(document.cookie||''); return m?m[1]:null } function set(v){ document.cookie='pt_role='+v+'; Path=/; Max-Age=31536000; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'') } function close(){ var e=document.getElementById('roleSheet'); if(e) e.remove() } function sheet(html){ close(); var d=document.createElement('div'); d.id='roleSheet'; d.className='sheet'; d.setAttribute('role','dialog'); d.setAttribute('aria-modal','false'); d.setAttribute('aria-label','Welcome'); d.innerHTML='
'+html+'
'; (document.body||document.documentElement).appendChild(d); var f=d.querySelector('.sheet-h')||d.querySelector('button'); if(f) try{f.focus({preventScroll:true})}catch(e){} return d } function skipped(){ try{ return sessionStorage.getItem('pt-noask')==='1' }catch(e){ return false } } function ask(force){ if(!force&&(/\/(games|resources|trivia)(\.html)?$/.test(location.pathname)||get()||skipped()||window.PTQR||location.hash==='#restore'||/[?&](c|g|i)=/.test(location.search))) return; // One tap answers both questions for a resident; each button says exactly what it does. var d=sheet('

Welcome. Do you live at Park Terrace?

Nothing is kept until you choose. Your privacy and your choices

'+ ''); Array.prototype.forEach.call(d.querySelectorAll('[data-r]'),function(b){ b.onclick=function(){ var r=b.getAttribute('data-r'); if(r==='none'){ try{ sessionStorage.setItem('pt-noask','1') }catch(e){} close(); return; } set(r); if(r==='resident'){ PTOPT.set('s',true); check(); } else done(r) } }) } // The second question, asked only of people who say they live here. Off unless they say yes. function remember(then,why){ if(PTOPT.has('s')){ then(); return; } var d=sheet('

May this device be remembered?

'+(why||'The residents’ pages need to know this device is yours.')+' If you say yes, a small signed note is kept on this device with the signs that it belongs here: visits, being at Park Terrace, the on-site code, a neighbor’s vouch. No name is in it, and you can erase it at any time. If you say no, nothing is kept and the open pages still work.

'+ ''); document.getElementById('remYes').onclick=function(){ PTOPT.set('s',true); then() }; document.getElementById('remNo').onclick=close } function done(r){ sheet('

'+(r==='family'?'Welcome. Thank you for looking in on someone here.':'Welcome. Have a look around.')+'

Activities, the menu, who to call, news and games are open to everyone.'+(r==='family'?' If the person you know here would like you let known when a call would be welcome, they can add you from their own phone; you will get a link.':'')+'

'+(r==='family'?'Open your page':'')+''); document.getElementById('roleOk').onclick=close } function check(){ sheet('

One moment…

'); fetch('/whereami',{cache:'no-store'}).then(function(r){return r.json()}).then(function(j){ if(j.full){ sheet('

Welcome, neighbor.

This device is confirmed. Check-In, listings and menu sharing are open.

'); document.getElementById('roleOk').onclick=close; return; } if(j.resident){ sheet('

Welcome, neighbor.

You can join the Check-In for yourself now. A neighbor’s vouch opens the list of neighbors.

Join the Neighbor Check-In'); document.getElementById('roleOk').onclick=close; return; } // not confirmed yet: finish it here, without going anywhere var st=j.standing||{}; if(st.code){ // the code is in; one small sign is left, and it is one tap sheet('

Code accepted ✓

One small step is left: showing that you are at Park Terrace. You can confirm you are at Park Terrace. Only yes or no is sent, never a map.

'+ 'A neighbor can confirm me instead

'); document.getElementById('roleOk').onclick=close; document.getElementById('roleGeo').onclick=function(){ var m=document.getElementById('roleMsg'); m.textContent='Asking this phone, just once…'; PTNEAR(function(v){ if(v===null){ m.textContent='This phone did not share a yes or no. That is fine: a neighbor can confirm you instead, or it will finish by itself next time you are on the community Wi-Fi.'; return; } if(!v){ m.textContent='This phone is not at Park Terrace right now. It will finish by itself next time you are home.'; return; } fetch('/whereami?geo=1',{cache:'no-store'}).then(function(){ check() }).catch(function(){ m.textContent='No connection just now.' }) }) }; return; } sheet('

Welcome, neighbor.

The open pages are ready. To open the residents’ parts, type the on-site code posted at the front desk, or have a neighbor vouch for you.

'+ ''+ 'A neighbor can confirm me

'); document.getElementById('roleOk').onclick=close; var go=function(){ var c=document.getElementById('roleCode').value.trim(); if(!c){ document.getElementById('roleCode').focus(); return; } document.getElementById('roleMsg').textContent='Checking…'; fetch('/onsite-code',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({code:c})}).then(function(r){return r.json()}).then(function(k){ if(k.ok) check(); else document.getElementById('roleMsg').textContent=k.error||'That code did not match.' }).catch(function(){ document.getElementById('roleMsg').textContent='No connection just now. Tap again in a moment.' }) }; document.getElementById('roleGo').onclick=go; document.getElementById('roleCode').addEventListener('keydown',function(e){ if(e.key==='Enter') go() }); }).catch(function(){ sheet('

That did not go through.

There is no connection just now.

'); document.getElementById('roleTry').onclick=check; document.getElementById('roleOk').onclick=close; }) } window.PTROLE={get:get,ask:ask,remember:remember,close:close}; if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',function(){ask(false)}); else ask(false); })(); // ---- Keep (added 2026-11-20): a new or replacement phone does not start over. // Once a day this device backs up its own small settings (pet, game progress, text size, Check-In link) under a private // "keep phrase". Typing that phrase on another device brings them back. The server stores a hash of the phrase, not the phrase. (function(){ var KEYS=['pt-me','pt_pet','pt_sdk','pt_mj','pt_scr','pt_recall','pt_mem','pt_game','pt_size','pt_contrast','pt-rf','pt_reps']; var W=('apple river garden lemon table window piano candle meadow harbor pepper button violet marble ribbon basket anchor bridge cactus canyon cedar cherry clover copper cotton daisy desert eagle ember falcon feather fiddle forest fountain galaxy ginger glacier granite harvest hazel honey island ivory jasmine juniper kettle lantern laurel lilac linen maple mango mesa mirror morning mustard nectar nickel oasis olive orchard otter paddle pebble pecan pepper2 pillow planet plum pocket poppy prairie pumpkin quartz quilt rabbit raven ridge robin rocket saddle saffron sage sandal satin shadow silver sparrow spruce stream sunset saguaro tangerine thimble thunder timber toast tulip turtle umbrella valley velvet walnut wagon willow winter wren yarn zephyr acorn almond amber arrow aspen badger bamboo barley beacon berry biscuit blossom breeze brook butter cabin camel canoe carrot castle chestnut cinnamon cobble comet coral cricket crystal cypress dolphin').split(' ').filter(function(w){return !/\d/.test(w)}); function ls(k,v){ try{ if(v===undefined) return localStorage.getItem(k); if(v===null) localStorage.removeItem(k); else localStorage.setItem(k,v) }catch(e){} return null } function norm(p){ return String(p||'').toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-+|-+$/g,'') } function phrase(make){ var p=ls('pt-keep'); if(p||!make) return p; var a=new Uint32Array(7); (window.crypto||window.msCrypto).getRandomValues(a); p=[W[a[0]%W.length],W[a[1]%W.length],W[a[2]%W.length],W[a[3]%W.length],W[a[4]%W.length],W[a[5]%W.length],String(10+a[6]%90)].join('-'); ls('pt-keep',p); return p } function collect(){ var d={},n=0; KEYS.forEach(function(k){ var v=ls(k); if(typeof v==='string'&&v){ d[k]=v; n++ } }); return d } function worth(d){ return !!(d['pt-me']||d.pt_pet||d.pt_sdk||d.pt_mj||d.pt_scr||d.pt_recall||d.pt_mem) } // The phrase never leaves this device. From it the device makes (1) a filing number and (2) a key; the backup is locked with // the key (AES-GCM) before it is sent, so the site stores something it cannot read. var te=new TextEncoder(), td=new TextDecoder(), C=window.crypto&&window.crypto.subtle; function hex(buf){ return Array.prototype.map.call(new Uint8Array(buf),function(x){return ('0'+x.toString(16)).slice(-2)}).join('') } function b64(buf){ var s='',u=new Uint8Array(buf); for(var i=0;i-1&&typeof data[k]==='string') ls(k,data[k]) }) } function restore(p,cb){ if(!C){ cb({ok:false,error:'This browser cannot open a backup.'}); return } p=norm(p); parts(p).then(function(k){ return api({op:'load',kid:k.kid}).then(function(j){ if(!j||!j.ok) return j||{ok:false}; var raw=unb64(j.enc); return C.decrypt({name:'AES-GCM',iv:raw.slice(0,12)},k.key,raw.slice(12)).then(function(pt){ put(JSON.parse(td.decode(pt))); ls('pt-keep',p); ls('pt-keep-at',String(Date.now())); ls('pt-beat',null); return j }) }) }) .then(function(j){ cb(j) }).catch(function(){ cb({ok:false,error:'That backup could not be opened. Check the phrase.'}) }) } function erase(cb){ var p=ls('pt-keep'); if(!p||!C){ if(cb)cb(); return } parts(p).then(function(k){ return api({op:'erase',kid:k.kid}) }).then(function(){ if(cb)cb() }).catch(function(){ if(cb)cb() }) } // Used by the Proof page: lock and open a sample with any phrase, with exactly the same code the real backup uses. function lock(p,obj){ return parts(p).then(function(k){ var iv=window.crypto.getRandomValues(new Uint8Array(12)); return C.encrypt({name:'AES-GCM',iv:iv},k.key,te.encode(JSON.stringify(obj))).then(function(ct){ var out=new Uint8Array(12+ct.byteLength); out.set(iv,0); out.set(new Uint8Array(ct),12); return {kid:k.kid,enc:b64(out)} }) }) } function unlock(p,enc){ return parts(p).then(function(k){ var raw=unb64(enc); return C.decrypt({name:'AES-GCM',iv:raw.slice(0,12)},k.key,raw.slice(12)) }).then(function(pt){ return JSON.parse(td.decode(pt)) }) } window.PTKEEP={phrase:phrase,save:save,restore:restore,put:put,erase:erase,keys:KEYS,lock:function(p,o){return lock(norm(p),o)},unlock:function(p,e){return unlock(norm(p),e)},last:function(){return +ls('pt-keep-at')||0}}; if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',function(){save(false)}); else save(false); })(); // ---- Nudges (rewritten 2026-11-20 after QA): shown on every page of a resident's device, so nobody has to go looking. // to yourself — "let your neighbors know you are OK" when there has been no sign of you today // about others — a neighbor past their chosen days, one someone knocked for and got no answer, one whose family cannot // reach them, or (to their buddies first) one quieter than usual // Each answer is one tap, says thank you, and can be tried again if the connection drops. The Check-In page shows all of // this itself, so the banner stays off there. (function(){ function get(k){try{return JSON.parse(localStorage.getItem(k)||'null')}catch(e){return null}} function set(k,v){try{localStorage.setItem(k,JSON.stringify(v))}catch(e){}} function esc(s){return String(s==null?'':s).replace(/[&<>"]/g,function(c){return {'&':'&','<':'<','>':'>','"':'"'}[c]})} var me=get('pt-me'), role=/(?:^|;\s*)pt_role=resident/.test(document.cookie||''); if((!(me&&me.id)&&!role)||/ll-checkin/.test(location.pathname)){ window.PTNUDGE=function(){}; return; } var FRONT='602-375-4010', TEL='tel:16023754010'; var BTN='font:inherit;font-weight:700;min-height:56px;border-radius:14px;padding:8px 16px;cursor:pointer;flex:1 1 9em;text-align:center;'; var PRI=BTN+'border:0;background:#1f5c4a;color:#fff;', SEC=BTN+'border:2px solid #6b7780;background:#fff;color:#1f2a27;', RED=BTN+'border:0;background:#b3261e;color:#fff;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;'; function dv(){ try{return localStorage.getItem('pt-dev')||''}catch(e){return ''} } function post(b){ b.dev=dv(); return fetch('/api/checkin',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(b)}).then(function(r){ return r.json().catch(function(){return {}}).then(function(j){ return {ok:r.ok,j:j} }) }) } function hrs(h){ return ((h%12)||12)+(h<12?' am':' pm') } var thanks=''; function draw(j){ var old=document.getElementById('ptNudge'); if(old) old.remove(); if(!j) return; if(j.me&&!(get('pt-me')||{}).id) set('pt-me',{id:j.me,auto:true}); var off=get('pt-nudge-off')||{}; if(off.day!==j.today) off={day:j.today,ids:[]}; var items=(j.list||[]).filter(function(x){return x.noAnswer||x.stage==='family'||off.ids.indexOf(x.id)<0}), h=''; if(thanks){ h+='
'+esc(thanks)+'
'; } if(j.self&&off.ids.indexOf('self')<0) h+='
Good '+(j.hour<12?'morning':j.hour<17?'afternoon':'evening')+', '+esc(j.self.first)+'.
Let your neighbors know you are OK today.
'+ '
'; (j.asks||[]).forEach(function(x){ h+='
'+esc(x.name)+' asked you to be a check-in buddy.
It is your choice.
'; }); (j.devAsks||[]).forEach(function(x){ var q=x.mine?'Another '+esc(x.kind)+' says it is yours.
Say yes only if you just set it up yourself.
':''+esc(x.name)+' is setting up a new '+esc(x.kind)+'.
'+(x.buddy?'As their buddy, you can say it is really them.':'They cannot reach their old one. If you know it is really them, say so. Two neighbors are needed.')+'
'; h+='
'+q+'
'; }); items.forEach(function(x){ var first=esc(x.name.split(' ')[0]), who=first+(x.apt?' (Apt '+esc(x.apt)+')':''), line, urgent=!!x.noAnswer||x.stage==='family'; if(x.noAnswer) line=''+esc(x.noAnswer.by)+' knocked on '+who+'’s door and got no answer.'+(x.noAnswer.desk?' '+esc(x.noAnswer.desk)+' has called the front desk.':' Someone needs to call the front desk.'); else if(x.stage==='family') line=''+who+'’s family cannot reach them. Could you knock on the door today?'; else if(x.stage==='due') line='Could you look in on '+who+'? There has been no sign of them '+(x.days>=99?'yet':'for '+x.days+' day'+(x.days===1?'':'s'))+'.'; else line=''+who+' is quieter than usual today. '+(x.by!=null?'There is usually a sign by about '+hrs(x.by)+'.':'')+' Nothing is wrong for certain.'+(x.buddy?' You are one of their buddies.':''); if(x.checking&&!x.noAnswer) line+=' '+esc(x.checking.by)+' said they will check.'; h+='
'+line+'
'+ (x.noAnswer?'Call the front desk '+FRONT+''+(x.noAnswer.desk?'':'')+'Call 911':'')+ ''+ (x.checking||x.noAnswer?'':'')+ (x.noAnswer?'':'')+ (urgent?'':'')+'
'; }); if(!h) return; if(j.more) h+=''; var d=document.createElement('div'); d.id='ptNudge'; d.setAttribute('role','region'); d.setAttribute('aria-label','Neighbor check-in'); d.style.cssText='background:#fff7e0;color:#1f2a27;border-left:6px solid #b94e28;border-radius:16px;padding:14px 16px;margin:12px auto;max-width:760px;line-height:1.45;box-shadow:0 8px 24px -14px rgba(0,0,0,.4)'; d.innerHTML='
Neighbors helping neighbors
'+h+'
'; var top=document.getElementById('top'); if(top&&top.parentNode) top.parentNode.insertBefore(d,top.nextSibling); else { var w=document.querySelector('.wrap')||document.body; w.insertBefore(d,w.firstChild); } Array.prototype.forEach.call(d.querySelectorAll('[data-a]'),function(b){ b.onclick=function(){ var a=b.getAttribute('data-a'), id=b.getAttribute('data-id'), n=b.getAttribute('data-n')||'them'; if(a==='off'){ off.ids.push(id); set('pt-nudge-off',off); thanks=''; draw(j); return; } if(a==='seen'&&b.getAttribute('data-u')&&!confirm('Did you see '+n+' yourself, today? Saying yes tells everyone they are all right.')) return; if(a==='noanswer'&&!confirm('You knocked on '+n+'’s door and nobody answered? This tells every neighbor.')) return; var body=a==='self'?{op:'seen',id:j.self.id,by:'self'}:a==='seen'?{op:'seen',id:id,by:'neighbor'}:a==='byes'||a==='bno'?{op:'buddyAnswer',id:id,yes:a==='byes'}:a==='devyes'||a==='devno'?{op:'linkAnswer',id:id,ask:b.getAttribute('data-ask'),yes:a==='devyes'}:{op:a,id:id}; b.disabled=true; post(body).then(function(x){ if(!x.ok){ b.disabled=false; document.getElementById('ptNudgeMsg').textContent=(x.j&&x.j.error)||'Not saved. Please tap again.'; return; } thanks=a==='self'?'✓ Thank you. Your neighbors know you are OK today.':a==='seen'?'✓ Thank you. '+n+' is marked as seen today.':a==='claim'?'✓ Thank you. Neighbors can see you are checking on '+n+'.':a==='noanswer'?'Raised for everyone. Please call the front desk now.':a==='desk'?'✓ Thank you. Neighbors can see the front desk has been called.':'✓ Done.'; run(true); }).catch(function(){ b.disabled=false; document.getElementById('ptNudgeMsg').textContent='Not saved. There is no connection just now. Tap again in a moment.'; }); }; }); } function run(force){ var last=0; try{last=+sessionStorage.getItem('pt-nudge-at')||0}catch(e){} var cached=null; try{cached=JSON.parse(sessionStorage.getItem('pt-nudge')||'null')}catch(e){} if(!force&&cached&&Date.now()-last<2*60*1000){ draw(cached); return; } fetch('/api/checkin?nudge=1&dev='+encodeURIComponent(dv()),{cache:'no-store'}).then(function(r){return r.ok?r.json():null}).then(function(j){ try{sessionStorage.setItem('pt-nudge',JSON.stringify(j));sessionStorage.setItem('pt-nudge-at',String(Date.now()))}catch(e){} draw(j) }).catch(function(){}) } window.PTNUDGE=run; // wait a moment on the first look, so this visit's own check-in has landed and we do not ask for what was just done var start=function(){ setTimeout(function(){ run(false) },1800) }; if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',start); else start(); })(); // ---- Low effort everywhere (added 2026-11-20) ---- (function(){ // 1. Opens like an app from the home screen: icon, name, colour. (Added here so every page has it.) function tag(n,a){ var e=document.createElement(n); for(var k in a) e.setAttribute(k,a[k]); document.head.appendChild(e) } if(!document.querySelector('link[rel=manifest]')){ tag('link',{rel:'manifest',href:'/manifest.webmanifest'}); tag('link',{rel:'apple-touch-icon',href:'/icon-180.png'}); tag('link',{rel:'icon',href:'/icon.svg',type:'image/svg+xml'}); tag('meta',{name:'theme-color',content:'#1f5c4a'}); tag('meta',{name:'apple-mobile-web-app-capable',content:'yes'}); tag('meta',{name:'apple-mobile-web-app-title',content:'The Terrace'}); } // 2. One scan to join: the code printed on the front-desk flyer can ride in the link (…/?c=CODE). It is entered for the // person and then removed from the address bar. On the community Wi-Fi that confirms the device with no typing. try{ var u=new URL(location.href), c=u.searchParams.get('c'), g=u.searchParams.get('g'); if(c||g){ window.PTQR=true; // tells the welcome question to stay out of the way u.searchParams.delete('c'); u.searchParams.delete('g'); history.replaceState(null,'',u.pathname+(u.search||'')+u.hash); var jpost=function(url,body){ return fetch(url,{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(body)}).then(function(r){return r.json()}) }; var say=function(h,t,ok){ var o=document.getElementById('roleSheet'); if(o) o.remove(); var d=document.createElement('div'); d.className='sheet'; d.id='roleSheet'; d.setAttribute('role','dialog'); d.setAttribute('aria-label',h); d.innerHTML='

'+h+'

'+t+'

'+(ok?'Join the Neighbor Check-In':'Other ways to confirm this device')+'
'; document.body.appendChild(d); try{ d.querySelector('.sheet-h').focus() }catch(e){} }; var joinNow=function(){ document.cookie='pt_role=resident; Path=/; Max-Age=31536000; SameSite=Lax; Secure'; (c?jpost('/onsite-code',{code:c.slice(0,40)}):Promise.resolve(null)).then(function(jc){ return g?jpost('/api/vouch',{op:'claim',token:g.slice(0,20)}).then(function(jg){ return {c:jc,g:jg} }):{c:jc,g:null} }).then(function(x){ if(x.g&&x.g.ok) say('A neighbor vouched for you. Welcome.','This device is confirmed. Everything for residents is open.',true); else if(x.g) say('That square did not work.',(x.g.error||'It may have been used already or run out. Ask your neighbor to show you a new one.'),false); else if(x.c&&x.c.ok) say('Welcome, neighbor.',x.c.full?'This device is confirmed. Everything for residents is open.':x.c.resident?'You are in. You can join the Check-In for yourself now. A neighbor’s vouch opens the list of neighbors.':'The code on the card was accepted. One small step is left.',!!x.c.resident); else say('The code on that card did not work.',(x.c&&x.c.error)||'It may have been changed since the card was printed. The front desk has the current one.',false); }).catch(function(){ say('That did not go through.','There is no connection just now. Scan the square again in a moment.',false) }) }; var beginQR=function(){ PTROLE.remember(joinNow,'A welcome card brought you here.') }; if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',beginQR); else beginQR(); } }catch(e){} // 3. Type your name once: any field marked data-remember is filled from the last time, on this device only. function fill(){ Array.prototype.forEach.call(document.querySelectorAll('[data-remember]'),function(i){ var k='pt_rem_'+i.getAttribute('data-remember'), v=null; try{v=localStorage.getItem(k)}catch(e){} if(v&&!i.value){ i.value=v; try{i.dispatchEvent(new Event('input',{bubbles:true}))}catch(e){} } i.addEventListener('change',function(){ try{ if(PTOPT.has('s')) localStorage.setItem(k,i.value.trim().slice(0,80)) }catch(e){} }) }) } // 4. Read it to me: any button marked data-speak reads the text of the element it names, in the device's own voice. function speakInit(){ var ok='speechSynthesis' in window; Array.prototype.forEach.call(document.querySelectorAll('[data-speak]'),function(b){ if(!ok){ b.classList.add('hide'); return; } var label=b.textContent; b.onclick=function(){ if(speechSynthesis.speaking){ speechSynthesis.cancel(); b.textContent=label; return; } var el=document.querySelector(b.getAttribute('data-speak')); if(!el) return; var t=(el.getAttribute('data-say')||el.innerText||'').replace(/\s+/g,' ').trim().slice(0,3000); if(!t) return; var x=new SpeechSynthesisUtterance(t); x.rate=0.92; x.lang='en-US'; x.onend=function(){ b.textContent=label }; b.textContent='Stop reading'; speechSynthesis.speak(x); }; }) } // 5. Every visit adds to the picture: one light call so the site can note a day of use for this device (kept in the // signed note on the device; nothing is stored by the site). try{ if(PTOPT.get()||/(?:^|;\s*)pt_role=/.test(document.cookie||'')) fetch('/whereami?visit=1',{cache:'no-store',headers:{'x-pt-set':'1'}}).catch(function(){}) }catch(e){} window.PTEASY={fill:fill,speak:speakInit}; function initEasy(){ fill(); speakInit() } if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',initEasy); else initEasy(); })(); // ---- Family nudges, by consent (added 2026-11-20): on a family member's phone, a note at the top of any page when the // person who invited them is off their usual pattern or has shown no sign. Only that one person; only because they invited this phone. (function(){ if(!/(?:^|;\s*)pt_role=family/.test(document.cookie||'')||/family\.html?$|\/family$/.test(location.pathname)) return; function esc(s){return String(s==null?'':s).replace(/[&<>"]/g,function(c){return {'&':'&','<':'<','>':'>','"':'"'}[c]})} function run(){ fetch('/api/family',{cache:'no-store'}).then(function(r){return r.ok?r.json():null}).then(function(j){ var L=((j&&j.family)||[]).filter(function(x){return x.state!=='ok'||x.noAnswer}); if(!L.length) return; var d=document.createElement('div'); d.setAttribute('role','region'); d.setAttribute('aria-label','Family and friend nudges'); d.style.cssText='background:#eef3ef;color:#1f2a27;border-left:6px solid #1f5c4a;border-radius:16px;padding:14px 16px;margin:12px auto;max-width:760px;line-height:1.45'; d.innerHTML='
From Park Terrace
'+L.map(function(x){ return '
'+(x.noAnswer?'Please call '+esc(x.first)+' when you can.':x.state==='due'?esc(x.first)+' would love to hear from you.':'A nice day to call '+esc(x.first)+'.')+'
' }).join('')+ 'See more'; var top=document.getElementById('top'); if(top&&top.parentNode) top.parentNode.insertBefore(d,top.nextSibling); }).catch(function(){}) } window.PTFAMILY=run; if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',run); else run(); })(); // ---- "At Park Terrace?" by the phone's own location (added 2026-11-20). The position is compared here, on the device; // only yes or no ever leaves it, never a map. Being off the community Wi-Fi is not a mark against anyone: this is simply another sign. window.PTNEAR=function(cb){ var SITE={lat:33.6252,lon:-112.1152,r:350}; if(!navigator.geolocation){ cb(null); return } var done=false, fin=function(v){ if(done) return; done=true; cb(v) }; navigator.geolocation.getCurrentPosition(function(p){ var a=Math.PI/180, dl=(p.coords.latitude-SITE.lat)*a, dn=(p.coords.longitude-SITE.lon)*a*Math.cos(SITE.lat*a); fin(Math.sqrt(dl*dl+dn*dn)*6371000 <= SITE.r+Math.min(p.coords.accuracy||0,150)) }, function(){ fin(null) }, {maximumAge:600000,timeout:9000}); setTimeout(function(){ fin(null) },10000) }; // Places: every location on the schedule opens place.html (where it is, how to get there). Added 2026-12-01. window.PTLOC={ dest:function(n){ n=String(n||''); if(/\bdrive\b|lights/i.test(n)) return ''; return n.replace(/\s*-\s*(must rsvp|purchase tickets).*$/i,'').replace(/\s+(shopping|christmas show)$/i,'').trim() }, link:function(loc,n){ if(!loc) return 'Place not given on the calendar'; var off=/off site/i.test(loc); return ''+HUB.esc(off?(PTLOC.dest(n)?'Off-site trip: map':'Off-site drive'):loc)+'' } }; // Gentle signs of life (added 2026-12-03). Opt-in, in-site only. No sensors, no // background work, no battery drain. Rhythm stays in an encrypted cookie this // device alone can read. The site is sent only "seems okay" or "not sure yet". (function(){ var COOKIE='pt_sol', KEY='pt_sol_k'; var shownAsked=false; function b64(buf){ var u=new Uint8Array(buf), s=''; for(var i=0;i28){ delete days[keys.shift()]; keys=Object.keys(days).sort(); } obj.d=days; var iv=crypto.getRandomValues(new Uint8Array(12)); var bytes=new TextEncoder().encode(JSON.stringify(obj)); return crypto.subtle.encrypt({name:'AES-GCM', iv:iv}, key, bytes).then(function(ct){ var out=new Uint8Array(12+ct.byteLength); out.set(iv,0); out.set(new Uint8Array(ct),12); cookieSet(b64(out)); }); }).catch(function(){}); } function sources(rec){ // Own Hub use (today page, menu, activities, going, a hello) is one maybe. // Building Wi-Fi is a second, independent maybe. var n=0; if(rec.v||rec.m||rec.g||rec.h) n++; if(rec.w) n++; if(rec.f) n++; // sending or receiving a small gift: its own source return n; } function mark(kind){ return load().then(function(o){ var day=HUB.dayKey(); o.d=o.d||{}; o.d[day]=o.d[day]||{}; o.d[day][kind]=1; return save(o).then(function(){ if(sources(o.d[day])>=2) return post({op:'indicator', state:'ok'}); }); }).catch(function(){}); } function post(body){ return fetch('/api/life',{method:'POST', credentials:'same-origin', headers:{'content-type':'application/json'}, body:JSON.stringify(body)}) .then(function(r){ return r.json(); }).catch(function(){ return null; }); } function get(){ return fetch('/api/life',{credentials:'same-origin', cache:'no-store'}) .then(function(r){ return r.json(); }).catch(function(){ return null; }); } function bar(){ var el=document.getElementById('ptLife'); if(el) return el; el=document.createElement('div'); el.id='ptLife'; el.className='noprint'; el.setAttribute('role','region'); el.setAttribute('aria-label','A quiet hello'); el.style.cssText='display:none;margin:0 0 16px;padding:16px 18px;background:#fff;border:2px solid var(--accent,#1f5c4a);border-radius:12px'; var top=document.getElementById('top'); if(top&&top.parentNode) top.parentNode.insertBefore(el, top.nextSibling); else if(document.body) document.body.insertBefore(el, document.body.firstChild); return el; } function draw(j){ var el=bar(); var gifts=(j&&j.gifts)||[]; if(!j||j.error||(!j.selfReminder&&!j.askFriend&&!gifts.length)){ el.style.display='none'; el.innerHTML=''; return; } var h=''; gifts.forEach(function(g){ var nm=HUB.esc(g.first||'A neighbor'), gg=GIFT[g.g]||GIFT.wave; h+='
'+nm+' '+gg.said+''+ (g.m>=0&&MSG[g.m]?'
“'+HUB.esc(MSG[g.m])+'”
':'')+ '
'+ ''+ ''+ '
'; }); if(gifts.length&&j.on) mark('f'); if(j.selfReminder){ h+='
Haven’t seen you today. Want to say hi?'+ '
'+ ''+ '
'; } if(j.askFriend){ var n=HUB.esc(j.askFriend.first||'a neighbor'); h+='
Has anyone said hi to '+n+' today?'+ '
'+ ''+ ''+ '
'; } el.innerHTML=h; el.style.display='block'; el.onclick=function(ev){ var b=ev.target.closest('[data-life]'); if(!b) return; var a=b.getAttribute('data-life'); if(a==='thanks'){ post({op:'giftdone',k:b.getAttribute('data-k')}).then(function(){ el.innerHTML='

You are welcome to keep it in mind. Thank you.

'; setTimeout(boot,1200); }); return; } if(a==='back'){ var gk=b.getAttribute('data-k'); post({op:'gift',to:b.getAttribute('data-from'),g:b.getAttribute('data-g'),m:-1}).then(function(r){ return post({op:'giftdone',k:gk}).then(function(){ mark('f'); el.innerHTML='

'+(r&&r.ok===false&&r.note?HUB.esc(r.note):'Sent. That is a nice thing to do.')+'

'; setTimeout(boot,1500); }); }); return; } if(a==='mute'){ post({op:'mute',from:b.getAttribute('data-from')}).then(function(){ el.innerHTML='

All right. You will not see anything from them. They are not told.

'; setTimeout(boot,1500); }); return; } if(a==='here') post({op:'here'}).then(function(){ el.innerHTML='

Thanks. Glad you stopped by.

'; mark('h'); }); else if(a==='away') post({op:'away', on:true}).then(function(){ el.innerHTML='

All right. We will hold the hellos until you are back.

'; }); else if(a==='yes'||a==='noheard'||a==='nottoday'){ post({op:'reply', id:b.getAttribute('data-id'), ans:a}).then(function(){ el.innerHTML='

'+(a==='yes'?'Thanks. That is enough for today.':'Thanks for letting us know.')+'

'; }); } }; if(j.selfReminder && j.needAskStamp && !shownAsked){ shownAsked=true; post({op:'asked'}); } } function invites(j, host){ if(!host) return; var bits='', P=window.PTPUB, today=HUB.dayKey(), hour=j.hour; if(hour>=9 && hour<13) bits+='

Lunch is at noon, want to join? The dining room is on today’s menu.

'; if(P&&P.days&&P.days[today]){ var now=HUB.nowMins(); (P.days[today].a||[]).some(function(r){ if(r[0]==='All day') return false; var s=HUB.mins(r[0]); if(s>now && s<=now+180){ bits+='

'+HUB.esc(r[2])+' is at '+HUB.esc(r[0])+', want to join?

'; return true; } return false; }); } if(j.on && !j.away) bits+='

'; host.innerHTML=bits; var hello=document.getElementById('lifeHello'); if(hello) hello.onclick=function(){ post({op:'here'}).then(function(){ mark('h'); hello.textContent='Hi sent — thanks.'; hello.disabled=true; }); }; } function drawToday(j){ var box=document.getElementById('lifeBox'); if(!box) return; if(!j||j.error||!j.canUse){ box.innerHTML='

If you live here, you can turn on a gentle hello for a few friends you choose. Nothing is sent until you say yes. Your rhythm stays in a private note on this device; only yes or no is sent, never a map.

'; return; } if(!j.on){ box.innerHTML='

Would you like a gentle hello if a day goes by quietly? You pick the friends. You hear first. You can stop anytime.

'+ ''+ '

A day is allowed to pass before anyone is asked. Quiet hours are 8 in the evening to 9 in the morning. Only yes or no is sent from this device.

'; } else { box.innerHTML='

A gentle hello is on. Your friends are the same circle of 3 as on the Neighbors page. One hello from you, or two quiet signs together, is enough for today.

'+ '
'+ ''+ (j.away?'':'')+ '
'+ (j.away?'

Hellos are paused while you are away.

':'')+ (j.circle<3?'

Add three friends on the Neighbors page so they can say hi if a day goes by quietly. Nothing goes out until then.

':'')+ '
'; } function bind(id, fn){ var e=document.getElementById(id); if(e) e.onclick=fn; } bind('lifeOn', function(){ post({op:'opt', on:true}).then(boot); }); bind('lifeOff', function(){ post({op:'opt', on:false}).then(boot); }); bind('lifeHere', function(){ post({op:'here'}).then(function(){ mark('h'); boot(); }); }); bind('lifeAway', function(){ post({op:'away', on:true}).then(boot); }); bind('lifeBack', function(){ post({op:'away', on:false}).then(boot); }); invites(j, document.getElementById('lifeInvite')); } var GIFT={wave:{e:'\uD83D\uDC4B',n:'A wave',said:'sent you a wave'},coffee:{e:'\u2615',n:'A coffee',said:'sent you a coffee'},flower:{e:'\uD83C\uDF38',n:'A flower',said:'sent you a flower'}, sun:{e:'\u2600\uFE0F',n:'Sunshine',said:'sent you some sunshine'},note:{e:'\uD83C\uDFB5',n:'A hymn note',said:'sent you a hymn note'},cookie:{e:'\uD83C\uDF6A',n:'A cookie',said:'sent you a cookie'}, lunch:{e:'\uD83C\uDF7D\uFE0F',n:'See you at lunch',said:'says: see you at lunch'}}; var MSG=['Thinking of you','Hope your day is lovely','See you soon','Just saying hi']; var pick={to:'',g:'',m:-1}; function drawGifts(j){ var box=document.getElementById('lifeGifts'); if(!box) return; if(!j||j.error||!j.canUse){ box.innerHTML=''; return; } var ppl=j.people||[]; if(!ppl.length){ box.innerHTML='

Send something kind

Once you have friends in your circle, you can send them a coffee, a flower or a wave here. No typing needed.

'; return; } var h='

Send something kind

Pick a friend, then a small gift. They will see it as a warm note. Nobody is told if you send, or if they open it.

'; h+='
'; ppl.forEach(function(p){ h+=''; }); h+='
'; Object.keys(GIFT).forEach(function(k){ var g=GIFT[k]; h+=''; }); h+='
'; if(pick.g&&pick.g!=='lunch'){ h+='
A few words, if you like:'; MSG.forEach(function(m,i){ h+=''; }); h+='
'; } h+='

'; if(j.mutedAny) h+=''; box.innerHTML=h; box.onclick=function(ev){ var b=ev.target.closest('button'); if(!b||b.disabled) return; if(b.hasAttribute('data-pto')){ pick.to=b.getAttribute('data-pto'); drawGifts(j); return; } if(b.hasAttribute('data-pg')){ pick.g=b.getAttribute('data-pg'); if(pick.g==='lunch') pick.m=-1; drawGifts(j); return; } if(b.hasAttribute('data-pm')){ var i=+b.getAttribute('data-pm'); pick.m=pick.m===i?-1:i; drawGifts(j); return; } if(b.id==='giftUnmute'){ post({op:'unmuteall'}).then(boot); return; } if(b.id==='giftSend'){ b.disabled=true; post({op:'gift',to:pick.to,g:pick.g,m:pick.m}).then(function(r){ var m=document.getElementById('giftMsg'); if(r&&r.ok){ pick={to:'',g:'',m:-1}; mark('f'); drawGifts(j); var m2=document.getElementById('giftMsg'); if(m2) m2.textContent='Sent. That was kind.'; } else { if(m) m.textContent=(r&&r.note)||'That did not go through. Please try again.'; b.disabled=false; } }); } }; } function noteWifi(){ var path=location.pathname||'/'; if(!(path==='/' || /\/index\.html$/.test(path))) return Promise.resolve(); return fetch('/whereami',{cache:'no-store', credentials:'same-origin'}).then(function(r){ return r.json(); }).then(function(w){ if(w && (w.onsite || (w.signals && w.signals.network) || (w.standing && (w.standing.wifi || w.standing.network)))) return mark('w'); }).catch(function(){}); } function boot(){ return get().then(function(j){ draw(j); drawToday(j); drawGifts(j); if(j && j.on){ var path=location.pathname||'/'; var step=Promise.resolve(); if(path==='/' || /\/index\.html$/.test(path)) step=mark('v'); else if(/menu\.html|calendar\.html/.test(path)) step=mark('m'); return step.then(noteWifi).then(function(){ return j; }); } return j; }); } if(document.readyState==='loading') document.addEventListener('DOMContentLoaded', function(){ boot(); }); else boot(); window.PTLIFE={ mark:mark, going:function(){ return get().then(function(j){ if(j&&j.on) return mark('g'); }); }, boot:boot }; })();