diff --git a/install/web.js b/install/web.js index 351f512868..c462c24e6a 100644 --- a/install/web.js +++ b/install/web.js @@ -5,15 +5,26 @@ var winston = require('winston'), fs = require('fs'), path = require('path'), less = require('less'), + async = require('async'), + uglify = require('uglify-js'), app = express(); -var web = {}; +var web = {}, + scripts = [ + 'public/vendor/jquery/js/jquery.js', + 'public/vendor/bootstrap/js/bootstrap.min.js', + 'public/vendor/bootbox/bootbox.min.js', + 'public/vendor/xregexp/xregexp.js', + 'public/vendor/xregexp/unicode/unicode-base.js', + 'public/src/utils.js', + 'public/src/installer/install.js' + ]; web.install = function(port) { port = port || 8080; winston.info('Launching web installer on port ', port); - compileLess(function() { + async.parallel([compileLess, compileJS], function() { setupRoutes(); launchExpress(port); }); @@ -52,4 +63,14 @@ function compileLess(callback) { }); } +function compileJS(callback) { + var scriptPath = path.join(__dirname, '..'), + result = uglify.minify(scripts.map(function(script) { + return path.join(scriptPath, script); + })); + + + fs.writeFile(path.join(__dirname, '../public/nodebb.min.js'), result.code, callback); +} + module.exports = web; \ No newline at end of file diff --git a/public/src/installer/install.js b/public/src/installer/install.js index 48464808ff..fe86a5642e 100644 --- a/public/src/installer/install.js +++ b/public/src/installer/install.js @@ -1,4 +1,5 @@ "use strict"; +/*global utils*/ $('document').ready(function() { setupInputs(); @@ -10,5 +11,20 @@ $('document').ready(function() { $('.input-row.active').removeClass('active'); $(this).parents('.input-row').addClass('active'); }); + + $('[name="username"]').on('blur', validateUsername); + } + + + function validateUsername() { + var $this = $(this), + username = $this.val(), + help = $this.parents('.input-row').children('.help-text'); + + if (!utils.isUserNameValid(username) || !utils.slugify(username)) { + help.html('Invalid Username.'); + } else { + help.html(''); + } } }); \ No newline at end of file diff --git a/src/views/install/index.tpl b/src/views/install/index.tpl index 29b45dd0de..8d10af37d7 100644 --- a/src/views/install/index.tpl +++ b/src/views/install/index.tpl @@ -54,13 +54,13 @@