| @@ -2,6 +2,7 @@ var fs = require("fs"); | |||
| var zlib = require("zlib"); | |||
| var browserPrefix = require("browser-prefix"); | |||
| var log = require("mlogger"); | |||
| var jshint = require("jshint").JSHINT; | |||
| var minify = require("./minify.js"); | |||
| var includeHtml = require("./includeHtml.js"); | |||
| @@ -41,8 +42,21 @@ exports.load = function(endpoints, conf) { | |||
| ep.mimeType = "text/html"; | |||
| if (conf.minify) ep.str = minify.html(ep.str); | |||
| } else if (/\.js$/.test(ep.path)) { | |||
| jshint.errors = []; | |||
| jshint(ep.str); | |||
| jshint.errors.forEach(function(err) { | |||
| if (!err) | |||
| return; | |||
| log.warn( | |||
| conf.dir.web+"/"+ep.path+": "+ | |||
| "Line "+err.line+": "+ | |||
| err.reason | |||
| ); | |||
| }); | |||
| ep.mimeType = "application/javascript"; | |||
| if (conf.minify) ep.str = minify.js(ep.str); | |||
| if (conf.minify && !jshint.errors) ep.str = minify.js(ep.str); | |||
| } | |||
| return ep; | |||
| @@ -54,6 +68,7 @@ exports.load = function(endpoints, conf) { | |||
| log.error("File not found: "+conf.dir.web+"/"+ep.path); | |||
| errs = true; | |||
| } else { | |||
| log.warn(conf.dir.web+"/"+ep.path); | |||
| throw err; | |||
| } | |||
| } | |||
| @@ -19,6 +19,7 @@ | |||
| "browser-prefix": "^0.1.0", | |||
| "formidable": "^1.0.17", | |||
| "html-minifier": "^0.7.2", | |||
| "jshint": "^2.8.0", | |||
| "mlogger": "^1.1.0", | |||
| "pg": "^4.4.0", | |||
| "scrypt": "^4.0.7", | |||
| @@ -12,7 +12,7 @@ | |||
| "October", | |||
| "November", | |||
| "December" | |||
| ] | |||
| ]; | |||
| window.util = {}; | |||
| @@ -26,7 +26,7 @@ | |||
| notify.timeout = setTimeout(function() { | |||
| elem.removeClass("active"); | |||
| }, 5000); | |||
| } | |||
| }; | |||
| $(document).ready(function() { | |||
| $("#notify-box").on("mouseenter", function() { | |||
| clearTimeout(util.notify.timeout); | |||
| @@ -35,14 +35,14 @@ | |||
| util.error = function(body) { | |||
| util.notify("Error: "+body); | |||
| } | |||
| }; | |||
| util.htmlEntities = function(str) { | |||
| return str.replace(/&/g, "&") | |||
| .replace(/</g, "<") | |||
| .replace(/>/g, ">") | |||
| .replace(/"/g, """); | |||
| } | |||
| }; | |||
| util.api = function(name, data, cb, getXhr) { | |||
| var fd = new FormData(); | |||
| @@ -76,7 +76,7 @@ | |||
| else | |||
| cb(res.error); | |||
| }); | |||
| } | |||
| }; | |||
| util.async = function(n, cb) { | |||
| if (typeof n !== "number") | |||
| @@ -95,8 +95,8 @@ | |||
| cb(res); | |||
| else | |||
| n -= 1; | |||
| } | |||
| } | |||
| }; | |||
| }; | |||
| util.pad = function(str, length, padChar) { | |||
| var missing = (length - str.length) + 1; | |||
| @@ -105,7 +105,7 @@ | |||
| return str; | |||
| return new Array(missing).join(padChar) + str; | |||
| } | |||
| }; | |||
| util.dateToString = function(date) { | |||
| var day = util.pad(date.getDate().toString(), 2, "0"); | |||
| @@ -115,18 +115,18 @@ | |||
| date.getFullYear()+", "+ | |||
| util.pad(date.getHours().toString(), 2, "0")+":"+ | |||
| util.pad(date.getMinutes().toString(), 2, "0"); | |||
| } | |||
| }; | |||
| util.prevent = function(evt) { | |||
| evt.preventDefault(); | |||
| evt.stopPropagation(); | |||
| } | |||
| }; | |||
| util.redirect = function(url, timeout) { | |||
| setTimeout(function() { | |||
| location.href = url; | |||
| }, timeout || 1000); | |||
| } | |||
| }; | |||
| window.display = {}; | |||
| @@ -139,7 +139,7 @@ | |||
| util.notify("Logged In", "You are now logged in."); | |||
| }); | |||
| } | |||
| }; | |||
| display.logIn = function() { | |||
| util.api("template?navbar-login", {}, function(err, res) { | |||
| @@ -150,7 +150,7 @@ | |||
| util.notify("Logged Out", "You are now logged out."); | |||
| }); | |||
| } | |||
| }; | |||
| $(document).ready(function() { | |||
| $("#login-form").on("submit", function(evt) { | |||
| @@ -11,7 +11,7 @@ $(document).on("ready", function() { | |||
| '<div class="progress-bar"></div>'+ | |||
| '<button class="btn btn-default delete" onclick="uploaderDelete(this.parentNode)">X</button>'+ | |||
| '<img class="thumbnail" src="'+f.thumbnail+'">'+ | |||
| '<span class="name">'+util.htmlEntities(f.name)+'</span>'+ | |||
| '<input class="name" value="'+util.htmlEntities(f.name)+'">'+ | |||
| '</li>' | |||
| ); | |||
| }); | |||
| @@ -28,7 +28,7 @@ $(document).on("ready", function() { | |||
| var inputFiles = evt.target.files; | |||
| for (var i = 0; i < inputFiles.length; ++i) (function() { | |||
| function createThumbnail(i) { | |||
| var f = inputFiles[i]; | |||
| f.thumbnail = ""; | |||
| @@ -38,10 +38,14 @@ $(document).on("ready", function() { | |||
| reader.onload = function(evt) { | |||
| f.thumbnail = reader.result; | |||
| draw(files); | |||
| } | |||
| }; | |||
| files.push(inputFiles[i]); | |||
| })(); | |||
| } | |||
| for (var i = 0; i < inputFiles.length; ++i) { | |||
| createThumbnail(i); | |||
| } | |||
| draw(files); | |||
| }); | |||
| @@ -50,7 +54,7 @@ $(document).on("ready", function() { | |||
| var index = elem.getAttribute("data-index"); | |||
| delete files[index]; | |||
| draw(files); | |||
| } | |||
| }; | |||
| //Upload things when the upload button is clicked | |||
| $("#uploader-upload").on("click", function(evt) { | |||