Comparison

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
parent 3363:2681f74750b2
child 3494:4feab7e87675
comparison
equal deleted inserted replaced
3491:4e9d4b07e3e9 3492:f59334da6df9
52 <script>%s</script> 52 <script>%s</script>
53 </body> 53 </body>
54 </html> 54 </html>
55 ]]):gsub("$([%w_]+)", { js_url = js_url, css_url = css_url }); 55 ]]):gsub("$([%w_]+)", { js_url = js_url, css_url = css_url });
56 56
57 js_template = "converse.initialize(%s);"; 57 js_template = [[
58 if(typeof converse == 'undefined') {
59 var div = document.createElement("div");
60 var noscript = document.getElementsByTagName("noscript")[0];
61 div.innerHTML = noscript.innerText;
62 document.body.appendChild(div);
63 } else {
64 converse.initialize(%s);
65 }
66 ]];
58 67
59 local user_options = module:get_option("conversejs_options"); 68 local user_options = module:get_option("conversejs_options");
60 69
61 local function get_converse_options() 70 local function get_converse_options()
62 local allow_registration = module:get_option_boolean("allow_registration", false); 71 local allow_registration = module:get_option_boolean("allow_registration", false);