forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructor.js
More file actions
103 lines (79 loc) · 1.87 KB
/
constructor.js
File metadata and controls
103 lines (79 loc) · 1.87 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
const Editor = require('../editor');
const TracerManager = require('../tracer_manager');
const DOM = require('../dom/setup');
const {
showLoadingSlider,
hideLoadingSlider
} = require('../dom/loading_slider');
const Cache = require('./cache');
const state = {
isLoading: null,
editor: null,
tracerManager: null,
categories: null,
loadedScratch: null,
wikiList: null
};
const initState = (tracerManager) => {
state.isLoading = false;
state.editor = new Editor(tracerManager);
state.tracerManager = tracerManager;
state.categories = {};
state.loadedScratch = null;
state.wikiList = [];
};
/**
* Global application singleton.
*/
const App = function () {
this.getIsLoading = () => {
return state.isLoading;
};
this.setIsLoading = (loading) => {
state.isLoading = loading;
if (loading) {
showLoadingSlider();
} else {
hideLoadingSlider();
}
};
this.getEditor = () => {
return state.editor;
};
this.getCategories = () => {
return state.categories;
};
this.getCategory = (name) => {
return state.categories[name];
};
this.setCategories = (categories) => {
state.categories = categories;
};
this.updateCategory = (name, updates) => {
$.extend(state.categories[name], updates);
};
this.getTracerManager = () => {
return state.tracerManager;
};
this.getLoadedScratch = () => {
return state.loadedScratch;
};
this.setLoadedScratch = (loadedScratch) => {
state.loadedScratch = loadedScratch;
};
this.getWikiList = () => {
return state.wikiList;
};
this.setWikiList = (wikiList) => {
state.wikiList = wikiList;
};
this.hasWiki = (wiki) => {
return ~state.wikiList.indexOf(wiki);
};
const tracerManager = TracerManager.init();
initState(tracerManager);
DOM.setup(tracerManager);
};
App.prototype = Cache;
module.exports = App;