From c919c4bfef4ad9e2dc25d040c0727dd29ad541ae Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 20 Oct 2014 13:25:32 +0300 Subject: introduce require.js and rewrite tests Yes, I'm being lazy. The purpose of require.js is to allow writing modules, i.e. individual smaller then the whole files with clear dependencies. This is achieved by using a new api provided by require.js: define, require, requirejs Read more at [requirejs] (http://requirejs.org) Tests have been rewritten to work correctly with require.js; they still use jsdom. Test output is now stored in the repository, all tests are run via run_tests.js; This is a hack - once a good harness (with assertions, suites - unittest like) presents itself it will be used. Hidden here is also using FileSaver for history saving, so history is saved to history.json instead to a random name. Plus dropping some dead code. --- scripts/app.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/app.js (limited to 'scripts/app.js') diff --git a/scripts/app.js b/scripts/app.js new file mode 100644 index 00000000..2ad7d5c0 --- /dev/null +++ b/scripts/app.js @@ -0,0 +1,28 @@ +(function() { +var config = { + //urlArgs: "bust=" + (new Date()).getTime(), // NOTE: useful for debugging + paths: { + jquery: 'external/jquery', + 'jquery-ui': 'external/jquery-ui', + 'd3': 'external/d3/d3', + FileSaver: 'external/FileSaver', + caret: 'external/caret', + autocomplete: 'external/autocomplete', + } +} + +if (window.is_node) { + // Testing path only + console.log('app: running under node'); + config.baseUrl = '../scripts/'; + window.rhizi_require_config = config; +} else { + // Main app path + require.config(config); + + requirejs(['main'], function(main) { + console.log('starting rhizi logic'); + main.main(); + }); +} +}()); -- cgit v1.3.1