Mercurial > prosody-modules
diff mod_conversejs/mod_conversejs.lua @ 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 | 2681f74750b2 |
children | 4feab7e87675 |
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");