Standing on the Word Ministries
|
97 Victoria St E, Alliston, ON
Standing on the Word Ministries
Bethany Café & Thrift
Home
Our Ministry
About Us
Ministry, Outreach & Events Gallery
Partner & Donate
Bethany Café & Thrift Community Branch
Plan Your Visit
Visit
Standing on the Word Ministries
Standing on the Word Ministries
Standing on the unshakable truth of God's Word to bring hope, healing, and Christ-centered community to Alliston, Ontario and beyond. We are devoted to proclaiming the Gospel of Jesus Christ, praying for healing and restoration, equipping believers, and standing with our neighbours in faith.
Core Mission
Standing on the Word
Our heartbeat is proclaiming the Gospel of Jesus Christ, praying for healing and restoration, and equipping believers right in the heart of Alliston.
Standing on the Word Ministries
Prayer & Care
We Would Love to Stand With You in Faith
Visit us at 97 Victoria St E in Alliston for prayer and fellowship, or send us a prayer request online anytime.
Submit Prayer Request
Location & Contact
Community Branch
•
Closed • Opens Monday at 10:00 AM
Bethany Café & Thrift Shop
Local community café and thrift shop in Alliston, Ontario.
About Us
Proclaiming God's Word and serving our community through Standing on the Word Ministries.
Standing on the Word Ministries
Our Ministry & Outreach
Sharing the Gospel of Jesus Christ, praying for healing and restoration, equipping believers, and serving our community in Alliston and beyond.
Standing on the Word Ministries • Gather & Remember
Ministry, Outreach & Events Gallery
View photos from our ministry services, community outreach, fellowship moments, and upcoming and past events.
Stand With Us
Partner, Donate & Contact Us
Every gift and prayer helps advance Standing on the Word Ministries as we proclaim the Gospel and serve Alliston and beyond.
© 2026 Standing on the Word Ministries • Alliston, Ontario. All rights reserved.
Live Mode ON — Add & Remove buttons hidden
item && item.src && !isAutoAddedWhcPlaceholder(item));
galleryPhotos.splice(0, galleryPhotos.length, ...cleanPhotos);
await saveMediaState('galleryPhotos', galleryPhotos);
if (window.cloudSaveItem) {
for (const item of galleryPhotos) {
window.cloudSaveItem('gallery_photos', item);
}
}
}
if (Array.isArray(backup.upcomingEvents)) {
upcomingEvents.splice(0, upcomingEvents.length, ...backup.upcomingEvents);
await saveMediaState('upcomingEvents', upcomingEvents);
}
if (Array.isArray(backup.testimonies)) {
const mergedT = mergeUniqueTestimonies(backup.testimonies, DEFAULT_TESTIMONIES);
testimonies.splice(0, testimonies.length, ...mergedT);
await saveMediaState('testimonies', testimonies);
}
renderGallery();
renderUpcomingEvents();
renderTestimonies();
showToast(`Imported ${galleryPhotos.length} photos & all saved content from your backup!`);
} catch (err) {
showToast('Could not read photos from that file.');
}
};
reader.readAsText(file);
event.target.value = '';
};
function isAutoAddedWhcPlaceholder(item) {
return Boolean(item && item.id >= 1763680100001 && item.id <= 1763680300008);
}
window.syncSlotsFromCloud = async function (slots) {
if (!slots || typeof slots !== 'object') return;
if (slots.brandLogo) {
applyBrandLogoDataUrl(slots.brandLogo);
await saveMediaState('brandLogo', slots.brandLogo);
}
if (slots.bethanyLogo) {
applyBethanyLogoDataUrl(slots.bethanyLogo);
await saveMediaState('bethanyLogo', slots.bethanyLogo);
}
if (slots.backdropPhoto) {
applyBackdropDataUrl(slots.backdropPhoto);
await saveMediaState('backdropPhoto', slots.backdropPhoto);
}
if (slots.familyPhoto) {
applyFamilyDataUrl(slots.familyPhoto);
await saveMediaState('familyPhoto', slots.familyPhoto);
}
if (slots.ministryVideo) {
applyMinistryVideoState(slots.ministryVideo);
await saveMediaState('ministryVideo', slots.ministryVideo);
}
};
window.syncGalleryFromCloud = async function (items) {
if (Array.isArray(items)) {
const existingLocal = Array.isArray(await loadMediaState('galleryPhotos')) ? await loadMediaState('galleryPhotos') : galleryPhotos;
const localById = new Map(existingLocal.filter(x => x && x.id !== undefined).map(x => [x.id, x]));
const merged = items.map(item => {
if (!item || item.id === undefined) return item;
const local = localById.get(item.id);
if (!item.src && local && local.src) {
return { ...item, src: local.src };
}
return item;
});
existingLocal.forEach(local => {
if (local && local.id !== undefined && !merged.some(m => m && m.id === local.id)) {
merged.push(local);
}
});
merged.sort((a, b) => (b.id || 0) - (a.id || 0));
galleryPhotos.splice(0, galleryPhotos.length, ...merged);
await saveMediaState('galleryPhotos', galleryPhotos);
if (window.renderGallery) window.renderGallery();
}
};
window.syncEventsFromCloud = async function (items) {
if (Array.isArray(items)) {
upcomingEvents.splice(0, upcomingEvents.length, ...items);
await saveMediaState('upcomingEvents', upcomingEvents);
if (window.renderUpcomingEvents) window.renderUpcomingEvents();
}
};
window.syncTestimoniesFromCloud = async function (items) {
if (Array.isArray(items)) {
const merged = mergeUniqueTestimonies(items, DEFAULT_TESTIMONIES);
testimonies.splice(0, testimonies.length, ...merged);
await saveMediaState('testimonies', testimonies);
if (window.renderTestimonies) window.renderTestimonies();
}
};
function applyBrandLogoDataUrl(dataUrl) {
if (!dataUrl) return;
document.querySelectorAll('.sotw-logo-img').forEach(img => {
img.src = dataUrl;
});
}
function applyBethanyLogoDataUrl(dataUrl) {
if (!dataUrl) return;
document.querySelectorAll('.bethany-logo-img').forEach(img => {
img.src = dataUrl;
});
}
function applyBackdropDataUrl(dataUrl) {
const heroBg = document.getElementById('hero-storefront-backdrop');
const aboutImg = document.getElementById('about-storefront-full-img');
const aboutIllus = document.getElementById('about-storefront-illustration');
if (heroBg) heroBg.style.backgroundImage = dataUrl ? `url('${dataUrl}')` : '';
if (aboutImg) {
if (dataUrl) {
aboutImg.src = dataUrl;
aboutImg.classList.remove('hidden');
} else {
aboutImg.src = '';
aboutImg.classList.add('hidden');
}
}
if (aboutIllus) aboutIllus.classList.toggle('hidden', Boolean(dataUrl));
}
function applyFamilyDataUrl(dataUrl) {
const preview = document.getElementById('family-photo-preview');
const placeholder = document.getElementById('family-photo-placeholder');
if (preview) {
preview.src = dataUrl;
preview.classList.remove('hidden');
}
if (placeholder) placeholder.classList.add('hidden');
}
function extractYoutubeEmbedUrl(rawUrl) {
if (!rawUrl) return '';
const trimmed = String(rawUrl).trim();
const match = trimmed.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([A-Za-z0-9_-]{11})/);
return match ? `https://www.youtube.com/embed/${match[1]}` : '';
}
window.showMinistryVideoPlaceholder = function () {
const player = document.getElementById('ministry-video-player');
const ytFrame = document.getElementById('ministry-youtube-iframe');
const placeholder = document.getElementById('ministry-video-placeholder');
if (ytFrame && !ytFrame.classList.contains('hidden')) return;
if (player) player.classList.add('hidden');
if (placeholder) placeholder.classList.remove('hidden');
};
function applyMinistryVideoState(videoData) {
const player = document.getElementById('ministry-video-player');
const ytFrame = document.getElementById('ministry-youtube-iframe');
const placeholder = document.getElementById('ministry-video-placeholder');
window._currentMinistryVideo = videoData || null;
if (!videoData) {
if (ytFrame) {
ytFrame.src = '';
ytFrame.classList.add('hidden');
}
if (player) {
player.pause();
player.removeAttribute('src');
player.classList.add('hidden');
}
if (placeholder) placeholder.classList.remove('hidden');
return;
}
if (videoData.type === 'youtube' && videoData.embedUrl) {
if (player) {
player.pause();
player.classList.add('hidden');
}
if (placeholder) placeholder.classList.add('hidden');
if (ytFrame) {
ytFrame.src = videoData.embedUrl;
ytFrame.classList.remove('hidden');
}
} else if (videoData.type === 'file' && videoData.src) {
if (ytFrame) {
ytFrame.src = '';
ytFrame.classList.add('hidden');
}
if (placeholder) placeholder.classList.add('hidden');
if (player) {
player.src = videoData.src;
player.load();
player.classList.remove('hidden');
}
}
}
window.handleBrandLogoUpload = function (event) {
const file = event.target.files && event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = async function (e) {
const dataUrl = await window.compressImageDataUrl(e.target.result, 700, 0.85);
applyBrandLogoDataUrl(dataUrl);
await saveMediaState('brandLogo', dataUrl);
if (window.cloudSaveSingle) window.cloudSaveSingle('brandLogo', dataUrl);
showToast('Standing on the Word logo locked in across all banners!');
};
reader.readAsDataURL(file);
event.target.value = '';
};
window.handleBethanyLogoUpload = function (event) {
const file = event.target.files && event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = async function (e) {
const dataUrl = await window.compressImageDataUrl(e.target.result, 700, 0.85);
applyBethanyLogoDataUrl(dataUrl);
await saveMediaState('bethanyLogo', dataUrl);
if (window.cloudSaveSingle) window.cloudSaveSingle('bethanyLogo', dataUrl);
showToast('Bethany Café & Thrift logo locked in across all Bethany banners!');
};
reader.readAsDataURL(file);
event.target.value = '';
};
window.handleFamilyPhotoUpload = function (event) {
const file = event.target.files && event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = async function (e) {
const dataUrl = await window.compressImageDataUrl(e.target.result, 720, 0.78);
applyFamilyDataUrl(dataUrl);
await saveMediaState('familyPhoto', dataUrl);
if (window.cloudSaveSingle) window.cloudSaveSingle('familyPhoto', dataUrl);
showToast('Jesse & Gabrielle photo saved!');
};
reader.readAsDataURL(file);
event.target.value = '';
};
window.removeFamilyPhoto = function () {
const preview = document.getElementById('family-photo-preview');
const placeholder = document.getElementById('family-photo-placeholder');
if (preview) {
preview.src = '';
preview.classList.add('hidden');
}
if (placeholder) placeholder.classList.remove('hidden');
saveMediaState('familyPhoto', null);
if (window.cloudSaveSingle) window.cloudSaveSingle('familyPhoto', null);
showToast('Jesse & Gabrielle photo removed.');
};
window.handleMinistryVideoUpload = function (event) {
const file = event.target.files && event.target.files[0];
if (!file) return;
const objectUrl = URL.createObjectURL(file);
const videoState = { type: 'file', src: objectUrl, fileName: file.name };
applyMinistryVideoState(videoState);
showToast('Video loaded in preview! Upload it as ministry-video.mp4 to WHC.ca for live hosting.');
event.target.value = '';
};
window.handleMinistryYoutubeLink = async function () {
const input = document.getElementById('ministry-youtube-input');
const rawUrl = input ? input.value.trim() : '';
const embedUrl = extractYoutubeEmbedUrl(rawUrl);
if (!embedUrl) {
showToast('Please paste a valid YouTube video link.');
return;
}
const videoState = { type: 'youtube', embedUrl, originalUrl: rawUrl };
applyMinistryVideoState(videoState);
await saveMediaState('ministryVideo', videoState);
if (window.cloudSaveSingle) window.cloudSaveSingle('ministryVideo', videoState);
if (input) input.value = '';
showToast('YouTube ministry video linked and saved!');
};
window.removeMinistryVideo = function () {
applyMinistryVideoState(null);
saveMediaState('ministryVideo', null);
if (window.cloudSaveSingle) window.cloudSaveSingle('ministryVideo', null);
showToast('Ministry video removed.');
};
function isCameraFileCode(label) {
if (!label) return true;
const trimmed = String(label).trim();
if (!trimmed) return true;
return /^(img|dsc|pxl|vid|mvimg|screenshot|photo|image|scan|cam)[_\-\s]?\d{4,}(\s*\(\d+\))?$/i.test(trimmed)
|| /^[\d\s()_\-]+$/.test(trimmed);
}
function containsDisallowedPhotoWords(text) {
if (!text) return false;
return /\b(jesse|gabrielle|gabriella|event\s*\d*|event|masses|praising|outreach|teamwork)\b/i.test(String(text));
}
function formatDisplayCaption(rawCaption) {
if (!rawCaption || isCameraFileCode(rawCaption) || containsDisallowedPhotoWords(rawCaption)) {
return '';
}
return String(rawCaption).trim();
}
function formatDisplaySubtext() {
return '';
}
window.removePhotoById = function (event, id) {
if (event) event.stopPropagation();
const idx = galleryPhotos.findIndex(item => item.id === id);
if (idx !== -1) {
galleryPhotos.splice(idx, 1);
saveMediaState('galleryPhotos', galleryPhotos);
if (window.cloudDeleteItem) window.cloudDeleteItem('gallery_photos', id);
renderGallery();
showToast('Photo removed.');
}
};
window.handleDirectPhotoFiles = async function (event, category) {
const files = Array.from(event.target.files || []);
if (files.length === 0) return;
const resolvedCategory = category || 'Community';
let addedCount = 0;
for (let idx = 0; idx < files.length; idx++) {
const file = files[idx];
const rawDataUrl = await new Promise((resolve) => {
const reader = new FileReader();
reader.onload = (e) => resolve(e.target.result);
reader.onerror = () => resolve('');
reader.readAsDataURL(file);
});
if (!rawDataUrl) continue;
const dataUrl = await window.compressImageDataUrl(rawDataUrl, 1000, 0.78);
const cleanName = file.name.replace(/\.[^/.]+$/, '').replace(/[-_]+/g, ' ');
const newItem = {
id: Date.now() + idx + Math.floor(Math.random() * 1000),
category: resolvedCategory,
fileCode: cleanName,
caption: '',
subtext: '',
src: dataUrl
};
galleryPhotos.unshift(newItem);
addedCount++;
await saveMediaState('galleryPhotos', galleryPhotos);
if (window.cloudSaveItem) window.cloudSaveItem('gallery_photos', newItem);
}
event.target.value = '';
renderGallery();
if (addedCount > 0) {
showToast(`${addedCount} photo${addedCount > 1 ? 's' : ''} saved!`);
}
};
function createPhotoCardHtml(photo) {
const safeSrc = String(photo.src || '').replace(/'/g, "\\'");
return `
✕ Remove
`;
}
window.renderGallery = function () {
const communityGrid = document.getElementById('gallery-grid');
const outreachGrid = document.getElementById('events-outreach-photo-grid');
const eventsGrid = document.getElementById('events-ministry-photo-grid');
const outreachPhotos = galleryPhotos.filter(p => p.category === 'Outreach' || p.category === 'Outreach & Services');
if (outreachGrid) {
if (outreachPhotos.length === 0) {
outreachGrid.className = 'block';
outreachGrid.innerHTML = `
Outreach Photos Coming Soon
Use the + Add Outreach Photos button above to upload pictures. Each photo will appear here with a ✕ Remove button.
`;
} else {
outreachGrid.className = 'columns-1 sm:columns-2 lg:columns-3 gap-5';
outreachGrid.innerHTML = outreachPhotos.map(createPhotoCardHtml).join('');
}
}
const eventPhotos = galleryPhotos.filter(p => p.category === 'Events');
if (eventsGrid) {
if (eventPhotos.length === 0) {
eventsGrid.className = 'block';
eventsGrid.innerHTML = `
Event Photos Coming Soon
Use the + Add Event Photos button above to upload pictures. Each photo will appear here with a ✕ Remove button.
`;
} else {
eventsGrid.className = 'columns-1 sm:columns-2 lg:columns-3 gap-5';
eventsGrid.innerHTML = eventPhotos.map(createPhotoCardHtml).join('');
}
}
if (communityGrid) {
const communityPhotos = galleryPhotos.filter(p => p.category !== 'Outreach' && p.category !== 'Outreach & Services' && p.category !== 'Events');
if (communityPhotos.length === 0) {
communityGrid.className = 'block';
communityGrid.innerHTML = `
Community Photos Coming Soon
Use the + Add Community Photos button above to upload pictures. Each photo can be removed anytime.
`;
} else {
communityGrid.className = 'columns-1 sm:columns-2 lg:columns-3 gap-5';
communityGrid.innerHTML = communityPhotos.map(createPhotoCardHtml).join('');
}
}
};
window.openLightbox = function (src, caption) {
const img = document.getElementById('lightbox-img');
const cap = document.getElementById('lightbox-caption');
if (img) img.src = src;
if (cap) cap.textContent = caption;
openModal('lightbox-modal');
};
window.handleEventPosterSelect = function (event) {
const file = event.target.files && event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = async function (e) {
pendingEventPosterDataUrl = await window.compressImageDataUrl(e.target.result, 1000, 0.78);
const preview = document.getElementById('event-poster-preview');
const wrap = document.getElementById('event-poster-preview-wrap');
if (preview) preview.src = pendingEventPosterDataUrl;
if (wrap) wrap.classList.remove('hidden');
};
reader.readAsDataURL(file);
};
window.clearEventPosterPreview = function () {
pendingEventPosterDataUrl = '';
const input = document.getElementById('event-poster-input');
const wrap = document.getElementById('event-poster-preview-wrap');
if (input) input.value = '';
if (wrap) wrap.classList.add('hidden');
};
window.removeEventById = function (id) {
const idx = upcomingEvents.findIndex(item => item.id === id);
if (idx !== -1) {
upcomingEvents.splice(idx, 1);
saveMediaState('upcomingEvents', upcomingEvents);
if (window.cloudDeleteItem) window.cloudDeleteItem('upcoming_events', id);
renderUpcomingEvents();
showToast('Event removed.');
}
};
window.removeEventPosterOnly = function (id) {
const ev = upcomingEvents.find(item => item.id === id);
if (ev) {
ev.posterSrc = '';
saveMediaState('upcomingEvents', upcomingEvents);
if (window.cloudSaveItem) window.cloudSaveItem('upcoming_events', ev);
renderUpcomingEvents();
showToast('Event poster removed.');
}
};
window.handleAddEvent = function (event) {
event.preventDefault();
const title = document.getElementById('event-title').value.trim();
const date = document.getElementById('event-date').value.trim();
const location = document.getElementById('event-location').value.trim() || '97 Victoria St E, Alliston';
const desc = document.getElementById('event-desc').value.trim();
if (!title || !date) return;
const newEv = {
id: Date.now(),
title,
date,
location,
desc,
posterSrc: pendingEventPosterDataUrl
};
upcomingEvents.unshift(newEv);
saveMediaState('upcomingEvents', upcomingEvents);
if (window.cloudSaveItem) window.cloudSaveItem('upcoming_events', newEv);
document.getElementById('event-title').value = '';
document.getElementById('event-date').value = '';
document.getElementById('event-location').value = '97 Victoria St E, Alliston';
document.getElementById('event-desc').value = '';
clearEventPosterPreview();
closeModal('event-modal');
renderUpcomingEvents();
showToast('Upcoming event saved!');
};
window.renderUpcomingEvents = function () {
const list = document.getElementById('upcoming-events-list');
if (!list) return;
if (upcomingEvents.length === 0) {
list.innerHTML = `
New Events & Outreach Dates Coming Soon
Subscribe on YouTube or check back here for upcoming gathering times and outreach announcements.
`;
return;
}
list.innerHTML = upcomingEvents.map(ev => `
${ev.posterSrc ? `
✕ Remove Poster
` : ''}
${ev.date}
✕ Remove Event
${ev.title}
${ev.location}
${ev.desc}
`).join('');
};
window.toggleInlineTestimonyForm = function (forceState) {
const wrap = document.getElementById('inline-testimony-form-wrap');
if (!wrap) return;
const shouldShow = typeof forceState === 'boolean' ? forceState : wrap.classList.contains('hidden');
wrap.classList.toggle('hidden', !shouldShow);
if (shouldShow) {
const authorInput = document.getElementById('inline-testimony-author');
if (authorInput) authorInput.focus();
}
};
window.removeTestimonyById = function (id) {
const idx = testimonies.findIndex(item => item.id === id);
if (idx !== -1) {
testimonies.splice(idx, 1);
saveMediaState('testimonies', testimonies);
if (window.cloudDeleteItem) window.cloudDeleteItem('testimonies', id);
renderTestimonies();
showToast('Testimony removed.');
}
};
async function postTestimonyRecord(author, story) {
const dateLabel = new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
const newTestimony = { id: Date.now(), author, story, dateLabel };
testimonies.unshift(newTestimony);
await saveMediaState('testimonies', testimonies);
if (window.cloudSaveItem) window.cloudSaveItem('testimonies', newTestimony);
renderTestimonies();
try {
await fetch(`https://formsubmit.co/ajax/${encodeURIComponent(MINISTRY_INBOX_EMAIL)}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
body: JSON.stringify({
_subject: `New Community Testimony from ${author} — Standing on the Word Ministries`,
_template: 'table',
'Author': author,
'Testimony': story,
'Date': dateLabel
})
});
} catch (e) { /* handled silently */ }
}
window.handleInlineTestimonySubmit = async function (event) {
event.preventDefault();
const authorEl = document.getElementById('inline-testimony-author');
const storyEl = document.getElementById('inline-testimony-story');
const author = authorEl ? authorEl.value.trim() : '';
const story = storyEl ? storyEl.value.trim() : '';
if (!author || !story) return;
await postTestimonyRecord(author, story);
if (authorEl) authorEl.value = '';
if (storyEl) storyEl.value = '';
toggleInlineTestimonyForm(false);
showToast('Thank you! Your testimony has been posted below.');
};
window.handleAddTestimony = async function (event) {
event.preventDefault();
const authorEl = document.getElementById('testimony-author');
const storyEl = document.getElementById('testimony-story');
const author = authorEl ? authorEl.value.trim() : '';
const story = storyEl ? storyEl.value.trim() : '';
if (!author || !story) return;
await postTestimonyRecord(author, story);
if (authorEl) authorEl.value = '';
if (storyEl) storyEl.value = '';
closeModal('testimony-modal');
showToast('Your testimony is now posted below!');
};
window.renderTestimonies = function () {
const list = document.getElementById('testimonies-list');
if (!list) return;
if (testimonies.length === 0) {
list.innerHTML = `
Stories of Faith & Restoration
Has God blessed your life through Standing on the Word Ministries? Click below to share your testimony with our community.
+ Share Your Testimony
`;
return;
}
list.innerHTML = testimonies.map(t => `
✕ Remove
“${t.story}”
— ${t.author}
${t.dateLabel ? `
${t.dateLabel} ` : ''}
`).join('');
};
window.prepareContactSubmit = async function (event) {
event.preventDefault();
const nameEl = document.getElementById('contact-name');
const emailEl = document.getElementById('contact-email');
const phoneEl = document.getElementById('contact-phone');
const msgEl = document.getElementById('contact-msg');
const btn = document.getElementById('contact-submit-btn');
const confirmBox = document.getElementById('contact-confirm-box');
const name = nameEl ? nameEl.value.trim() : '';
const email = emailEl ? emailEl.value.trim() : '';
const phone = phoneEl ? phoneEl.value.trim() : '';
const msg = msgEl ? msgEl.value.trim() : '';
if (!name || !email || !msg) return;
if (btn) {
btn.disabled = true;
btn.textContent = 'Sending Message...';
}
try {
await fetch(`https://formsubmit.co/ajax/${encodeURIComponent(MINISTRY_INBOX_EMAIL)}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
body: JSON.stringify({
_subject: `New Website Note from ${name} — Standing on the Word Ministries`,
_template: 'table',
_autoresponse: "Thank you for sending a message to Standing on the Word Ministries! We have received your note and will get back to you as soon as possible. Blessings in Christ, Standing on the Word Ministries (97 Victoria St E, Alliston, ON).",
'Sender Name': name,
email: email,
'Phone Number': phone || 'Not provided',
'Message': msg
})
});
} catch (e) { /* handled gracefully */ }
resetContactFormFields();
if (confirmBox) confirmBox.classList.remove('hidden');
showToast('Message sent! A confirmation email has been sent to your inbox.');
};
window.preparePrayerSubmit = async function (event) {
event.preventDefault();
const nameEl = document.getElementById('prayer-name');
const emailEl = document.getElementById('prayer-email');
const textEl = document.getElementById('prayer-text');
const btn = document.getElementById('prayer-submit-btn');
const confirmBox = document.getElementById('prayer-confirm-box');
const name = nameEl ? nameEl.value.trim() : '';
const email = emailEl ? emailEl.value.trim() : '';
const prayerText = textEl ? textEl.value.trim() : '';
if (!name || !prayerText) return;
if (btn) {
btn.disabled = true;
btn.textContent = 'Sending Prayer Request...';
}
const payload = {
_subject: `New Prayer Request from ${name} — Standing on the Word Ministries`,
_template: 'table',
_autoresponse: "Thank you for sharing your prayer request with Standing on the Word Ministries. We have received your request and are standing with you in faith and prayer. Blessings in Jesus' Name, Standing on the Word Ministries.",
'Name': name,
'Prayer Request': prayerText
};
if (email) payload.email = email;
try {
await fetch(`https://formsubmit.co/ajax/${encodeURIComponent(MINISTRY_INBOX_EMAIL)}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
body: JSON.stringify(payload)
});
} catch (e) { /* handled gracefully */ }
if (btn) {
btn.disabled = false;
btn.textContent = 'Send Prayer Request';
}
if (nameEl) nameEl.value = '';
if (emailEl) emailEl.value = '';
if (textEl) textEl.value = '';
if (confirmBox) confirmBox.classList.remove('hidden');
showToast('Prayer request sent! We are standing with you in faith.');
};
window.downloadHtmlSnapshot = function () {
try {
const clone = document.documentElement.cloneNode(true);
const cloneBody = clone.querySelector('body');
if (cloneBody) cloneBody.classList.remove('edit-mode');
const cloneBanner = clone.querySelector('#edit-mode-banner');
if (cloneBanner) cloneBanner.remove();
const sotwLogoEl = document.getElementById('hero-brand-logo-img');
const currentBrandLogo = (sotwLogoEl && sotwLogoEl.src && sotwLogoEl.src.startsWith('data:image')) ? sotwLogoEl.src : '';
const bethanyLogoEl = document.getElementById('hero-bethany-logo-img');
const currentBethanyLogo = (bethanyLogoEl && bethanyLogoEl.src && bethanyLogoEl.src.startsWith('data:image')) ? bethanyLogoEl.src : '';
const heroBg = document.getElementById('hero-storefront-backdrop');
const currentBackdrop = heroBg && heroBg.style.backgroundImage && heroBg.style.backgroundImage.includes('data:image')
? heroBg.style.backgroundImage.slice(5, -2)
: '';
const familyImgEl = document.getElementById('family-photo-preview');
const currentFamily = (familyImgEl && !familyImgEl.classList.contains('hidden') && familyImgEl.src && familyImgEl.src.startsWith('data:image'))
? familyImgEl.src
: '';
const currentMinistryVideo = (window._currentMinistryVideo && window._currentMinistryVideo.type === 'youtube')
? window._currentMinistryVideo
: null;
if (currentBrandLogo) {
clone.querySelectorAll('.sotw-logo-img').forEach(img => img.setAttribute('src', currentBrandLogo));
}
if (currentBethanyLogo) {
clone.querySelectorAll('.bethany-logo-img').forEach(img => img.setAttribute('src', currentBethanyLogo));
}
if (currentFamily) {
const clonedFamilyImg = clone.querySelector('#family-photo-preview');
const clonedFamilyPlaceholder = clone.querySelector('#family-photo-placeholder');
if (clonedFamilyImg) {
clonedFamilyImg.setAttribute('src', currentFamily);
clonedFamilyImg.classList.remove('hidden');
}
if (clonedFamilyPlaceholder) clonedFamilyPlaceholder.classList.add('hidden');
}
const safeJson = (obj) => JSON.stringify(obj).replace(/<\/script/gi, '<\\/script');
const seedScript = document.createElement('script');
seedScript.textContent = `
window.__EMBEDDED_BETHANY_BACKUP__ = ${safeJson({
brandLogo: currentBrandLogo,
bethanyLogo: currentBethanyLogo,
backdropPhoto: currentBackdrop,
familyPhoto: currentFamily,
ministryVideo: currentMinistryVideo,
galleryPhotos: galleryPhotos,
upcomingEvents: upcomingEvents,
testimonies: testimonies
})};
`;
clone.querySelector('body').appendChild(seedScript);
const htmlContent = '\n' + clone.outerHTML;
const blob = new Blob([htmlContent], { type: 'text/html;charset=utf-8' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'index.html';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => URL.revokeObjectURL(url), 2000);
showToast('Saved live index.html backup with all your photos & logos locked in!');
} catch (err) {
showToast('Could not generate backup download.');
}
};
window.setEditMode = function (enabled) {
const isEnabled = Boolean(enabled);
document.body.classList.toggle('edit-mode', isEnabled);
const btn = document.getElementById('design-mode-btn');
const track = document.getElementById('design-mode-track');
const thumb = document.getElementById('design-mode-thumb');
const dot = document.getElementById('design-mode-dot');
const statusLabel = document.getElementById('design-mode-label');
const toggleText = document.getElementById('design-mode-toggle-text');
if (btn) btn.setAttribute('aria-checked', String(isEnabled));
if (track) track.style.backgroundColor = isEnabled ? '#cfa052' : '#475569';
if (thumb) thumb.style.transform = isEnabled ? 'translateX(16px)' : 'translateX(0px)';
if (dot) {
dot.className = 'w-2.5 h-2.5 rounded-full ' + (isEnabled ? 'bg-amber-400 animate-pulse' : 'bg-emerald-400');
}
if (statusLabel) {
statusLabel.textContent = isEnabled ? 'Design Mode Active' : 'Live Mode';
statusLabel.className = 'font-bold text-gold-300';
}
if (toggleText) {
toggleText.textContent = isEnabled ? 'Exit Design Mode' : 'Enter Design Mode';
}
if (isEnabled) {
showToast('Design Mode ON — Add & Remove buttons unlocked');
} else {
showToast('Live Mode ON — Add & Remove buttons hidden');
}
};
window.toggleDesignMode = function () {
const isCurrentlyEditing = document.body.classList.contains('edit-mode');
window.setEditMode(!isCurrentlyEditing);
};
async function initSite() {
const yearEl = document.getElementById('current-year');
if (yearEl) yearEl.textContent = new Date().getFullYear();
updateAllistonStatus();
const embedded = window.__EMBEDDED_BETHANY_BACKUP__ || {};
const [savedBrandLogo, savedBethanyLogo, savedBackdrop, savedFamily, savedMinistryVideo, savedGallery, savedEvents, savedTestimonies] = await Promise.all([
loadMediaState('brandLogo'),
loadMediaState('bethanyLogo'),
loadMediaState('backdropPhoto'),
loadMediaState('familyPhoto'),
loadMediaState('ministryVideo'),
loadMediaState('galleryPhotos'),
loadMediaState('upcomingEvents'),
loadMediaState('testimonies')
]);
const finalBrandLogo = savedBrandLogo || embedded.brandLogo;
const finalBethanyLogo = savedBethanyLogo || embedded.bethanyLogo;
const finalBackdrop = savedBackdrop || embedded.backdropPhoto;
const finalFamily = savedFamily || embedded.familyPhoto;
const finalMinistryVideo = savedMinistryVideo || embedded.ministryVideo;
const finalGallery = Array.isArray(savedGallery) && savedGallery.length > 0
? savedGallery
: (Array.isArray(embedded.galleryPhotos) ? embedded.galleryPhotos : []);
const finalEvents = Array.isArray(savedEvents) && savedEvents.length > 0
? savedEvents
: (Array.isArray(embedded.upcomingEvents) ? embedded.upcomingEvents : []);
const rawTestimonies = Array.isArray(savedTestimonies) && savedTestimonies.length > 0
? savedTestimonies
: (Array.isArray(embedded.testimonies) ? embedded.testimonies : []);
const finalTestimonies = mergeUniqueTestimonies(rawTestimonies, DEFAULT_TESTIMONIES);
if (finalBrandLogo) applyBrandLogoDataUrl(finalBrandLogo);
if (finalBethanyLogo) applyBethanyLogoDataUrl(finalBethanyLogo);
if (finalBackdrop) applyBackdropDataUrl(finalBackdrop);
if (finalFamily) applyFamilyDataUrl(finalFamily);
if (finalMinistryVideo) applyMinistryVideoState(finalMinistryVideo);
galleryPhotos.splice(0, galleryPhotos.length, ...finalGallery);
upcomingEvents.splice(0, upcomingEvents.length, ...finalEvents);
testimonies.splice(0, testimonies.length, ...finalTestimonies);
renderGallery();
renderUpcomingEvents();
renderTestimonies();
setInterval(updateAllistonStatus, 60000);
}
function setupShortcutsAndQueryParams() {
const dropdownBtn = document.getElementById('main-nav-dropdown-btn');
if (dropdownBtn) {
dropdownBtn.onclick = function (e) {
window.toggleDropdown(e, 'main-nav-dropdown');
};
}
const params = new URLSearchParams(window.location.search);
if (params.get('edit') === '1') {
window.setEditMode(true);
}
if (params.get('backup') === '1') {
downloadHtmlSnapshot();
}
if (params.get('sent') === 'contact') {
window.navigateTo('partner');
const confirmBox = document.getElementById('contact-confirm-box');
if (confirmBox) confirmBox.classList.remove('hidden');
showToast('Thank you! Your message has been sent.');
}
if (params.get('sent') === 'prayer') {
showToast('Prayer request received! We are standing with you in faith.');
}
document.addEventListener('keydown', function (e) {
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key.toLowerCase() === 'e') {
e.preventDefault();
window.toggleDesignMode();
}
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key.toLowerCase() === 'b') {
e.preventDefault();
downloadHtmlSnapshot();
}
});
}
const FIRESTORE_MAX_FIELD_BYTES = 950000;
function byteLengthUtf8(str) {
if (!str) return 0;
try {
return new TextEncoder().encode(String(str)).length;
} catch (e) {
return String(str).length * 2;
}
}
async function initCloudSync() {
try {
if (typeof __firebase_config === 'undefined' || !__firebase_config) return;
const { initializeApp } = await import("https://www.gstatic.com/firebasejs/11.6.1/firebase-app.js");
const { getAuth, signInAnonymously, signInWithCustomToken } = await import("https://www.gstatic.com/firebasejs/11.6.1/firebase-auth.js");
const { getFirestore, doc, setDoc, deleteDoc, collection, onSnapshot } = await import("https://www.gstatic.com/firebasejs/11.6.1/firebase-firestore.js");
const cloudAppId = 'standing-on-the-word-ministries-alliston';
const firebaseConfig = typeof __firebase_config === 'string'
? JSON.parse(__firebase_config)
: __firebase_config;
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const cloudDb = getFirestore(app);
let cloudUser = null;
if (typeof __initial_auth_token !== 'undefined' && __initial_auth_token) {
const cred = await signInWithCustomToken(auth, __initial_auth_token);
cloudUser = cred.user;
} else {
const cred = await signInAnonymously(auth);
cloudUser = cred.user;
}
if (!cloudUser) return;
window.cloudSaveSingle = async function (docKey, dataUrl) {
try {
const ref = doc(cloudDb, 'artifacts', cloudAppId, 'public', 'data', 'site_slots', docKey);
if (!dataUrl) {
await deleteDoc(ref);
} else if (typeof dataUrl === 'string') {
if (byteLengthUtf8(dataUrl) <= FIRESTORE_MAX_FIELD_BYTES) {
await setDoc(ref, { dataUrl, updatedAt: Date.now() });
}
} else {
await setDoc(ref, { dataUrl, updatedAt: Date.now() });
}
} catch (err) { /* handled gracefully */ }
};
window.cloudSaveItem = async function (colName, itemObj) {
try {
const ref = doc(cloudDb, 'artifacts', cloudAppId, 'public', 'data', colName, String(itemObj.id));
const srcBytes = byteLengthUtf8(itemObj.src);
const posterBytes = byteLengthUtf8(itemObj.posterSrc);
if (srcBytes > FIRESTORE_MAX_FIELD_BYTES || posterBytes > FIRESTORE_MAX_FIELD_BYTES) {
await setDoc(ref, {
...itemObj,
src: srcBytes > FIRESTORE_MAX_FIELD_BYTES ? '' : itemObj.src,
posterSrc: posterBytes > FIRESTORE_MAX_FIELD_BYTES ? '' : itemObj.posterSrc,
localMediaOnly: true
});
} else {
await setDoc(ref, itemObj);
}
} catch (err) { /* handled gracefully */ }
};
window.cloudDeleteItem = async function (colName, itemId) {
try {
const ref = doc(cloudDb, 'artifacts', cloudAppId, 'public', 'data', colName, String(itemId));
await deleteDoc(ref);
} catch (err) { /* handled gracefully */ }
};
const slotsCol = collection(cloudDb, 'artifacts', cloudAppId, 'public', 'data', 'site_slots');
onSnapshot(slotsCol, (snap) => {
const slots = {};
snap.forEach(d => { slots[d.id] = d.data()?.dataUrl || null; });
if (window.syncSlotsFromCloud) window.syncSlotsFromCloud(slots);
}, () => {});
const galleryCol = collection(cloudDb, 'artifacts', cloudAppId, 'public', 'data', 'gallery_photos');
onSnapshot(galleryCol, (snap) => {
const items = [];
snap.forEach(d => items.push(d.data()));
items.sort((a, b) => (b.id || 0) - (a.id || 0));
if (window.syncGalleryFromCloud) window.syncGalleryFromCloud(items);
}, () => {});
const eventsCol = collection(cloudDb, 'artifacts', cloudAppId, 'public', 'data', 'upcoming_events');
onSnapshot(eventsCol, (snap) => {
const items = [];
snap.forEach(d => items.push(d.data()));
items.sort((a, b) => (b.id || 0) - (a.id || 0));
if (window.syncEventsFromCloud) window.syncEventsFromCloud(items);
}, () => {});
const testCol = collection(cloudDb, 'artifacts', cloudAppId, 'public', 'data', 'testimonies');
onSnapshot(testCol, (snap) => {
const items = [];
snap.forEach(d => items.push(d.data()));
items.sort((a, b) => (b.id || 0) - (a.id || 0));
if (window.syncTestimoniesFromCloud) window.syncTestimoniesFromCloud(items);
}, () => {});
} catch (e) {
// Fallback silently when running outside cloud sandbox
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function () {
setupShortcutsAndQueryParams();
initSite();
initCloudSync();
});
} else {
setupShortcutsAndQueryParams();
initSite();
initCloudSync();
}