Changeset

3492:f59334da6df9

mod_conversejs: Show fallback text if converse.js fails to load (thanks MattJ) This can happen if javascript is enabled but 3rd party resources are blocked, or some other error happened.
author Kim Alvefur <zash@zash.se>
date Tue, 19 Mar 2019 19:43:13 +0100
parents 3491:4e9d4b07e3e9
children 3493:3d4eefdd950a
files mod_conversejs/mod_conversejs.lua
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_conversejs/mod_conversejs.lua	Sun Mar 17 17:56:54 2019 +0100
+++ b/mod_conversejs/mod_conversejs.lua	Tue Mar 19 19:43:13 2019 +0100
@@ -54,7 +54,16 @@
 </html>
 ]]):gsub("$([%w_]+)", { js_url = js_url, css_url = css_url });
 
-js_template = "converse.initialize(%s);";
+js_template = [[
+if(typeof converse == 'undefined') {
+	var div = document.createElement("div");
+	var noscript = document.getElementsByTagName("noscript")[0];
+	div.innerHTML = noscript.innerText;
+	document.body.appendChild(div);
+} else {
+	converse.initialize(%s);
+}
+]];
 
 local user_options = module:get_option("conversejs_options");