Built motion from commit 97153652.|2.6.26
[motion2.git] / server / files / chat / iframe.ejs
index 4a72eae..8bbdea1 100644 (file)
@@ -1,11 +1,14 @@
 (function() {
     'use strict';
-    const chatWebsiteAddressOrigin = '{{{chatWebsiteAddressOrigin}}}'
-    if(chatWebsiteAddressOrigin !== window.location.origin){
-        alert(`The current location does not match ${chatWebsiteAddressOrigin}. Please check your website domain in the current XCALLY Chat Website settings.`)
+    try {
+        const chatWebsiteAddress = new URL('{{{chatWebsiteAddressOrigin}}}')
+        if (chatWebsiteAddress.origin !== window.location.origin){
+            throw new Error(`Domain "${window.location.origin}"" can't load snippet for '{{{chatWebsiteAddressOrigin}}}'. Please check your website domain in the current XCALLY Chat Website settings.`)
+        }
+    } catch (error) {
+        window.alert(`Domain ${window.location.origin} can't load snippet for '{{{chatWebsiteAddressOrigin}}}'. Please check your website domain in the current XCALLY Chat Website settings.`)
+        return 
     }
-    else
-    {
         // Init all URLs
         const remoteURL = new URL('{{{remote}}}')
         const chatOrigin = remoteURL.origin
         <% if (hideWhenOffline && intervalId != null) { -%> // hide template
             document.getElementById("motion-chat-iframe-tab").style.display = "none";
         <% } -%>
-    }
 }()); 
\ No newline at end of file