Skip to content
/ osd Public

Commit 9e5d880

Browse files
committed
Managing the time-related settings
1 parent 139e444 commit 9e5d880

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

res/index.html

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<title>OpenIPC</title>
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
55
<style>
6-
*{box-sizing:border-box}*+*{margin:.5em 0}pre{overflow:auto}.row,.w-100{width:100%}.vh-100{height:100vh}.card:focus,hr{outline:0;border:solid #fa0}.card,pre{padding:1em;border:solid #eee}
6+
*{box-sizing:border-box}*+*{margin:.5em 0}pre{overflow:auto}.row,.w-100{width:100%}.vh-100{height:100vh}.card:focus,hr{outline:0;border:solid #fa0}.card,pre{padding:1em;border:solid #eee}.right{float:right}
77
.tc{text-align:center}.c{padding:1em;margin:auto;font:1em/1.6 sans-serif}.cont{max-width:64em}.gapless{border-spacing:0}.vc{position:relative;top:40%;transform:perspective(1px) translateY(-45%)}
88
a{color:#fa0;text-decoration:none}.btn:hover,a:hover{opacity:.6}.btn.primary{color:#fff;background:#fa0;border:solid #fa0}.btn{padding:1em;text-transform:uppercase;background:#fff;border:solid;font:.7em sans-serif}
99
.inline,a.btn{display:inline-block}.nope{display:none}.pill{border-radius:9999px}.rounded{border-radius:4px}.scrollx{overflow-x:auto}.scrolly{overflow-y:auto}.caps{text-transform:uppercase}.tracked{letter-spacing:.1em}
10-
.box{vertical-align:top}.box input,select{width:100%}.box td{padding:.5em}.close{position:absolute;right:2em;top:2em}.lbl-modal:focus,.lbl-modal:hover{cursor:pointer;opacity:.6}.right{float:right}
10+
.btn.cell{display:table-cell;width:1%}.box{vertical-align:top}.box input,select{width:100%}.box td{padding:.5em}.close{position:absolute;right:2em;top:2em}.lbl-modal:focus,.lbl-modal:hover{cursor:pointer;opacity:.6}
1111
.modal{display:none;background:#fff;position:fixed;bottom:0;left:0;right:0;top:0;margin:0;padding:0;z-index:1}.hide{position:absolute;top:-3px;left:-3px;width:1px;height:1px}.unl{border-bottom:2px solid}
1212
input,select{font-family:sans-serif}input[type=checkbox]{position:absolute;opacity:0}input[type=checkbox]:checked+.modal{display:block;z-index:4}.menu .col{display:inline}.menu .btn{margin:-1em 0;padding:.75em}
1313
.dim{opacity:1;transition:opacity .15s ease-in}.dim:focus,.dim:hover{opacity:.5;transition:opacity .15s ease-in}h6{font:400 1em sans-serif}h5{font:400 1.2em sans-serif}h4{font:400 1.5em sans-serif}
@@ -122,11 +122,27 @@
122122
apiApply('osd/' + i);
123123
}
124124

125+
function setFormatTime() {
126+
var fmt = document.getElementById('time_fmt').value;
127+
apiRead('time');
128+
document.getElementById('time_fmt').value = fmt;
129+
apiApply('time');
130+
}
131+
132+
function setLocalTime() {
133+
var ts = Math.floor(new Date().getTime() / 1000);
134+
document.getElementById('time_ts').value = ts;
135+
apiApply('time');
136+
apiRead('time');
137+
}
138+
125139
function every5Sec() {
126140
apiRead('status');
127141
}
128142

129143
function onLoad() {
144+
apiRead('time');
145+
130146
duplicateRows('osd', 10);
131147
for (var i = 0; i < 10; i++)
132148
apiRead('osd/' + i);
@@ -191,10 +207,46 @@ <h2 class="unl">OSD</h2>
191207
</div>
192208
</div>
193209
</div>
210+
<input type="checkbox" id="system-modal">
211+
<div class="c modal vh-100 w-100 scrolly">
212+
<div class="c bg-black menu pv2 row" tabindex="0">
213+
<b><label for="system-modal" class="lbl-modal ph2 white">OpenIPC</label></b>
214+
<div class="col">
215+
<label for="system-modal" class="btn primary close">Close</label>
216+
</div>
217+
</div>
218+
<div class="c cont">
219+
<h2 class="unl">System</h2>
220+
<div class="row scrollx">
221+
<div class="12 col box">
222+
<fieldset>
223+
<legend>Time</legend>
224+
<table class="tc w-100">
225+
<tr>
226+
<td><label for="time_fmt">Display format</label></td>
227+
<td><input type="text" id="time_fmt"></td>
228+
<td><a href="javascript:setFormatTime()" class="btn cell">Set</a></td>
229+
</tr>
230+
<tr>
231+
<td><label for="time_ts">Current Unix time</label></td>
232+
<td><input type="text" id="time_ts"></td>
233+
<td>
234+
<a href="javascript:setLocalTime()" class="btn cell">Sync</a>
235+
<a href="javascript:apiApply('time')" class="btn cell">Apply</a>
236+
</td>
237+
</tr>
238+
</table>
239+
<a href="javascript:apiRead('time')" class="btn right">Refresh</a>
240+
</fieldset>
241+
</div>
242+
</div>
243+
</div>
244+
</div>
194245
<div class="c bg-black menu pv2 row" tabindex="0">
195246
<b><a href="./" class="ph2 white">OpenIPC</a></b>
196247
<div class="col">
197248
<label for="osd-modal" class="lbl-modal ph2 white">OSD</label>
249+
<label for="system-modal" class="lbl-modal ph2 white">System</label>
198250
</div>
199251
</div>
200252
<div class="c cont">

src/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void respond_request(struct Request *req) {
537537
"Content-Type: application/json;charset=UTF-8\r\n"
538538
"Connection: close\r\n"
539539
"\r\n"
540-
"{\"fmt\":\"%s\",\"ts\":%d}", timefmt, t.tv_sec);
540+
"{\"fmt\":\"%s\",\"ts\":%zu}", timefmt, t.tv_sec);
541541
send_and_close(req->clntFd, response, respLen);
542542
return;
543543
}

0 commit comments

Comments
 (0)