FY2026 STOP School Violence Application: Intake

, led by the . Grants.gov closes October 30, 2026.
Ground rules
  • Report totals only. Nothing about individual students.
  • "We don't track this" is always acceptable.
  • Give the period and source for every number. Mark estimates.
  • Do not name any company or product.
  • Answers stay in this browser until you download them. Nothing is sent to any server. Finished answers go back to the lead sheriff's office by email as a file, and only that office keeps them.

Must-have About 15 minutes

The counties recommended for this application are checked, with their districts checked underneath. The other eligible counties in the region are listed unchecked; check any to add it. Uncheck any county or district to leave it out. Click a county to see its districts.
0counties
0school districts
0schools
0students (potential reach)
0classrooms (est.)
0buses (est.)
0%avg. poverty
0%avg. child poverty (5-17)
Schools, students and classrooms: NCES Common Core of Data (the 2024-25 directory for counties marked 2024-25, the 2023 directory for the others). Poverty: Census SAIPE 2024. Buses: 1 per 75 students (estimate). Classrooms: teacher count (estimate). Fit is a rough estimate against the plan and is shown as a percentage only.
The person with authority to sign for the applicant. This can be the Sheriff. BJA does not require a board or Commissioners Court resolution for this grant.
Which SAM.gov registration will the application use?
Does your county's own policy require Commissioners Court approval or signature to apply?
That person gets a link to Tab 3 (grant administrator, finances, SAM.gov, audit, purchasing). You do not answer those.
One row per checked county; each center covers its own county by default. Use "+ Add county" when a center also dispatches for other counties in the consortium. Edit, delete or add centers.
Regional 9-1-1 coordinator (suggested):
The Review Board oversees the project: it approves major decisions, receives progress reports and reviews results. Members have no daily duties, and the project adds no work beyond their current role.
The first 3 seats are filled in for you (your Sheriff, your Chief Deputy and a superintendent from one of your county's school districts). They count toward the 6; change or remove any of them.
Fill at least 6 seats in total, up to 9. For each seat, choose a sheriff's office or school district from the list, or choose "Other" for anyone else (for example an emergency manager, police chief or county judge), then enter that person's name and email. The person can be a chief deputy or administrator rather than the agency head.
Invite your partners (about a dozen)0 invited
This is how the application gets its local statistics and letters. Every partner you invite here gets an email from you with a link to the Partner questionnaire (Tab 2), filled in for them. Invite agencies and people: sheriffs, police chiefs, superintendents, emergency managers, county judges, hospital and EMS leaders, faith and community leaders.
It is preferred that at least 12 partners answer, so the application has statistics from across the region, and that at least 6 provide letters of support. About half usually respond, so select about 24. Each selected partner gets an email link to the Partner questionnaire (Tab 2). Partners you do not select stay in the consortium.
Each county opens to its sheriff's office, school districts, emergency management coordinator and city police. Add up to two contact emails for each; use + for more.
+ Add a person (community member, official or anyone not listed)
Where partners send their answers back (goes into every partner email)
Each selected partner with an email gets a line below. Open email opens a ready email in your mail program, from your own address. If nothing opens (common with Outlook on the web or Gmail), press Copy email and paste it into a new message. Nothing is sent by this page.
Download the template, send it to ALERRT or TEEX for their letterhead and signature, and upload the signed letter when it comes back.

Local evidence Answer about 5 0 of 5 answered

These become the dated local facts in the application and the statistics table. Numbers go in number boxes; give the period and source; mark estimates. The first three are suggested; pick any five. "We don't track this" is always fine.
Example: 41 total calls, of which 6 were threats and 2 involved a weapon. Threats and weapons are part of the total, not added to it.
2024-25
2025-26 to date
Example: 3 routes have a stretch with no signal; the longest is 18 minutes.
Count real events, not drills.

Optional Strengthens the application

The intent of the program is to improve cross-jurisdictional and agency communications for coordinated response and situational awareness, and to reduce the number of false alarms, which consume resources. It also enables common communication between law enforcement and the education environment through training.
Classroom software from month 4; classrooms complete by month 24; buses complete by month 12 (fixed).
Data: NCES Common Core of Data school directory (2024-25 and 2023, via the Urban Institute Education Data API); Census SAIPE 2024. Answers stay in this browser unless you download them or send them by email.
Not saved yet
'; dlText('ALERRT_TEEX_Letter_of_Commitment_Template.doc', html, 'application/msword'); }; $('copyLetter').onclick=()=>{ const t=alerrtLetter(); (navigator.clipboard&&navigator.clipboard.writeText? navigator.clipboard.writeText(t):Promise.reject()).then(()=>{$('copyLetter').textContent='Copied';},()=>{ const r=document.createRange(); r.selectNodeContents($('alerrtBox')); const s=getSelection(); s.removeAllRanges(); s.addRange(r); $('copyLetter').textContent='Selected; press Ctrl+C'; }); }; // tabs const TABS=['lead','partner','admin','tracker']; function showTab(id){ document.querySelectorAll('.tab').forEach(x=>x.setAttribute('aria-selected',x.dataset.t===id)); TABS.forEach(t=>$(t).classList.toggle('hidden',t!==id)); $('doneBtn').classList.toggle('hidden', !(MODE!=='lead' && id===MODE)); if(id==='tracker') trackerRender(); window.scrollTo(0,0); } document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>showTab(t.dataset.t)); $('consInput').oninput=()=>{$('consName').textContent=$('consInput').value; document.querySelectorAll('.consEcho').forEach(e=>e.textContent=$('consInput').value);}; $('expAll').onclick=()=>{S.counties.forEach(c=>c.open=true); render();}; $('colAll').onclick=()=>{S.counties.forEach(c=>c.open=false); render();}; $('chkAll').onclick=()=>{S.counties.forEach(c=>{c.on=true;c.schools.forEach(s=>s.on=true)}); render();}; $('unAll').onclick=()=>{S.counties.forEach(c=>{c.on=!!c.lead;c.schools.forEach(s=>s.on=!!c.lead)}); render();}; // save / download function collect(){const a={}; document.querySelectorAll('[data-k]').forEach(el=>{const k=el.dataset.k; if(el.type==='radio'){if(el.checked)a[k]=el.value;} else if(el.type==='checkbox')a[k]=el.checked; else if(el.type==='file')a[k]=[...el.files].map(f=>f.name); else a[k]=el.value;}); a.consortium=checked().map(c=>({county:c.name,schools:c.schools.filter(s=>s.on).map(s=>({nces:s.id,name:s.name,district:s.district}))})); a.dispatch=[...$('dispatchRows').querySelectorAll('.disp')].map(r=>({center:r._v.center,covers:[...r._v.covers]})).filter(x=>x.center); a.agencies_selected=[...agOn]; a.agency_emails=Object.fromEntries(Object.entries(agEmail).map(([k,v])=>[k,v.filter(Boolean)]).filter(([k,v])=>v.length)); a.board=seats.map(s=>({agency:s.org,name:s.name,email:s.email})); a.agencies_added=[...agCustom]; a.lo_people=kp.filter(p=>String(p.name||'').trim()||String(p.title||'').trim()).map(p=>({name:p.name,title:p.title})); a.people_added=JSON.parse(JSON.stringify(agPeople)); a._meta={mode:MODE, consortium:CFG.id, saved:new Date().toISOString()}; if(MODE!=='lead'){ delete a.consortium; delete a.dispatch; delete a.agencies_selected; delete a.agency_emails; delete a.board; delete a.agencies_added; delete a.people_added; delete a.lo_people; } return a;} const DRAFT_KEY='stop_intake_'+CFG.id+'_'+MODE+'_'+(HASH.agency||HASH.email||''); function saveDraft(){try{localStorage.setItem(DRAFT_KEY,JSON.stringify(collect())); $('savedMsg').textContent='Saved in this browser '+new Date().toLocaleTimeString();}catch(e){$('savedMsg').textContent='Could not save here; use Download.';}} $('saveBtn').onclick=saveDraft; let _t; document.addEventListener('input',()=>{clearTimeout(_t); _t=setTimeout(saveDraft,800);}); document.addEventListener('change',()=>{clearTimeout(_t); _t=setTimeout(saveDraft,800);}); function dlText(name, text, type){const b=new Blob([text],{type:type||'text/plain'}); const u=URL.createObjectURL(b); const l=document.createElement('a'); l.href=u; l.download=name; l.click(); setTimeout(()=>URL.revokeObjectURL(u),2000); return name;} const slug=s=>String(s||'').replace(/[^A-Za-z0-9]+/g,'_').replace(/^_|_$/g,''); function answersName(){const a=collect(); return MODE==='lead'?`STOP_lead_${slug(a.l2)}.json`:MODE==='admin'?`STOP_admin_${slug(a.a1.split(',')[0]||'answers')}.json`:`STOP_partner_${slug(a.p_agency||'answers')}.json`;} $('dlBtn').onclick=()=>dlText(answersName(), JSON.stringify(collect(),null,2), 'application/json'); // ---------- configuration fill, links, drafts, tracker, exports ---------- function pageLink(p){ const base=location.href.split('#')[0]; const q=new URLSearchParams(); Object.entries(p).forEach(([k,v])=>{ if(v!=null && v!=='') q.set(k,v); }); q.set('c', checked().map(c=>c.name).join('|')); q.set('cons', $('consInput').value); const rb=document.querySelector('[data-k=l7_respond_by]'); if(rb&&rb.value) q.set('by', rb.value); const ln=document.querySelector('[data-k=l7_contact_name]'), lp=document.querySelector('[data-k=l7_phone]'), le=document.querySelector('[data-k=l7_contact_email]'), lc=document.querySelector('[data-k=l7_cc]'); if(ln&&ln.value) q.set('lname', ln.value); if(lp&&lp.value) q.set('lphone', lp.value); if(le&&le.value) q.set('lemail', le.value); if(lc&&lc.value) q.set('cc', lc.value); return base+'#'+q.toString(); } function respondByText(){ const v=(MODE==='lead'? (document.querySelector('[data-k=l7_respond_by]')||{}).value : HASH.by) || CFG.response_deadline; if(!v) return '[date]'; const d=new Date(v+'T12:00:00'); return isNaN(d)?v:d.toLocaleDateString('en-US',{month:'long',day:'numeric',year:'numeric'}); } function leadContactText(){ const n=MODE==='lead'? (document.querySelector('[data-k=l7_contact_name]')||{}).value : HASH.lname; const ph=MODE==='lead'? (document.querySelector('[data-k=l7_phone]')||{}).value : HASH.lphone; const e=MODE==='lead'? (document.querySelector('[data-k=l7_contact_email]')||{}).value : HASH.lemail; const parts=[n||CFG.lead_contact.name, ph||CFG.lead_contact.phone, e||CFG.lead_contact.email].filter(Boolean); return parts.length?parts.join(', '):'[lead contact name, phone, email]'; } function leadCc(){ return (MODE==='lead'? (document.querySelector('[data-k=l7_cc]')||{}).value : HASH.cc) || ''; } function leadEmail(){ return (MODE==='lead'? (document.querySelector('[data-k=l7_contact_email]')||{}).value : HASH.lemail) || CFG.lead_contact.email || ''; } function fillConfig(){ document.querySelectorAll('.leadEcho').forEach(e=>e.textContent=CFG.lead_agency); document.querySelectorAll('.leadCountyEcho').forEach(e=>e.textContent=CFG.lead_county); document.querySelectorAll('.cogEcho').forEach(e=>e.textContent=CFG.cog); document.querySelectorAll('.escEcho').forEach(e=>e.textContent=CFG.esc); $('optCog').textContent='Council of Governments ('+CFG.cog+')'; $('optEsc').textContent='Education Service Center ('+CFG.esc+')'; if(!$('l1Input').value) $('l1Input').value=CFG.legal_applicant; if(!$('consInput').value) $('consInput').value=HASH.cons||CFG.consortium_name; if(!$('regional911').value) $('regional911').value=CFG.regional_911; if(MODE==='lead'&&!$('leadCc').value&&!$('leadCc').dataset.t) $('leadCc').value=CFG.copy_to||''; $('consName').textContent=$('consInput').value; document.querySelectorAll('.consEcho').forEach(e=>e.textContent=$('consInput').value); $('qExisting').classList.toggle('hidden', !CFG.show_existing_capability_question); $('respondByEcho').textContent=respondByText(); $('leadContactEcho').textContent=leadContactText(); } document.addEventListener('input',e=>{ if(e.target.id==='leadEmail'||e.target.id==='leadCc') e.target.dataset.t=1; if(['l7_respond_by','l7_contact_name','l7_phone','l7_contact_email'].includes(e.target.dataset.k)){ $('respondByEcho').textContent=respondByText(); $('leadContactEcho').textContent=leadContactText(); } }); function copyText(t, btn){ const done=()=>{ if(btn){ const o=btn.textContent; btn.textContent='Copied'; setTimeout(()=>btn.textContent=o,1600); } }; const fb=()=>{ const ta=document.createElement('textarea'); ta.value=t; ta.style.position='fixed'; ta.style.opacity='0'; document.body.appendChild(ta); ta.focus(); ta.select(); try{ document.execCommand('copy'); done(); }catch(e){} ta.remove(); }; if(navigator.clipboard&&window.isSecureContext){ navigator.clipboard.writeText(t).then(done, fb); } else fb(); } const emailText=(to,cc,subj,body)=>`To: ${to}\n${cc?'Cc: '+cc+'\n':''}Subject: ${subj}\n\n${body}`; const MAILS=[]; function wireCopies(root){ root.querySelectorAll('[data-copy]').forEach(b=>b.onclick=()=>copyText(MAILS[+b.dataset.copy], b)); } // partner emails (question 8) const typeOf = n => /sheriff|police/i.test(n) ? 'le' : /\bISD\b|\bCISD\b|school district/i.test(n) ? 'sd' : /emergency management/i.test(n) ? 'em' : 'other'; function partnerList(){ const out=[]; const cs=checked(); [...agOn].forEach(n=>{ const emails=(agEmail[n]||[]).filter(Boolean); const county=(agPeople[n]&&agPeople[n].county) || (cs.find(c=>n.startsWith(c.name))||{}).name || (cs.find(c=>districtsOf(c).includes(n))||{}).name || ''; out.push({agency:n, county, type:typeOf(n), emails}); }); return out; } $('mkLinks').onclick=()=>{ const list=partnerList(), box=$('partnerLinks'); const lead=leadEmail(); if(!lead){ box.innerHTML='
Enter the email that receives the answers first.
'; return; } if(!list.length){ box.innerHTML='
Select partners in the list above first.
'; return; } box.innerHTML=list.map(p=>{ const link=pageLink({t:'partner', type:p.type, agency:p.agency, county:p.county}); const body=`To ${p.agency},\n\nThe ${CFG.lead_agency} is applying for the FY2026 STOP School Violence grant (U.S. Department of Justice, Bureau of Justice Assistance) on behalf of the ${$('consInput').value}, which includes ${p.county||'your county'}. If funded, the grant would give school classrooms and school buses a silent way to alert dispatch and give responding agencies one shared map for school incidents. There is no cost to your agency and no local match.\n\nIt is preferred that your agency answer a short partner questionnaire (about 10 minutes) and, if you are willing, provide a letter of support. The questionnaire is at the link below. Your answers stay in your browser until you press "Finish and send to the lead", which returns them to us by email. Taking part in this application does not prevent your agency from receiving awards under the same program or other federal grants.\n\n${link}\n\nPlease respond by ${respondByText()}.\n\n${leadContactText()}\n${CFG.lead_agency}`; const subj=`${$('consInput').value}: partner questionnaire and letter of support`; const mail=p.emails.length? 'mailto:'+p.emails.map(encodeURIComponent).join(',')+'?subject='+encodeURIComponent(subj)+'&body='+encodeURIComponent(body) : ''; p.emails.forEach(e=>{ track.recips[e]=track.recips[e]||{name:p.agency, kind:'partner', county:p.county, status:'Not opened'}; }); const ci=MAILS.push(emailText(p.emails.join(', '),'',subj,body))-1; return `
${p.agency}${p.county?` (${p.county})`:''}${p.emails.length?'':' no email yet'}${mail?`Open email`:''}
`; }).join(''); wireCopies(box); saveTrack(); }; // done flow for partner and administrator $('doneBtn').onclick=()=>{ const a=collect(); const name=dlText(answersName(), JSON.stringify(a,null,2), 'application/json'); const files=[]; document.querySelectorAll('input[type=file]').forEach(i=>[...i.files].forEach(f=>files.push(f.name))); const who=MODE==='admin'? (a.a1||'Administration answers') : (a.p_agency||'Partner answers'); const body=`Attached: ${name}${files.length?' and these uploaded documents: '+files.join(', '):''}.\n\nThe answer file just downloaded to this computer. Please attach it${files.length?' and the documents listed':''} to this email before sending.\n\n${who}`; const to=leadEmail(); const cc=leadCc(); location.href='mailto:'+encodeURIComponent(to)+'?'+(cc?'cc='+encodeURIComponent(cc)+'&':'')+'subject='+encodeURIComponent(`${$('consInput').value}: ${MODE==='admin'?'administration':'partner'} answers from ${who}`)+'&body='+encodeURIComponent(body); const subj=`${$('consInput').value}: ${MODE==='admin'?'administration':'partner'} answers from ${who}`; const ci=MAILS.push(emailText(to,cc,subj,body))-1; $('savedMsg').innerHTML=(to? `Answer file ${name} downloaded; an email to ${to}${cc?' with a copy to '+cc:''} opened. Attach the file and send. If no email opened: ` : `Answer file ${name} downloaded. Email it to the ${CFG.lead_agency}. `)+``; wireCopies($('savedMsg').parentNode); }; // restore a draft function restore(a){ if(!a) return; try{ restoreInner(a); }catch(err){ showErr('restore saved draft', err); } } function restoreInner(a){ document.querySelectorAll('[data-k]').forEach(el=>{ const k=el.dataset.k; if(!(k in a)) return; const v=a[k]; if(el.type==='radio'){ el.checked=(el.value===v); } else if(el.type==='checkbox'){ el.checked=!!v; } else if(el.type==='file'){ } else { el.value=v==null?'':v; if(['pAgency','pDispatch','pFact'].includes(el.id)&&v) el.dataset.t=1; } }); if(MODE==='lead'){ if(Array.isArray(a.consortium)){ S.counties.forEach(c=>{ const m=a.consortium.find(x=>x.county===c.name); c.on=!!m; c.schools.forEach(s=>s.on=!!(m&&m.schools.some(y=>y.nces===s.id))); }); } if(Array.isArray(a.dispatch)){ S.counties.forEach(c=>{ dEdits[c.name]={center:`${c.name} Sheriff's Office dispatch (9-1-1 answering point)`,covers:[c.name],gone:true}; }); a.dispatch.forEach(d=>{ const own=S.counties.find(c=>d.center.startsWith(c.name)); if(own) dEdits[own.name]={center:d.center,covers:[...d.covers],gone:false}; }); } if(Array.isArray(a.lo_people)&&a.lo_people.length){ kp.length=0; a.lo_people.forEach(p=>kp.push({name:String(p.name||''),title:String(p.title||'')})); } if(Array.isArray(a.agencies_added)) a.agencies_added.forEach(n=>{ if(!agCustom.includes(n)) agCustom.push(n); }); if(a.people_added) Object.assign(agPeople, a.people_added); if(Array.isArray(a.agencies_selected)) a.agencies_selected.forEach(n=>agOn.add(n)); if(a.agency_emails) Object.entries(a.agency_emails).forEach(([k,v])=>{ agEmail[k]=v.length>=2?[...v]:[...v,''].slice(0,2); }); if(Array.isArray(a.board)&&a.board.length){ seatsInit=true; seats.length=0; a.board.forEach(b=>seats.push({org:b.agency||'Other',name:String(b.name||''),email:String(b.email||''),hint:'Name and title'})); while(seats.length<6) seats.push({org:'Other',name:'',email:'',hint:'Name and title'}); } } $('courtDate').classList.toggle('hidden', a.l4_req!=='yes'); const w=a.p_letter_path!=='upload'; $('pathWrite').classList.toggle('hidden',!w); $('pathUpload').classList.toggle('hidden',w); } // tracker (lead only; kept in this browser) const TRACK_KEY='stop_track_'+CFG.id; let track={recips:{}, returns:[]}; try{ const t=JSON.parse(localStorage.getItem(TRACK_KEY)||'null'); if(t&&t.recips) track=t; }catch(e){} function saveTrack(){ try{ localStorage.setItem(TRACK_KEY, JSON.stringify(track)); }catch(e){} } const hasLetter = r => (r.p_letter_path==='upload' && Array.isArray(r.p_letter_file) && r.p_letter_file.length) || (r.p_letter_path!=='upload' && (r.p_testimonial||'').trim()); const gaveData = r => Object.entries(r).some(([k,v])=>/^(pe|sd|em)_/.test(k) && !/_nt$/.test(k) && typeof v==='string' && v.trim()); // evidence questions as structured fields: [{q:label, fields:[{k,l}]}] per section function evidQs(sel){ return [...document.querySelectorAll(sel+' .q')].map(q=>{ const l=q.querySelector('.ql'); const lt=l?[...l.childNodes].filter(n=>!(n.classList&&n.classList.contains('tag'))).map(n=>n.textContent).join('').replace(/\s+/g,' ').trim():''; return {q:lt, fields:[...q.querySelectorAll('[data-k]')].map(i=>({k:i.dataset.k, l:i.dataset.l||'', y:(i.closest('.yrow')&&i.closest('.yrow').querySelector('.yr'))?i.closest('.yrow').querySelector('.yr').textContent:''}))}; }); } function factLine(r, qd){ const parts=[]; let nt=false; qd.fields.forEach(f=>{ const v=r[f.k]; if(/_nt$/.test(f.k)){ if(v===true) nt=true; return; } if(v===undefined||v===null||v===''||v===false) return; parts.push(`${f.y?f.y+' ':''}${f.l?f.l.toLowerCase()+': ':''}${v}`); }); if(!parts.length&&!nt) return ''; return `${qd.q}: ${parts.join('; ')}${nt?(parts.length?'; ':'')+'not tracked':''}`; } function trackerRender(){ const partners=track.returns.filter(r=>r._meta&&r._meta.mode==='partner'), admin=track.returns.find(r=>r._meta&&r._meta.mode==='admin'); const letters=partners.filter(hasLetter).length, seatsN=seats.filter(s=>String(s.name||'').trim()&&String(s.email||'').trim()).length; $('tResp').textContent=`${partners.length} of 12`; $('tLetters').textContent=`${letters} of 6`; $('tSeats').textContent=`${seatsN} of 6`; const adminRec=Object.values(track.recips).find(r=>r.kind==='admin'); $('tAdmin').textContent= admin? 'Submitted' : adminRec? adminRec.status : 'Not sent'; const rows=Object.entries(track.recips); const box=$('recipRows'); box.innerHTML= rows.length? rows.map(([em,r])=>`
${r.name}${r.county?` (${r.county})`:''}
${em}
Reminder
`).join('') : '
No recipients yet. Create the partner emails in question 8 or send the Tab 3 link in question 5.
'; box.querySelectorAll('select').forEach(s=>s.onchange=()=>{ track.recips[s.dataset.em].status=s.value; saveTrack(); trackerRender(); }); box.querySelectorAll('[data-rm]').forEach(b=>b.onclick=()=>{ delete track.recips[b.dataset.rm]; saveTrack(); trackerRender(); }); fillFile(true); } $('importFiles').onchange=async e=>{ let n=0, bad=0; for(const f of e.target.files){ try{ const r=JSON.parse(await f.text()); if(!r._meta){ bad++; continue; } const key=r._meta.mode==='admin'? (r.a1||f.name) : (r.p_agency||f.name); track.returns=track.returns.filter(x=>((x._meta.mode==='admin'?(x.a1||''):(x.p_agency||''))!==key)); r._file=f.name; track.returns.push(r); n++; const em=Object.keys(track.recips).find(em=>{ const rec=track.recips[em]; return (r._meta.mode==='admin'&&rec.kind==='admin') || (rec.kind==='partner'&&r.p_agency&&rec.name===r.p_agency) || ((r.p_contact||'').toLowerCase().includes(em.toLowerCase())) || ((r.a1||'').toLowerCase().includes(em.toLowerCase())); }); if(em) track.recips[em].status='Submitted'; }catch(err){ bad++; } } saveTrack(); $('importMsg').textContent=`${n} file${n===1?'':'s'} added${bad?`, ${bad} could not be read (not an answer file)`:''}. ${track.returns.length} on file.`; trackerRender(); e.target.value=''; }; // exports $('expAnswers').onclick=()=>dlText(`STOP_all_answers_${slug($('consInput').value)}.json`, JSON.stringify({lead:collect(), returns:track.returns},null,2), 'application/json'); $('expEvidence').onclick=()=>{ const rows=[['agency','county','type','contact','will_join','letter','question','answer']]; const labels={}; evidQs('#partner').forEach(qd=>qd.fields.forEach(f=>labels[f.k]=qd.q+(f.y?' / '+f.y:'')+(f.l?' / '+f.l:''))); track.returns.filter(r=>r._meta.mode==='partner').forEach(r=>Object.entries(r).forEach(([k,v])=>{ if(/^(pe|sd|em|po|other)_/.test(k) && v!=='' && v!==false && !(Array.isArray(v)&&!v.length)) rows.push([r.p_agency,r.p_county,r.p_type,r.p_contact,r.p_join,hasLetter(r)?'yes':'no',labels[k]||k,Array.isArray(v)?v.join('; '):String(v)]); })); dlText(`STOP_partner_evidence_${slug($('consInput').value)}.csv`, rows.map(r=>r.map(x=>'"'+String(x==null?'':x).replace(/"/g,'""')+'"').join(',')).join('\n'), 'text/csv'); }; $('expStats').onclick=()=>{ const cols=[]; const seen=new Set(); const add=(sel,who)=>evidQs(sel).forEach(qd=>qd.fields.forEach(f=>{ if(!seen.has(f.k)){ seen.add(f.k); cols.push({k:f.k, h:(who+': '+qd.q+(f.y?' / '+f.y:'')+(f.l?' / '+f.l:''))}); } })); add('#lead section.evid','Lead'); ['le','sd','em'].forEach(t=>add(`#partner section.evid[data-type="${t}"]`, {le:'Law enforcement',sd:'School district',em:'Emergency management'}[t])); const head=['responder','role','type','county','will_join','letter_of_support'].concat(cols.map(c=>c.h)); const lead=collect(); const rows=[[CFG.lead_agency,'lead','le',CFG.lead_county,'','']].map(r=>r.concat(cols.map(c=>{ const v=lead[c.k]; return v===true?'yes':v===false||v==null?'':v; }))); track.returns.filter(r=>r._meta.mode==='partner').forEach(r=>rows.push([r.p_agency,'partner',r.p_type,r.p_county,r.p_join,hasLetter(r)?'yes':'no'].concat(cols.map(c=>{ const v=r[c.k]; return v===true?'yes':v===false||v==null?'':v; })))); dlText(`STOP_statistics_table_${slug($('consInput').value)}.csv`, [head].concat(rows).map(r=>r.map(x=>'"'+String(x==null?'':x).replace(/"/g,'""')+'"').join(',')).join('\n'), 'text/csv'); }; $('expUploads').onclick=()=>{ const out=[]; const a=collect(); document.querySelectorAll('#lead input[type=file]').forEach(i=>[...i.files].forEach(f=>out.push(`Lead\t${i.dataset.k}\t${f.name}`))); track.returns.forEach(r=>Object.entries(r).forEach(([k,v])=>{ if(Array.isArray(v)&&v.length&&/file|letterhead|resumes|files/.test(k)) v.forEach(f=>out.push(`${r._meta.mode==='admin'?(r.a1||'Administration'):(r.p_agency||'Partner')}\t${k}\t${f}`)); })); dlText(`STOP_uploaded_files_${slug($('consInput').value)}.txt`, 'Uploaded documents stay on each responder\'s computer. Collect these by email.\n\nFrom\tField\tFile\n'+(out.join('\n')||'(none listed yet)')); }; function fillFile(preview){ const a=collect(), cs=checked(), ss=cs.flatMap(c=>c.schools.filter(s=>s.on)); const enr=ss.reduce((x,s)=>x+(s.enr||0),0), rooms=ss.reduce((x,s)=>x+(s.rooms||0),0); const partners=track.returns.filter(r=>r._meta.mode==='partner'), admin=track.returns.find(r=>r._meta.mode==='admin')||{}; const joined=partners.filter(r=>r.p_join==='yes'); const avg=k=>{const v=cs.filter(c=>c[k]!=null); return v.length?(v.reduce((x,c)=>x+c[k],0)/v.length).toFixed(1)+'%':'';}; const facts=[]; evidQs('#lead section.evid').forEach(qd=>{ const t=factLine(a,qd); if(t) facts.push(`${CFG.lead_agency}: ${t}`); }); partners.forEach(r=>{ const sel=`#partner section.evid[data-type="${r.p_type}"]`; evidQs(sel).forEach(qd=>{ const t=factLine(r,qd); if(t) facts.push(`${r.p_agency||'Partner'} (${r.p_county||''}): ${t}`); }); }); const alerrt=(parseInt(a.lo_alerrt)||0)+partners.reduce((x,r)=>x+(parseInt(r.po_alerrt)||0),0); const adminChoice={ 'cog-agreed':CFG.cog+' (agreed)', 'cog-ask':CFG.cog+' (to be asked)', esc:CFG.esc, private:'Grant administrator hired competitively', other:admin.a2_other||'' }[admin.a2]||''; const fin={auditor:'County Auditor', designee:"County Auditor's designee", other:admin.a3_other||''}[admin.a3]||''; const finName=admin.a3_name?`${fin} (${admin.a3_name})`:fin; const ind={negotiated:'Federally negotiated rate', deminimis:'15% de minimis', none:'None', other:admin.a5_other||''}[admin.a5]||''; const rows=[ ['[County]', CFG.lead_county], ["[County] Sheriff's Office", CFG.lead_agency], ['[Consortium name]', a.l2], ['[N] rural counties', String(cs.length)], ['[County list]', cs.map(c=>c.name).join(', ')], ['[N] school districts', String(nDistricts(cs))], ['[N] students', fmt(enr)], ['[N] campuses', fmt(ss.reduce((x,s)=>x+(s.n||1),0))], ['[N] buses (estimate, 1 per 75 students)', fmt(Math.round(enr/75))], ['[N] classrooms (estimate, teacher count)', fmt(rooms)], ['Poverty average (SAIPE 2024, all ages)', avg('pov')], ['Child poverty average (SAIPE 2024, ages 5-17)', avg('kpov')], ['[bond evidence]', ''], ['[Dispatch center(s)]', (a.dispatch||[]).map(d=>`${d.center} (covers ${d.covers.join(', ')})`).join('; ')], ['[Dispatch center(s)] dispatch for [N] counties', String(new Set((a.dispatch||[]).flatMap(d=>d.covers)).size||'')], ['Regional 9-1-1 coordinator', a.l6_regional], ['Local, dated facts for the Need section', facts.join('\n ')], ['Objective 1.5 baseline: [N] minutes', a.l11_min?`${a.l11_min} minutes (${a.l11_basis||'basis not given'}${a.l11_date?', '+a.l11_date:''})`:''], ['[N] counties have confirmed they will participate', String(new Set(joined.map(r=>r.p_county).filter(Boolean)).size||'')], ['[N] school districts have confirmed they will participate', String(joined.filter(r=>r.p_type==='sd').length||'')], ['[N] partner agencies provided local data', String(partners.filter(gaveData).length||'')], ['[N] signed letters of support', String(partners.filter(hasLetter).length||'')], ['[ALERRT / TEEX] has committed by letter', a.l9_status==='Signed letter uploaded'?'Yes: '+((a.l9_file||[]).join(', ')||'signed letter on file'):(a.l9_status==='Sent to ALERRT/TEEX'?'Requested, not yet received':'')], ['Stakeholder Review Board members', (a.board||[]).filter(b=>b.name).map(b=>`${b.name}, ${b.agency}`).join('; ')], ['[$N] a year in grants', admin.a6_amt||''], ['Main grants administered', admin.a6_names||''], ['Single audit by [firm]', admin.a7||''], ['[grant] in [year] (one grant the Sheriff\'s Office managed)', admin.a10||''], ['Indirect line', ind], ['Fiscal Officer', finName], ['Grant administrator', adminChoice], ['SAM.gov UEI and expiration', admin.a4_uei?`${admin.a4_uei}, expires ${admin.a4_exp||'(date not given)'}`:''], ['Authorized Representative (signer)', a.l4_signer], ['Key personnel (resumes)', (a.lo_people||[]).map(p=>[p.name,p.title].filter(Boolean).join(', ')).join('; ')], ['JustGrants Entity Administrator', admin.ao_ea||''], ['DOJ financial management training', admin.ao_train_yes?'Completed':admin.ao_train_60?'Will complete within 60 days of award':admin.ao_train_unk?'Unknown':''], ['[N deputies already hold ALERRT training]', alerrt?String(alerrt):''], ['Default targets', [a.lo_t1,a.lo_t2,a.lo_t3].filter(Boolean).join('; ')]]; if(CFG.show_existing_capability_question) rows.push(['Sentence on the existing capability in '+CFG.lead_county, a.le_existing]); const missing=rows.filter(r=>!(r[1]||'').trim()).map(r=>r[0]); if(preview){ $('fillMissing').textContent= missing.length? `Still missing for the narrative (${missing.length}): ${missing.join('; ')}` : 'Every narrative placeholder has a value.'; return; } const txt=`Narrative fill file: ${a.l2}, led by the ${CFG.lead_agency}\nBuilt ${new Date().toLocaleString('en-US')} from the lead answers and ${track.returns.length} returned file(s).\nTwo columns: placeholder as it appears in the narrative, then the value. Unanswered placeholders stay in brackets.\n\n`+ rows.map(([p,v])=>`${p}\t${(v||'').trim()||p}`).join('\n')+`\n\nStill missing (${missing.length}):\n`+(missing.map(m=>' '+m).join('\n')||' none'); dlText(`STOP_narrative_fill_${slug(a.l2)}.txt`, txt); } $('expFill').onclick=()=>fillFile(false); // start function init(){ if(MODE!=='lead'){ document.querySelectorAll('.tab').forEach(t=>t.classList.toggle('hidden', t.dataset.t!==MODE)); if(HASH.c){ const want=HASH.c.split('|'); S.counties.forEach(c=>{ c.on=want.includes(c.name); c.schools.forEach(s=>s.on=c.on); }); } $('modeNote').textContent= MODE==='partner' ? 'Partner questionnaire' : 'Financial administration questions'; } else { $('modeNote').textContent=''; } let draft=null; try{ draft=JSON.parse(localStorage.getItem(DRAFT_KEY)||'null'); }catch(e){} try{ fillConfig(); }catch(err){ showErr('settings', err); } restore(draft); checked().forEach(c=>agOpen.add(c.name)); render(); try{ fillConfig(); }catch(err){ showErr('settings', err); } if(MODE==='partner'){ if(HASH.type&&!draft) $('pType').value=HASH.type; if(HASH.county){ const o=[...$('pCounty').options].find(o=>o.value===HASH.county); if(o) $('pCounty').value=HASH.county; } if(HASH.agency&&!(draft&&draft.p_agency)){ $('pAgency').value=HASH.agency; $('pAgency').dataset.t=1; } } if(MODE==='admin'&&!draft){ $('aContact').value=[HASH.name,HASH.who,HASH.email].filter(Boolean).join(', '); } applyType(); counters(); showTab(MODE); if(draft) $('savedMsg').textContent='Draft restored from this browser'; } init(); })();