// backend/realtime.jsw import { publish } from 'wix-realtime'; /** * Broadcast a payload to everyone in a chat room. * Channel naming: room: */ export function broadcast(roomId, payload) { return publish(`room:${roomId}`, payload); }
top of page

The purpose of the following template is to assist you in writing your accessibility statement. Please note that you are responsible for ensuring that your site's statement meets the requirements of the local law in your area or region.
 

*Note: This page currently has several sections. Once you complete editing the Accessibility Statement below, you need to delete this section.
 

To learn more about this, check out our article “Accessibility: Adding an Accessibility Statement to Your Site”.

Accessibility statement

This statement was last updated on [enter relevant date].
 

We at [enter organization / business name] are working to make our site [enter site name and  address] accessible to people with disabilities.

What Web Accessibility Is

An accessible site allows visitors with disabilities to browse the site with the same or a similar level of ease and enjoyment as other visitors. This can be achieved with the capabilities of the system on which the site is operating, and through assistive technologies.

Accessibility Adjustments On This Site

We have adapted this site in accordance with WCAG [2.0 / 2.1 / 2.2 - select relevant option] guidelines, and have made the site accessible to the level of [A / AA / AAA - select relevant option]. This site's contents have been adapted to work with assistive technologies, such as screen readers and keyboard use. As part of this effort, we have also [remove irrelevant information]:

  • Used the Accessibility Wizard to find and fix potential accessibility issues

  • Set the language of the site

  • Set the content order of the site’s pages

  • Defined clear heading structures on all of the site’s pages

  • Added alternative text to images

  • Implemented color combinations that meet the required color contrast

  • Reduced the use of motion on the site

  • Ensured all videos, audio, and files on the site are accessible

Declaration Of Partial Compliance With The Standard Due To Third-party Content [only Add If Relevant]

The accessibility of certain pages on the site depend on contents that do not belong to the organization, and instead belong to [enter relevant third-party name]. The following pages are affected by this: [list the URLs of the pages]. We therefore declare partial compliance with the standard for these pages.

Accessibility Arrangements In The Organization [only Add If Relevant]

[Enter a description of the accessibility arrangements in the physical offices / branches of your site's organization or business. The description can include all current accessibility arrangements  - starting from the beginning of the service (e.g., the parking lot and / or  public transportation stations) to the end (such as the service desk, restaurant table, classroom etc.). It is also required to specify any additional accessibility arrangements, such as disabled services and their location, and accessibility accessories (e.g. in audio inductions and elevators) available for use]

Requests, Issues, And Suggestions

If you find an accessibility issue on the site, or if you require further assistance, you are welcome to contact us through the organization's accessibility coordinator:

  • [Name of the accessibility coordinator]

  • [Telephone number of the accessibility coordinator]

  • [Email address of the accessibility coordinator]

  • [Enter any additional contact details if relevant / available]

bottom of page
// backend/data.js import { broadcast } from 'backend/realtime'; /** * Fires after a document is inserted into the Messages collection * (Collection name: Messages -> function name: Messages_afterInsert) */ export function Messages_afterInsert(item, context) { // Keep the payload lean; it's sent to all subscribers. const payload = { _id: item._id, text: item.text, userId: item.userId, userName: item.userName, roomId: item.roomId, createdAt: item.createdAt }; // Fire-and-forget broadcast; don't block the insert lifecycle. broadcast(item.roomId, payload); return item; } // backend/data.js import { broadcast } from 'backend/realtime'; /** * Fires after a document is inserted into the Messages collection * (Collection name: Messages -> function name: Messages_afterInsert) */ export function Messages_afterInsert(item, context) { // Keep the payload lean; it's sent to all subscribers. const payload = { _id: item._id, text: item.text, userId: item.userId, userName: item.userName, roomId: item.roomId, createdAt: item.createdAt }; // Fire-and-forget broadcast; don't block the insert lifecycle. broadcast(item.roomId, payload); return item; } // Page code (e.g., Chat page) import wixData from 'wix-data'; import wixUsers from 'wix-users'; import { subscribe, unsubscribe } from 'wix-realtime'; // If you use Wix Members profile names, you can also import: // import { currentMember } from 'wix-members'; let roomId = 'global'; // default room (or drive from #roomPicker) let myUser = null; let realtimeSub = null; $w.onReady(async () => { myUser = wixUsers.currentUser; initRepeaterItemUI(); await loadMessages(); // Realtime subscribe resubscribe(); // Send message $w('#sendButton').onClick(sendCurrentMessage); $w('#messageInput').onKeyPress((e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendCurrentMessage(); } }); // Optional: switch rooms if ($w('#roomPicker')) { $w('#roomPicker').onChange(async () => { roomId = $w('#roomPicker').value; await loadMessages(); resubscribe(); }); } }); function initRepeaterItemUI() { $w('#messagesRepeater').onItemReady(($item, itemData) => { const mine = itemData.userId === (myUser?.id ?? 'anon'); // Hide both by default, then show one $item('#leftBubble').collapse(); $item('#rightBubble').collapse(); if (mine) { $item('#rightText').text = itemData.text || ''; $item('#rightMeta').text = metaText(itemData); $item('#rightBubble').expand(); } else { $item('#leftText').text = itemData.text || ''; $item('#leftMeta').text = metaText(itemData); $item('#leftBubble').expand(); } }); } function metaText(item) { const name = item.userName || (item.userId ? `User ${item.userId.slice(0,6)}` : 'User'); const ts = item.createdAt ? new Date(item.createdAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : ''; return `${name} • ${ts}`; } async function loadMessages() { const results = await wixData.query('Messages') .eq('roomId', roomId) .ascending('createdAt') .limit(200) // adjust / paginate as needed .find(); $w('#messagesRepeater').data = results.items; focusInput(); } function focusInput() { setTimeout(() => { if ($w('#messageInput')) $w('#messageInput').focus(); }, 50); } async function sendCurrentMessage() { const text = ($w('#messageInput').value || '').trim(); if (!text) return; const item = { text, userId: myUser?.id || 'anon', userName: await getDisplayName(), // or null roomId // createdAt is auto-set in the collection (Default: Now) }; await wixData.insert('Messages', item); // Triggers afterInsert -> broadcast $w('#messageInput').value = ''; } async function getDisplayName() { // Option A (simple): use email local-part if available try { if (myUser?.loggedIn) { const email = await myUser.getEmail(); if (email) return email.split('@')[0]; } } catch (e) { /* ignore */ } // Option B (comment in if using Wix Members): // try { // const member = await currentMember.getMember(); // return member?.profile?.nickname || member?.loginEmail || 'Member'; // } catch (e) {} return myUser?.loggedIn ? 'Member' : 'Guest'; } function resubscribe() { // Clean up the previous subscription if any if (realtimeSub) { try { unsubscribe(realtimeSub); } catch (e) {} realtimeSub = null; } // Subscribe to the current room channel realtimeSub = subscribe(`room:${roomId}`, (message) => { const payload = message?.payload; if (!payload) return; const data = $w('#messagesRepeater').data || []; data.push(payload); $w('#messagesRepeater').data = data; focusInput(); }); }