From 5e3e1f878145c5749c35ee711166ef1fbd0a207c Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 14 Aug 2015 15:14:20 -0400 Subject: [PATCH] #3430 --- public/src/admin/admin.js | 5 ++--- public/src/ajaxify.js | 4 ++-- public/src/app.js | 2 +- public/src/modules/settings.js | 7 +------ public/src/modules/sounds.js | 8 ++++---- public/src/modules/translator.js | 4 +++- public/src/variables.js | 8 ++++---- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index bc6d81d747..22d5319708 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -74,7 +74,6 @@ }); Mousetrap.bind('ctrl+shift+a R', function() { - console.log('[admin] Restarting NodeBB...'); socket.emit('admin.restart'); }); @@ -196,9 +195,9 @@ if (checked) { checkbox.after(''); - } + } else { - checkbox.after(''); + checkbox.after(''); } checkbox.attr('data-toggle-added', true); diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 35c692c550..622bc0afde 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -253,8 +253,6 @@ $(document).ready(function() { }; function ajaxifyAnchors() { - templates.registerLoader(ajaxify.loadTemplate); - function hrefEmpty(href) { return href === undefined || href === '' || href === 'javascript:;'; } @@ -298,6 +296,8 @@ $(document).ready(function() { }); } + templates.registerLoader(ajaxify.loadTemplate); + if (window.history && window.history.pushState) { // Progressive Enhancement, ajaxify available only to modern browsers ajaxifyAnchors(); diff --git a/public/src/app.js b/public/src/app.js index 63e6e2399e..858200e02d 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -92,7 +92,7 @@ app.cacheBuster = null; switch(url_parts[0]) { case 'user': - room = 'user/' + ajaxify.data.theirid; + room = 'user/' + ajaxify.data ? ajaxify.data.theirid : 0; break; case 'topic': room = 'topic_' + url_parts[1]; diff --git a/public/src/modules/settings.js b/public/src/modules/settings.js index d541b35e84..0092f4ca46 100644 --- a/public/src/modules/settings.js +++ b/public/src/modules/settings.js @@ -294,7 +294,6 @@ define('settings', function () { message: "NodeBB failed to save the settings.", timeout: 5000 }); - console.log('[settings] Unable to set settings for hash: ', hash); } else { app.alert({ title: 'Settings Saved', @@ -387,7 +386,6 @@ define('settings', function () { hash: hash }, function (err, values) { if (err) { - console.log('[settings] Unable to load settings for hash: ', hash); if (typeof callback === 'function') { callback(err); } @@ -455,10 +453,9 @@ define('settings', function () { hash: hash }, function (err, values) { if (err) { - console.log('[settings] Unable to load settings for hash: ', hash); return callback(err); } - + // Parse all values. If they are json, return json for(var key in values) { if (values.hasOwnProperty(key)) { @@ -508,8 +505,6 @@ define('settings', function () { }); } }); - } else { - console.log('[settings] Form not found.'); } } }; diff --git a/public/src/modules/sounds.js b/public/src/modules/sounds.js index fa0eade2b5..3314500ce5 100644 --- a/public/src/modules/sounds.js +++ b/public/src/modules/sounds.js @@ -1,5 +1,5 @@ "use strict"; -/* global define, socket, config */ +/* global app, define, socket, config */ define('sounds', ['buzz'], function(buzz) { var Sounds = {}; @@ -17,7 +17,7 @@ define('sounds', ['buzz'], function(buzz) { function loadFiles() { socket.emit('modules.sounds.getSounds', function(err, sounds) { if (err) { - return console.log('[sounds] Could not initialise!'); + return app.alertError('[sounds] Could not initialise!'); } files = sounds; @@ -27,7 +27,7 @@ define('sounds', ['buzz'], function(buzz) { function loadMapping() { socket.emit('modules.sounds.getMapping', function(err, mapping) { if (err) { - return console.log('[sounds] Could not load sound mapping!'); + return app.alertError('[sounds] Could not load sound mapping!'); } eventSoundMapping = mapping; }); @@ -65,7 +65,7 @@ define('sounds', ['buzz'], function(buzz) { if (loadedSounds[fileName]) { loadedSounds[fileName].play(); } else { - console.log('[sounds] Not found:', fileName); + app.alertError('[sounds] Not found: ' + fileName); } } diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index 1b09a14119..46bb79e812 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -302,7 +302,9 @@ // Expose a global `translator` object for backwards compatibility window.translator = { translate: function() { - console.warn('[translator] Global invocation of the translator is now deprecated, please `require` the module instead.'); + if (typeof console !== 'undefined' && console.warn) { + console.warn('[translator] Global invocation of the translator is now deprecated, please `require` the module instead.'); + } _translator.translate.apply(_translator, arguments); } } diff --git a/public/src/variables.js b/public/src/variables.js index 16ad223073..c11b2d8c0d 100644 --- a/public/src/variables.js +++ b/public/src/variables.js @@ -7,14 +7,14 @@ ajaxify.variables = {}; ajaxify.variables.set = function(key, value) { - if (console && console.warn) { - console.warn('[deprecated] variables.set is deprecated, please use ajaxify.data, key=' + key); - } + if (typeof console !== 'undefined' && console.warn) { + console.warn('[deprecated] variables.set is deprecated, please use ajaxify.data, key=' + key); + } parsedVariables[key] = value; }; ajaxify.variables.get = function(key) { - if (console && console.warn) { + if (typeof console !== 'undefined' && console.warn) { console.warn('[deprecated] variables.get is deprecated, please use ajaxify.data, key=' + key); } return parsedVariables[key];