-
Notifications
You must be signed in to change notification settings - Fork 2
/
terminal.html
106 lines (92 loc) · 2.99 KB
/
terminal.html
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
104
105
106
<!DOCTYPE html>
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Eric Bidelman (ericbidelman@chromium.org)
-->
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>HTML5 Terminal</title>
<link rel="stylesheet" media="all" href="terminal.css">
<link rel="chrome-application-definition" href="manifest.json">
</head>
<body>
<aside class="help hidden">
<section>
<div>
<span onclick="toggleHelp()" id="close">x</span>
<h2>Keyboard shortcuts</h2>
<div class="shortcuts">
<p><strong><ctrl> + s</strong> : Toggle CRT monitor flicker effect</p>
<p><strong><esc></strong> : toggle this help menu</p>
</div>
</div>
<div>
<h2>What is this?</h2>
<p>A Command-line terminal/shell running on top of HTML5 APIs.</p>
<p>By: Eric Bidelman <ericbidelman@chromium.org></p>
</div>
</section>
</aside>
<!--<div class="crt top"></div>-->
<div class="interlace"></div>
<div id="container"></div>
<!--<div class="crt bottom"></div>-->
<script src="webinos.js"></script>
<script src="terminal.js"></script>
<script>
function toggleHelp() {
document.querySelector('.help').classList.toggle('hidden');
document.body.classList.toggle('dim');
}
(function() {
var term = new Terminal('container');
term.initFS(false, 1024 * 1024);
if (document.location.hash) {
var theme = document.location.hash.substring(1).split('=')[1];
term.setTheme(theme);
} else if (localStorage.theme) {
term.setTheme(localStorage.theme);
}
document.body.addEventListener('keydown', function(e) {
if (e.keyCode == 27) { // Esc
toggleHelp();
e.stopPropagation();
e.preventDefault();
}
}, false);
// Setup the DnD listeners for file drop.
document.body.addEventListener('dragenter', function(e) {
e.stopPropagation();
e.preventDefault();
this.classList.add('dropping');
}, false);
document.body.addEventListener('dragover', function(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}, false);
document.body.addEventListener('dragleave', function(e) {
this.classList.remove('dropping');
}, false);
document.body.addEventListener('drop', function(e) {
e.stopPropagation();
e.preventDefault();
this.classList.remove('dropping');
term.addDroppedFiles(e.dataTransfer.files);
term.output('<div>File(s) added!</div>');
}, false);
})();
</script>
</body>
</html>