compiling JS as well now

v1.18.x
psychobunny 10 years ago
parent 55c969ab23
commit 1f2bd9390d

@ -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;

@ -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('');
}
}
});

@ -54,13 +54,13 @@
<input type="text" class="form-control" name="username" placeholder="Username" />
</div>
<div class="col-sm-4 help-text">
Here is some sample help text. Username should be between <strong>6</strong> and <strong>12</strong> characters long.
</div>
</div>
<div class="row input-row">
<div class="col-sm-8 col-xs-12 input-field">
<label for="username">Username</label>
<input type="text" class="form-control" name="username" placeholder="Username" />
<label for="password">Password</label>
<input type="password" class="form-control" name="password" placeholder="Username" />
</div>
<div class="col-sm-4 help-text">
Here is some sample help text. Username should be between <strong>6</strong> and <strong>12</strong> characters long.
@ -71,6 +71,6 @@
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="src/installer/install.js"></script>
<script type="text/javascript" src="nodebb.min.js"></script>
</body>
</html>
Loading…
Cancel
Save