Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| vendors:cisco:uc:ece:custom-buttons [2026/02/12 10:00] – gerardorourke | vendors:cisco:uc:ece:custom-buttons [2026/02/25 15:54] (current) – [page1.html] gerardorourke | ||
|---|---|---|---|
| Line 31: | Line 31: | ||
| alert(" | alert(" | ||
| } | } | ||
| + | | ||
| + | // Detect Close Chat (this is only needed on pages, where chat can be initiated) | ||
| + | if (data.Caller === " | ||
| + | alert(" | ||
| + | } | ||
| // Detect badge count update (where greater than 0) | // Detect badge count update (where greater than 0) | ||
| if (data.Caller === " | if (data.Caller === " | ||
| if (data.Value> | if (data.Value> | ||
| - | var sound = new Audio(" | ||
| alert(" | alert(" | ||
| } | } | ||
| Line 51: | Line 55: | ||
| Chat is only be initiated from the ' | Chat is only be initiated from the ' | ||
| - | To do: Add additional HTML - for a screen reader - so when minimized | + | This code also includes code for the screen reader - if the chat is minimized |
| <file javascript index.html> | <file javascript index.html> | ||
| Line 59: | Line 63: | ||
| </ | </ | ||
| < | < | ||
| + | <!-- Start of CSS and HTML code for Screen Reader --> | ||
| + | < | ||
| + | .visually-hidden { | ||
| + | position: absolute; | ||
| + | width: 1px; | ||
| + | height: 1px; | ||
| + | padding: 0; | ||
| + | margin: -1px; | ||
| + | overflow: hidden; | ||
| + | clip: rect(0, 0, 0, 0); | ||
| + | white-space: | ||
| + | border: 0; | ||
| + | } | ||
| + | </ | ||
| + | <div id=" | ||
| + | <!-- End of CSS and HTML code for Screen Reader --> | ||
| + | |||
| + | <!-- Start of HTML code for Brief Intro and Chat Button --> | ||
| < | < | ||
| < | < | ||
| < | < | ||
| + | <!-- End of HTML code for Brief Intro and Chat Button --> | ||
| <!-- Configuration for a specific Chat Entrypoint, which sets the EntryPointId, | <!-- Configuration for a specific Chat Entrypoint, which sets the EntryPointId, | ||
| Line 117: | Line 140: | ||
| <script language=javascript> | <script language=javascript> | ||
| function showChatButton() { | function showChatButton() { | ||
| - | | + | |
| } | } | ||
| function hideChatButton() { | function hideChatButton() { | ||
| - | | + | |
| } | } | ||
| - | |||
| window.addEventListener(" | window.addEventListener(" | ||
| Line 129: | Line 151: | ||
| const data = JSON.parse(event.data); | const data = JSON.parse(event.data); | ||
| - | // This shows all ECE events to console (so disable / comment out this console output in production) | + | |
| - | console.log(" | + | console.log(" |
| // Detect minimize | // Detect minimize | ||
| Line 139: | Line 161: | ||
| // Detect maximize | // Detect maximize | ||
| if (data.Caller === " | if (data.Caller === " | ||
| - | hideChatButton(); | + | |
| + | // Screen reader announcement | ||
| + | var announcer = document.getElementById(" | ||
| + | announcer.textContent = ""; | ||
| } | } | ||
| - | // Detect badge count update | + | |
| + | if (data.Caller === " | ||
| + | showChatButton(); | ||
| + | } | ||
| + | |||
| + | | ||
| if (data.Caller === " | if (data.Caller === " | ||
| - | | + | var unread = data.Value; |
| - | // Note - download this audio file and host on your own webserver - in case the URL changes following a ECE update | + | if (unread > 0) { |
| - | var sound = new Audio("https:// | + | |
| + | var announcer = document.getElementById(" | ||
| + | if (unread === 1) { | ||
| + | // Screen reader announcement | ||
| + | | ||
| + | } else { | ||
| + | announcer.textContent = "Chat message received. You have " + unread + " unread messages."; | ||
| + | } | ||
| + | } | ||
| } | } | ||
| Line 161: | Line 199: | ||
| </ | </ | ||
| </ | </ | ||
| - | |||
| ==== page1.html==== | ==== page1.html==== | ||
| <file javascript page1.html> | <file javascript page1.html> | ||
| Line 169: | Line 206: | ||
| </ | </ | ||
| < | < | ||
| + | <!-- Start of CSS and HTML code for Screen Reader --> | ||
| + | < | ||
| + | .visually-hidden { | ||
| + | position: absolute; | ||
| + | width: 1px; | ||
| + | height: 1px; | ||
| + | padding: 0; | ||
| + | margin: -1px; | ||
| + | overflow: hidden; | ||
| + | clip: rect(0, 0, 0, 0); | ||
| + | white-space: | ||
| + | border: 0; | ||
| + | } | ||
| + | </ | ||
| + | <div id=" | ||
| + | <!-- End of CSS and HTML code for Screen Reader --> | ||
| + | |||
| + | <!-- Start of HTML code for Brief Intro and Chat Button (which is DISABLED by default as this is a page where chat is NOT initiated from --> | ||
| < | < | ||
| < | < | ||
| < | < | ||
| + | <!-- End of HTML code for Brief Intro and Chat Button --> | ||
| - | <!-- Basic Configuration for a Chat Entrypoint - when chat is NOT initiated on this page --> | + | <!-- Basic Configuration for a Chat Entrypoint - when chat is NOT initiated on this page - hence no EntryPoint IDs etc--> |
| <script language=javascript> | <script language=javascript> | ||
| /*eGain Chat server */ | /*eGain Chat server */ | ||
| Line 214: | Line 270: | ||
| const data = JSON.parse(event.data); | const data = JSON.parse(event.data); | ||
| - | // This shows all ECE events to console (so disable / comment out this console output in production) | + | // This shows all ECE events to console (so disable / comment out this console output in production) |
| - | console.log(" | + | console.log(" |
| // Detect minimize | // Detect minimize | ||
| if (data.Caller === " | if (data.Caller === " | ||
| - | | + | showChatButton(); |
| } | } | ||
| // Detect maximize | // Detect maximize | ||
| if (data.Caller === " | if (data.Caller === " | ||
| - | hideChatButton(); | + | hideChatButton(); |
| + | // Clear Screen reader announcement Text | ||
| + | var announcer = document.getElementById(" | ||
| + | announcer.textContent = ""; | ||
| } | } | ||
| - | // Detect badge count update | + | // Detect badge count update |
| if (data.Caller === " | if (data.Caller === " | ||
| - | if (data.Value > 0){ | + | var unread = data.Value; |
| - | document.getElementById(" | + | if (unread |
| - | }else{ | + | document.getElementById(" |
| - | document.getElementById(" | + | var announcer = document.getElementById(" |
| - | } | + | if (unread === 1) { |
| - | + | // Screen reader announcement | |
| - | // Note - download this audio file and host on your own webserver - in case the URL changes following a ECE update | + | announcer.textContent |
| - | var sound = new Audio("https:// | + | } else { |
| + | | ||
| + | } | ||
| + | } | ||
| } | } | ||