-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
131 lines (115 loc) · 3.58 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Media Center Angel</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';"/>
<style>
body {
color: #fff;
background-color: #3e4245ff
}
input {
margin: 15px;
border-radius: 3px;
border: none;
background-color: #252728ff;
color: #fff;
font-size: 1.5rem;
padding: 5px;
min-width: 100px;
flex: 100%;
}
.start-button {
background-color: #ce275fff;
border: none;
border-radius: 20px;
color: #fff;
width: 50%;
position: absolute;
bottom: 15px;
right: 15px;
font-size: 1.5rem;
}
.label {
margin: 15px 15px 0 15px;
font-size: 1.4rem;
}
.pus-button {
font-size: 2rem;
font-weight: bold;
color: #ce275fff;
cursor: pointer;
margin: 10px;
}
.minus-button {
color: #5a44cbff;
visibility: hidden;
}
#path-element {
display: flex;
flex-direction: row;
align-items: center;
margin-right: 15px;
}
.path-container > :last-child > .minus-button {
visibility: visible;
}
.path-container > :nth-child(2) > .minus-button {
visibility: hidden !important;
}
</style>
</head>
<body>
<div style="display: flex; flex-direction: column;">
<span class="label">Port</span>
<input type="text" id="port" value="3000"/>
<div id="path-container" class="path-container">
<span class="label">Paths</span>
<div id="path-element" name="path-element">
<input type="text" name="path"/>
<span class="pus-button" onclick="newPath()">+</span>
<span class="pus-button minus-button" onclick="delPath()">-</span>
</div>
</div>
<button onclick="startServer()" class="start-button" id="start-button">
start server
</button>
</div>
<script>
var serverRunning = false;
function newPath() {
var pathElement = document.getElementById('path-element');
var pathContainer = document.getElementById('path-container');
var pathElementClone = pathElement.cloneNode(true);
pathElementClone.children[0].value = '';
pathContainer.appendChild(pathElementClone);
}
function delPath() {
var paths = document.getElementsByName('path-element');
if (paths.length > 1) {
var element = paths[paths.length - 1];
element.parentNode.removeChild(element);
}
}
function startServer() {
var startButton = document.getElementById('start-button');
if (serverRunning) {
window.postMessage({type: 'stop-server'});
serverRunning = false;
startButton.innerText = 'start server';
} else {
serverRunning = true;
var port = document.getElementById('port');
var paths = document.getElementsByName('path');
var pathsValues = [];
for (var i = 0; i < paths.length; i++) {
pathsValues.push(paths[i].value);
}
window.postMessage({type: 'start-server', port: parseInt(port.value), paths: pathsValues});
startButton.innerText = 'stop server';
}
}
</script>
</body>
</html>