-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
199 lines (173 loc) · 4.82 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
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
<!DOCTYPE html>
<html>
<body>
<style>
body, html {
margin: 0;
padding: 0;
color: white;
background-color: #111111;
font-family: monospace;
}
div {
margin: 0;
padding: 0;
}
input {
border: none;
outline: none;
background-color: #111111;
color: inherit;
border-bottom: solid 2px #FFFFFFAA;
font-size: inherit;
font-family: inherit;
}
button {
font-size: inherit;
font-family: inherit;
box-sizing: border-box;
background-color: #0099ffAA;
border: none;
border-radius: 10%;
color: inherit;
}
button:hover { border-bottom: solid 2px #FFFFFFAA; }
#imgcon {
display: flex;
justify-content: center;
/*
height: 100vh;
box-sizing: border-box;
/*border: solid 5px #AA1111;*/
}
#img {
/*
width: 100%;
object-fit: contain;
*/
}
#directory_input {
width: 100%;
}
#topcon {
font-weight: bold;
font-size: 2.2rem;
opacity: 0;
background-color: inherit;
position: absolute;
margin: 1rem;
padding: 1rem;
top: 0;
right: 0;
border-radius: 1rem;
}
#topcon:hover { opacity: .8 }
#topconin {
}
#secs {
zoom: 100%;
position: absolute;
top: 0;
left: 0;
margin: 2rem;
padding: 1rem;
font-size: 7rem;
border-radius: 1rem;
background-color: #000000AA;
}
</style>
<div id='secs'>9999</div>
<div id=topcon>
<div id=topconin>
SEC:
<input id="secinput" placeholder="60 seconds" >
<button id=dirbtn onclick='change_length_button()'>click</button>
<br><br>
DIR:
<input id="dirinput" placeholder="D:\ART\REFERENCE 2D (and doujin)\ART PARENTS" >
<button id=dirbtn onclick="change_dir()">click</button>
</div>
</div>
<div id='imgcon'>
<img id='img' src='http://localhost:8123/randimg/823402380' />
</div>
<script>
var LENGTH = 60 * 1000
var CDOWN_TIMER = LENGTH;
var PAUSED = false;
function get_dtime() {
return new Date().getTime();
}
function change_dir() {
var dir = document.getElementById('dirinput').value;
//enc_dir = encodeURIComponent(dir);
enc_dir = dir.replaceAll('/', '_|_|_|_')
console.log(enc_dir)
fetch('http://localhost:8123/setdir/' + enc_dir)
.then(response => response.text() )
.then(text => { CDOWN_TIMER = 0; update(); } )
}
function KeyPress(e) {
var evtobj = window.event? event : e
console.log(evtobj.keyCode);
if (evtobj.keyCode == 37) { // left
var img = document.getElementById('img');
img.src = 'http://localhost:8123/previmg/' + get_dtime();
change_length(LENGTH);
}
if (evtobj.keyCode == 39) { // right
var img = document.getElementById('img');
img.src = 'http://localhost:8123/randimg/' + get_dtime();
change_length(LENGTH);
}
if (evtobj.keyCode == 83) { // save
fetch('http://localhost:8123/save')
.then(response => response.text() )
.then(text => { } )
}
if (evtobj.keyCode == 32 || evtobj.keyCode == 80) {
PAUSED = ! PAUSED;
if (PAUSED) { document.getElementById('secs').innerHTML = 'PAUSED' }
}
}
document.onkeydown = KeyPress;
function update_secs(val) { // expects ms and converts to seconds
var secs = document.getElementById('secs');
var ms = secs.value;
secs.innerHTML = parseInt(Math.ceil(val / 1000));
}
function change_length(new_len) {
LENGTH = parseInt(new_len);
CDOWN_TIMER = LENGTH;
update_secs(CDOWN_TIMER)
}
function change_length_button() {
var sec = document.getElementById('secinput').value;
sec *= 1000;
change_length(sec);
}
function update() {
// update timer
if (!PAUSED) {
CDOWN_TIMER -= 100;
// reset timer if needed
if (CDOWN_TIMER <= 0) {
var img = document.getElementById('img');
img.src = 'http://localhost:8123/randimg/' + get_dtime();
CDOWN_TIMER = LENGTH;
}
update_secs(CDOWN_TIMER);
}
}
var delta = 100;
var t = setInterval(update, delta);
addEventListener("resize", (event) => {
var correction = 1.0 / window.devicePixelRatio;
var secs = document.getElementById("secs");
var topcon = document.getElementById("topcon");
secs.style.zoom = correction;
topcon.style.zoom = correction;
});
</script>
</body>
</html>