-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html.template
202 lines (184 loc) · 6.97 KB
/
index.html.template
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
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Telephonicah</title>
<style>
body {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
font-family: Arial, sans-serif;
}
header {
text-align: center;
}
input[type="text"], select {
margin-bottom: 5px;
}
.row {
display: flex;
justify-content: space-around;
padding: 1rem;
box-sizing: border-box;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 0.5rem;
}
textarea {
width: 100%;
height: 200px;
}
.delete-icon {
display: inline-block;
width: 18px;
height: 18px;
position: relative;
text-decoration: none;
}
.delete-icon:before,
.delete-icon:after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 2px;
background-color: red;
top: 50%;
left: 0;
}
.delete-icon:before {
transform: rotate(45deg);
}
.delete-icon:after {
transform: rotate(-45deg);
}
</style>
</head>
<body>
<header>
<h1>Telephonicah - Admin area</h1>
</header>
<div class="row">
<div>
<h2>Team</h2>
<form method="post" action="/update?allowed=1" id="allowed-callers-form">
<ul id="allowed-callers">
{allowed_callers}
</ul>
<button id="save-list-btn" type="submit" style="display: none">Save</button>
</form>
<h2>Add member</h2>
<form id="add-caller-form">
<input required type="text" id="name" name="name" placeholder="Nume">
<br>
<input required type="text" id="phone" name="phone" placeholder="Telefon">
<br>
<button type="submit">Add</button>
</form>
<h2>Change admin number</h2>
<form id="change-owner-form" method="post" action="/update?owner=1">
<input type="hidden" id="current-owner" value="{current_owner}">
<select name="owner" id="owner">
</select>
<br>
<button type="submit">Save</button>
</form>
<h2>Change designated call number</h2>
<form method="post" action="/update?gate=1">
<input type="text" name="gate" value="{gate}">
<br>
<button type="submit">Save</button>
</form>
<h2>Change toggle pin duration (ms)</h2>
<form method="post" action="/update?enable-pin-toggle-duration=1">
<input type="text" name="ep-toggle-duration" value="{ep-toggle-duration}">
<br>
<button type="submit">Save</button>
</form>
</div>
<div style="width: 60%">
<h2>Logs</h2>
<textarea id="logs">
{logs}
</textarea>
<form method="post" action="/update?check:credit=1">
<button type="submit">Check prepay credit</button>
</form>
<form method="post" action="/update?download:logs=1">
<button type="submit" name="download-logs">Download fail log</button>
</form>
<form method="post" action="/update?debug:mode=1">
<button type="submit" name="submit">Enter debug mode</button>
</form>
<form method="post" action="/update?deleteallsms=1">
<button type="submit" name="submit">Delete all SMS</button>
</form>
<form method="post" action="/update?reset=1">
<button type="submit" name="submit">Reset device</button>
</form>
<p>Debug mode: {debug_mode}</p>
<form method="post" action="/update?sendat=1">
<textarea name="atcommand"></textarea>
<button type="submit" name="submit">Send AT command</button>
</form>
</div>
</div>
<script>
document.getElementById('add-caller-form').addEventListener('submit', (e) => {
e.preventDefault();
const nameInput = document.getElementById('name');
const name = nameInput.value.trim();
const phoneInput = document.getElementById('phone');
const phone = phoneInput.value.trim();
if (name && phone) {
const newItem = document.createElement('li');
newItem.id = phone;
newItem.innerHTML = `${phone} - ${name} <input type="hidden" name="name[]" value="${name}"><input type="hidden" name="phone[]" value="${phone}"> <a href="#" rel="${phone}" class="delete-icon" title="Șterge"></a>`;
document.getElementById('allowed-callers').appendChild(newItem);
nameInput.value = '';
phoneInput.value = '';
document.getElementById('save-list-btn').style.display = 'block';
}
});
document.getElementById('allowed-callers-form').addEventListener('click', (e) =>{
const target = e.srcElement;
let deleteIconClicked = false;
for (const c of target.classList) {
if (c == 'delete-icon') {
deleteIconClicked = true;
break;
}
}
if (!deleteIconClicked) {
return;
}
e.preventDefault();
const targetId = target.getAttribute('rel');
document.getElementById(targetId).remove();
document.getElementById('save-list-btn').style.display = 'block';
})
const allowedCallersList = document.getElementById('allowed-callers');
const ownerSelectEl = document.getElementById('owner');
const currentOwner = document.getElementById('current-owner').value;
for (const child of allowedCallersList.children) {
const phone = child.getAttribute('id');
const option = document.createElement('option');
option.value = phone;
option.textContent = child.textContent;
if (currentOwner === phone) {
option.setAttribute('selected', true);
}
ownerSelectEl.appendChild(option);
}
const textarea = document.getElementById('logs');
textarea.scrollTop = textarea.scrollHeight;
</script>
</body>
</html>