From dcefcd19cba4d30b21bdce88d811d24908dffee7 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 18 Mar 2017 11:21:18 +0200 Subject: [PATCH] Use require() instead of import in client code Closes #895 --- client/.eslintrc.yml | 3 --- client/js/libs/handlebars/colorClass.js | 2 ++ client/js/libs/handlebars/diff.js | 2 ++ client/js/libs/handlebars/equal.js | 2 ++ client/js/libs/handlebars/localedate.js | 2 ++ client/js/libs/handlebars/localetime.js | 2 ++ client/js/libs/handlebars/modes.js | 2 ++ client/js/libs/handlebars/parse.js | 6 +++-- client/js/libs/handlebars/roundBadgeNumber.js | 2 ++ client/js/libs/handlebars/tojson.js | 2 ++ client/js/libs/handlebars/tz.js | 2 ++ client/js/libs/handlebars/users.js | 2 ++ client/js/libs/slideout.js | 6 +++-- client/js/lounge.js | 26 ++++++++++--------- client/views/index.js | 2 ++ 15 files changed, 44 insertions(+), 19 deletions(-) delete mode 100644 client/.eslintrc.yml diff --git a/client/.eslintrc.yml b/client/.eslintrc.yml deleted file mode 100644 index cb4e55ff..00000000 --- a/client/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -parserOptions: - sourceType: module diff --git a/client/js/libs/handlebars/colorClass.js b/client/js/libs/handlebars/colorClass.js index 53bfc0d4..e7b8d8e4 100644 --- a/client/js/libs/handlebars/colorClass.js +++ b/client/js/libs/handlebars/colorClass.js @@ -1,3 +1,5 @@ +"use strict"; + // Generates a string from "color-1" to "color-32" based on an input string module.exports = function(str) { var hash = 0; diff --git a/client/js/libs/handlebars/diff.js b/client/js/libs/handlebars/diff.js index 3b2116bd..198c8882 100644 --- a/client/js/libs/handlebars/diff.js +++ b/client/js/libs/handlebars/diff.js @@ -1,3 +1,5 @@ +"use strict"; + var diff; module.exports = function(a, opt) { diff --git a/client/js/libs/handlebars/equal.js b/client/js/libs/handlebars/equal.js index 1d7a4393..6a8033ca 100644 --- a/client/js/libs/handlebars/equal.js +++ b/client/js/libs/handlebars/equal.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(a, b, opt) { a = a.toString(); b = b.toString(); diff --git a/client/js/libs/handlebars/localedate.js b/client/js/libs/handlebars/localedate.js index 0f85a5f2..9c800ab0 100644 --- a/client/js/libs/handlebars/localedate.js +++ b/client/js/libs/handlebars/localedate.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(time) { return new Date(time).toLocaleDateString(); }; diff --git a/client/js/libs/handlebars/localetime.js b/client/js/libs/handlebars/localetime.js index 5318a022..59e1dbf8 100644 --- a/client/js/libs/handlebars/localetime.js +++ b/client/js/libs/handlebars/localetime.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(time) { return new Date(time).toLocaleString(); }; diff --git a/client/js/libs/handlebars/modes.js b/client/js/libs/handlebars/modes.js index 6416515f..ff3d555e 100644 --- a/client/js/libs/handlebars/modes.js +++ b/client/js/libs/handlebars/modes.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(mode) { var modes = { "~": "owner", diff --git a/client/js/libs/handlebars/parse.js b/client/js/libs/handlebars/parse.js index cd61ff7e..9d276f49 100644 --- a/client/js/libs/handlebars/parse.js +++ b/client/js/libs/handlebars/parse.js @@ -1,5 +1,7 @@ -import Handlebars from "handlebars/runtime"; -import URI from "urijs"; +"use strict"; + +const Handlebars = require("handlebars/runtime"); +const URI = require("urijs"); module.exports = function(text) { text = Handlebars.Utils.escapeExpression(text); diff --git a/client/js/libs/handlebars/roundBadgeNumber.js b/client/js/libs/handlebars/roundBadgeNumber.js index a7750de0..97c50afa 100644 --- a/client/js/libs/handlebars/roundBadgeNumber.js +++ b/client/js/libs/handlebars/roundBadgeNumber.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(count) { if (count < 1000) { return count; diff --git a/client/js/libs/handlebars/tojson.js b/client/js/libs/handlebars/tojson.js index fcd0fde1..418ac8c4 100644 --- a/client/js/libs/handlebars/tojson.js +++ b/client/js/libs/handlebars/tojson.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(context) { return window.JSON.stringify(context); }; diff --git a/client/js/libs/handlebars/tz.js b/client/js/libs/handlebars/tz.js index 14f05e5e..e62bf285 100644 --- a/client/js/libs/handlebars/tz.js +++ b/client/js/libs/handlebars/tz.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(time) { time = new Date(time); var h = time.getHours(); diff --git a/client/js/libs/handlebars/users.js b/client/js/libs/handlebars/users.js index e52e7526..d962423c 100644 --- a/client/js/libs/handlebars/users.js +++ b/client/js/libs/handlebars/users.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(count) { return count + " " + (count === 1 ? "user" : "users"); }; diff --git a/client/js/libs/slideout.js b/client/js/libs/slideout.js index 522cc448..34faa9a8 100644 --- a/client/js/libs/slideout.js +++ b/client/js/libs/slideout.js @@ -1,7 +1,9 @@ +"use strict"; + /** * Simple slideout menu implementation. */ -export default function slideoutMenu(viewport, menu) { +module.exports = function slideoutMenu(viewport, menu) { var touchStartPos = null; var touchCurPos = null; var touchStartTime = 0; @@ -98,4 +100,4 @@ export default function slideoutMenu(viewport, menu) { return menuIsOpen; } }; -} +}; diff --git a/client/js/lounge.js b/client/js/lounge.js index 81275fbd..c26f653b 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -1,18 +1,20 @@ +"use strict"; + // vendor libraries -import "jquery-ui/ui/widgets/sortable"; -import $ from "jquery"; -import io from "socket.io-client"; -import Mousetrap from "mousetrap"; -import URI from "urijs"; +require("jquery-ui/ui/widgets/sortable"); +const $ = require("jquery"); +const io = require("socket.io-client"); +const Mousetrap = require("mousetrap"); +const URI = require("urijs"); // our libraries -import "./libs/jquery/inputhistory"; -import "./libs/jquery/stickyscroll"; -import "./libs/jquery/tabcomplete"; -import helpers_parse from "./libs/handlebars/parse"; -import helpers_roundBadgeNumber from "./libs/handlebars/roundBadgeNumber"; -import slideoutMenu from "./libs/slideout"; -import templates from "../views"; +require("./libs/jquery/inputhistory"); +require("./libs/jquery/stickyscroll"); +require("./libs/jquery/tabcomplete"); +const helpers_parse = require("./libs/handlebars/parse"); +const helpers_roundBadgeNumber = require("./libs/handlebars/roundBadgeNumber"); +const slideoutMenu = require("./libs/slideout"); +const templates = require("../views"); $(function() { var path = window.location.pathname + "socket.io/"; diff --git a/client/views/index.js b/client/views/index.js index 2890dea9..0b92ab8e 100644 --- a/client/views/index.js +++ b/client/views/index.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = { actions: { action: require("./actions/action.tpl"),