-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
195 lines (171 loc) · 4.92 KB
/
index.html
File metadata and controls
195 lines (171 loc) · 4.92 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<html lang="en">
<head>
<title>Fırat Payalan</title>
<style>
body {
color: white;
}
body, #input {
background: black;
font-size: 150%;
font-family: monospace;
line-height: 120%;
}
#output {
min-height: 85%;
white-space: pre;
}
#input {
width: 100%;
height: 8%;
border: none;
color: lime;
}
#input:focus {
outline: none;
}
.error {
color: red;
}
/* The navigation bar */
.navbar {
overflow: hidden;
background-color: #333;
position: fixed; /* Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%; /* Full width */
}
/* Links inside the navbar */
.navbar a {
float: left;
display: block;
color: #ffffff;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Main content */
.main {
/*margin-top: 30px; /* Add a top margin to avoid content overlay */
/*background-color: purple;*/
}
.main a{
text-decoration: none;
color: white;
}
</style>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147066333-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-147066333-1');
</script>
</head>
<body>
<div class="main">
<p><a target="_blank" href="https://www.linkedin.com/in/f%C4%B1rat-payalan-46aa766a/">linkedin</a>
| <a target="_blank" href="https://github.com/yasinfp">github</a>
| <a target="_blank" href="https://stackoverflow.com/users/2552886/yfpayalan">stackoverflow</a>
| <a target="_blank" href="https://medium.com/@yfpayalan">medium</a>
| <a target="_blank" href="https://www.hackerrank.com/yfpayalan1">hackerrank</a>
| <a target="_blank" href="https://ringzer0team.com/profile/17656/euphratesy">ringzer0team</a>
</p>
</div>
<div id="output"></div>
<div>
<input id="input" type="text" autofocus />
</div>
<!-- thanks to https://github.com/trybash/bash-emulator -->
<script src="js/bash-emulator.min.js"></script>
<script>
var input = document.getElementById('input')
var output = document.getElementById('output')
var emulator = bashEmulator({
workingDirectory: '/',
fileSystem: {
'/': {
type: 'dir',
modified: Date.now()
},
'/README.txt': {
type: 'file',
modified: Date.now(),
content: 'empty'
},
'/home': {
type: 'dir',
modified: Date.now()
},
'/home/user/journal.txt': {
type: 'file',
modified: Date.now(),
content: 'this is private!'
},
'/home/user': {
type: 'dir',
modified: Date.now()
}
}
})
var ENTER = 13
var UP = 38
var DOWN = 40
function log (result) {
output.innerHTML += (result || '') + '\n'
}
function error (result) {
log('<div class="error">' + result + '</div>')
}
function run (cmd) {
log('$ ' + cmd)
return emulator.run(cmd).then(log, error)
}
var completeFunctions = {}
completeFunctions[UP] = emulator.completeUp
completeFunctions[DOWN] = emulator.completeDown
function complete (direction) {
var completeFunction = completeFunctions[direction]
if (!completeFunction) {
return
}
var cursorPosition = input.selectionStart
var beforeCursor = input.value.slice(0, cursorPosition)
completeFunction(beforeCursor).then(function (completion) {
if (completion) {
input.value = completion
input.setSelectionRange(cursorPosition, cursorPosition)
}
})
}
input.addEventListener('keydown', function (e) {
if (e.altKey || e.metaKey || e.shiftKey || e.ctrlKey) {
return
}
if (e.which === UP || e.which === DOWN) {
e.preventDefault()
complete(e.which)
}
})
input.addEventListener('keyup', function (e) {
if (e.which !== ENTER) {
return
}
if (!input.value.length) {
return
}
run(input.value).then(function () {
input.value = ''
document.body.scrollTop = 10e6
})
})
document.body.addEventListener('click', function () {
input.focus()
})
run('pwd').then(function () {
run('ls')
})
</script>
<body>
<html>