diff --git a/code/modules/nano/nanoui.dm b/code/modules/nano/nanoui.dm index 0a68fcd5977..355213ecf74 100644 --- a/code/modules/nano/nanoui.dm +++ b/code/modules/nano/nanoui.dm @@ -92,8 +92,8 @@ nanoui is used to open and update nano browser uis */ /datum/nanoui/proc/add_common_assets() add_script("libraries.min.js") // The jQuery library + add_script("nano_config.js") // The NanoConfig JS, this is used to store configuration values. add_script("nano_update.js") // The NanoUpdate JS, this is used to receive updates and apply them. - add_script("nano_config.js") // The NanoUpdate JS, this is used to receive updates and apply them. add_script("nano_base_helpers.js") // The NanoBaseHelpers JS, this is used to set up template helpers which are common to all templates add_stylesheet("shared.css") // this CSS sheet is common to all UIs add_stylesheet("icons.css") // this CSS sheet is common to all UIs @@ -258,8 +258,12 @@ nanoui is used to open and update nano browser uis */ /datum/nanoui/proc/get_header() var/head_content = "" + + for (var/filename in scripts) + head_content += " " + for (var/filename in stylesheets) - head_content += "" + head_content += " " var/templatel_data[0] for (var/key in templates) @@ -292,7 +296,7 @@ nanoui is used to open and update nano browser uis } else { - alert('receiveUpdateData error: something is not defined!'); + alert('receiveUpdateData ERROR: something is not defined!'); if (typeof NanoUpdate == 'undefined') { alert('NanoUpdate not defined!'); @@ -308,7 +312,7 @@ nanoui is used to open and update nano browser uis
[title ? "
[title]
" : ""]
- +
Initiating...
"} /** @@ -317,13 +321,8 @@ nanoui is used to open and update nano browser uis * @return string HTML footer content */ /datum/nanoui/proc/get_footer() - var/scriptsContent = "" - - for (var/filename in scripts) - scriptsContent += "" return {" - [scriptsContent]
diff --git a/nano/js/nano_base_helpers.js b/nano/js/nano_base_helpers.js index 338be422562..ceb1c27047e 100644 --- a/nano/js/nano_base_helpers.js +++ b/nano/js/nano_base_helpers.js @@ -186,7 +186,7 @@ NanoBaseHelpers = function () return html; } }); - } + }; // generate a Byond href, combines _urlParameters with parameters var generateHref = function (parameters) @@ -217,7 +217,7 @@ NanoBaseHelpers = function () } } return queryString; - } + }; return { init: function () diff --git a/nano/js/nano_config.js b/nano/js/nano_config.js index 7766b64a4b5..8352b197ccf 100644 --- a/nano/js/nano_config.js +++ b/nano/js/nano_config.js @@ -4,7 +4,12 @@ var NanoConfig = function () return { init: function () { - + if (typeof jQuery == 'undefined') { + alert('ERROR: jQuery failed to load!'); + } + if (typeof $.views == 'undefined') { + alert('ERROR: JSRender failed to load!'); + } } } } (); @@ -32,7 +37,7 @@ if (!Array.prototype.indexOf) } return -1; }; -} +}; if (!String.prototype.format) { @@ -54,7 +59,7 @@ if (!String.prototype.format) }); }; String.prototype.format.regex = new RegExp("{-?[0-9]+}", "g"); -} +}; Object.size = function(obj) { var size = 0, key; @@ -70,7 +75,7 @@ if(!window.console) { return false; } }; -} +}; String.prototype.toTitleCase = function () { var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|vs?\.?|via)$/i; diff --git a/nano/js/nano_update.js b/nano/js/nano_update.js index 8cc65c9ee79..cb2eee021d7 100644 --- a/nano/js/nano_update.js +++ b/nano/js/nano_update.js @@ -23,6 +23,8 @@ NanoUpdate = function () // this function sets up the templates and base functionality var init = function () { + $('#uiNoJavaScript').html('Loading...'); + // this callback is triggered after new data is processed // it updates the status/visibility icon and adds click event handling to buttons/links NanoUpdate.addAfterUpdateCallback(function (updateData) { @@ -73,7 +75,7 @@ NanoUpdate = function () var templateData = body.data('templateData'); var initialData = body.data('initialData'); - if (!templateData || !initialData) + if (templateData == null || !initialData == null) { alert('Error: Initial data did not load correctly.'); } @@ -88,6 +90,11 @@ NanoUpdate = function () } } + if (!templateCount) + { + alert('ERROR: No templates listed!'); + } + // load markup for each template and register it for (var key in templateData) { @@ -121,15 +128,14 @@ NanoUpdate = function () renderTemplates(initialData); } _isInitialised = true; + $('#uiNoJavaScript').hide(); } executeCallbacks(_afterUpdateCallbacks, _data); - - //alert($("#mainTemplate").html()); } catch(error) { - alert('An error occurred while loading the UI: ' + error.message); + alert('ERROR: An error occurred while loading the UI: ' + error.message); return; } }); @@ -165,15 +171,29 @@ NanoUpdate = function () { _earlyUpdateData = updateData; // all templates have not been registered. We set _earlyUpdateData which will be applied after the template is loaded with the initial data } - } + }; // This function renders the template with the latest data // It has to be done recursively as each piece of data is observed individually and needs to be updated individually var renderTemplates = function (data) { - _data = data; - $("#mainTemplate").html(_templates["main"].render(_data)); - } + if (!_templates.hasOwnProperty("main")) + { + alert('Error: Main template not found.'); + } + + _data = data; + + try + { + $("#mainTemplate").html(_templates["main"].render(_data)); + } + catch(error) + { + alert('ERROR: An error occurred while rendering the UI: ' + error.message); + return; + } + }; // Execute all callbacks in the callbacks array/object provided, updateData is passed to them for processing var executeCallbacks = function (callbacks, updateData) @@ -184,7 +204,7 @@ NanoUpdate = function () } return updateData; - } + }; return { init: function ()