-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (55 loc) · 1.75 KB
/
index.js
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
var hBox = require('fbox').HBox;
var vBox = require('fbox').VBox;
var splitView = require('splitview').SplitView;
var Cell = require('fboxcell').Cell;
var ConnectionHandler = require('connectionhandler');
var SandboxController = require('sandboxcontroller').SandboxController;
var extHtmlJs = require('exthtmljs');
var extMarkdown = require('extmarkdown');
var JSSandbox = (function() {
var appbox
, header
, connectionStatus
, ch = new ConnectionHandler('ws://localhost:1515');
return {
init : function() {
this.scaffoldUI();
SandboxController.setConnectionHandler(ch);
SandboxController.init(appbox);
this.setupWindowListeners();
this.resizeApp();
ch.connect();
// Some global status indicators?
ch.on("connected", function() {
document.getElementById("connection_status").classList.remove("disconnected");
});
ch.on("disconnected", function() {
document.getElementById("connection_status").classList.add("disconnected");
});
},
setupWindowListeners : function() {
var that = this;
window.addEventListener("resize", function() {
that.resizeApp();
});
},
resizeApp : function() {
appbox.resize(window.innerWidth, window.innerHeight);
},
scaffoldUI : function() {
appbox = new vBox();
var header = new hBox();
header.el.setAttribute("id", "app-header");
var logoCell = new Cell(
['<div id="header-logo">',
'<img src="assets/images/logo_name.png" width="113" />',
'</div>'].join(''));
header.add(logoCell, -1);
connectionStatus = new Cell('<div id="connection_status" class="disconnected"><i class="icon icon-circle-blank"></i></div>')
header.add(connectionStatus, 55);
appbox.add(header, 45);
document.body.appendChild(appbox.el);
}
}
})();
JSSandbox.init();