forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (45 loc) · 1.28 KB
/
Copy pathindex.js
File metadata and controls
58 lines (45 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
const RSVP = require('rsvp');
const appInstance = require('./app');
const AppConstructor = require('./app/constructor');
const DOM = require('./dom');
const Server = require('./server');
const Helpers = require('./server/helpers');
const modules = require('./module');
const {
extend
} = $;
$.ajaxSetup({
cache: false,
dataType: 'text'
});
// set global promise error handler
RSVP.on('error', function(reason) {
console.assert(false, reason);
});
$(() => {
// initialize the application and attach in to the instance module
const app = new AppConstructor();
extend(true, appInstance, app);
// load modules to the global scope so they can be evaled
extend(true, window, modules);
Server.loadCategories().then((data) => {
appInstance.setCategories(data);
DOM.showCategories();
// determine if the app is loading a pre-existing scratch-pad
// or the home page
const gistID = Helpers.getParameterByName('scratch-paper');
if (gistID) {
Server.loadScratchPaper(gistID).then(({
category,
algorithm,
data
}) => {
DOM.showAlgorithm(category, algorithm, data);
});
} else {
DOM.showFirstAlgorithm();
}
});
// http://localhost:8080/?scratch-paper=dcf0d0de60a4ad335b3b0cb5c39035e7
});