-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
481 lines (295 loc) · 11.6 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<!doctype html>
<html lang="en">
<head>
<title>BoardBlaster Beta</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="shortcut icon" type="image/ico" href="thumb/favicon.ico"/>
<style>
.list-group{
width:100%;
}
imgOLD {
width:100px;
height:100px;
overflow:hidden;
}
</style>
</head>
<body>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
<script>
var index;
var socket = io();
var curboard;
var threads = [];
//alla ricezione della socket info
socket.on('boards', function(data) {
//var testarray = Array.from(data);
data.boards.forEach(function(item){
var b_letter = item.letter;
var b_name = item.name;
$('#boards').append('<option value="' + b_letter + '">/' + b_letter + '/ ('+ b_name +')</option>' );
});
});
socket.on('ScanRes', function(json) {
$('#progbar-space').hide();
var JSONObject = JSON.parse(json);
var name = JSONObject["name"];
var num = JSONObject["num"];
var maximgs = JSONObject["maximgs"];
var img = JSONObject["img"];
var thumbs = JSONObject["thumbs"];
var alreadyDL = JSONObject["alreadyDL"];
//console.log(img);
var jobj = {"index":index,"num":num,"name":name, "flag": "ign"};
var bgcolor = "white";
if(alreadyDL){
bgcolor = "#f4ffb6"
//alert(name + " già scaricato!");
}
//alert(JSONObject.img[0][0]);
if($('#listah').append(
'<div class="lista"><li class="list-group-item" style="background-color:'+bgcolor+';">' +
'<div class="row"> <div class="col-md-4">' +
'<h4><a href="https://boards.4channel.org/'+curboard+'/thread/'+num+'" target="_blank" >' +name+ '</a></h4><p>Has ' + maximgs + ' elements</p><p>Thread N.'+num+ '</p></div>' +
'<div class="col-md-4">' +
//immagini
'<img src="' + thumbs[0] + '" alt="" />'+
'<img src="' + thumbs[1] + '" alt="" />'+
'<img src="' + thumbs[2] + '" alt="" />'+
'</div><div class="col-md-4"><form>' +
'<div class="radio"><label><input type="radio" name="rad_btn" data-action="ign" data-index="' + index +'" checked> Ignore</label></div>'+
'<div class="radio"><label><input type="radio" name="rad_btn" data-action="dwn" data-index="' + index +'" > Download</label></div>'+
'<div class="radio"><label><input type="radio" name="rad_btn" data-action="blk" data-index="' + index +'" > Blacklist</label></div>'+
'</form></div></div></li></div>'
)){
//threads.splice(0, index, jobj);
threads.push(jobj);
//console.log(threads);
index++;
//threads.push(jobj);
}else{
alert("ERRORE");
}
//alert(name + img);
});
socket.on('done', function() {
$('.elaborateBTN').show();
$('#stop').show();
$('#scan').show();
});
socket.on('progBar', function(progBarObj) {
$('#progbar-space').show();
var prog = JSON.parse(progBarObj);
// console.log(prog);
/*
Mi servono i seguenti dati:
- N. delle immagini tot da scaricare
- N. di immagini attualmente scaricate
- Nome thread in download
*/
var currimg = prog["currimg"];
var maximg = prog["maximg"];
var desc = prog["desc"];
//x:100=currimg:maximg
var barValue = Math.floor((currimg * 100)/maximg);
//console.log(Math.floor((currimg * 100)/maximg));
$('.progress-bar').css('width', barValue+'%').attr('aria-valuenow', barValue).text(currimg + "/" + maximg);
$('#proglabel1').text("Downloading from thread: " + desc);
$('#proglabel2').text("Downloaded: " + currimg + " out of " + maximg);
});
//'form input[type=radio]:checked'
socket.on('comms', function(data) {
console.log(data);
/*
Mi servono i seguenti dati:
- comm: Messaggio da comunicare
- switch: condizione custom per visualizzazioni avanzate
*/
var mess = data.comm + "\n"
var swtch = data.swtch
$('#txtConsole').prepend(mess);
});
$(function() {
socket.emit('req-boards', "");
index = 0;
$('#scan, #start, #stop, #skip').click(function () {
if (this.id == 'skip') {
socket.emit('skipDL', "" );
}
if (this.id == 'stop') {
curboard = $('#boards').val();
//$('#txtConsole').prepend("STARTING..."+ "\n");
socket.emit('clear', curboard );
$(".lista").remove();
location.reload();
}
if (this.id == 'scan') {
curboard = $('#boards').val();
//$('#txtConsole').prepend("STARTING..."+ "\n");
socket.emit('scan', curboard);
$(".lista").remove();
$('#txtConsole').text('');
$('.elaborateBTN').hide();
$('#stop').hide();
$('#scan').hide();
}
if (this.id == 'start') {
//console.log(threads);
//al click si prende l'array e si manda al webserver.
//il webserver sarà poi lui a smistarle in base al flag e ad effettuare l'associazione con l'array di json.
//gli ID combacieranno e lui prenderà le info dai json immagazzinati.
// I DATI VENGONO TRASMESSI SOLO ALLA PRESSIONE DEL BOTTONE, NON SI PUO' CAMBIARE PAGINA DINAMICAMENTE
$('.elaborateBTN').hide();
socket.emit('work', threads);
$(".lista").remove();
$('#stop').hide();
$('#scan').hide();
}
});
$("body").on("change", "input[name='rad_btn']:radio", function(){
var flag = $(this).data("action");
//alert();
if ($(this).data("action") == 'ign') {
threads[$(this).data("index")].flag = flag;
//alert("ign " + $(this).data("index") );
}else if($(this).data("action") == 'dwn'){
flag = $(this).data("action");
threads[$(this).data("index")].flag = flag;
//alert(threads[$(this).data("index")].flag);
// alert(flag);
}else if ($(this).data("action") == 'blk'){
flag = $(this).data("action");
threads[$(this).data("index")].flag = flag;
}
//alert($(this).data("index") + ' ' + threads[$(this).data("index")].flag);
//console.log(threads[$(this).data("index")]);
});
});
$(document).ready(function() {
$('#progbar-space').hide();
$('.elaborateBTN').hide();
//Aggiungere hide per clear e scan button.
});
</script>
<div class="container">
<!-- Static navbar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">BoardBlaster </a><a class="navbar-brand" href="view" target="_blank"> Viewer</a>
</div>
</div><!--/.container-fluid -->
</nav>
<!-- Main component for a primary marketing message or call to action -->
<center> <div class="jumbotron">
<div class="container">
<div class="row">
<div class="col">
<label for="boards">Choose a Board:</label>
<select id="boards"></select>
</div>
<div class="col">
<h1>V.0.8</h1>
</div>
<div class="col">
<button id="scan" type="button" class="btn btn-dark">Start scanning threads</button></br></br>
<button id="stop" type="button" class="btn btn-danger">Clear All</button>
</div>
</div>
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<h3><small id="infos" class="text-muted">Made by: WS</small></h3>
</div>
<div class="col-md-4">
</div>
</div>
<div class="row">
<div class="col-md-4">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#demo">
Hide/Show Console
</button>
</div>
<div class="col-md-4"></div>
<div class="col-md-4">
</div>
</div>
<div class="row collapse show" id="demo">
<div class="col">
<label for="txtConsole">Console</label>
<textarea class="form-control" id="txtConsole" rows="10"></textarea>
</div>
</div>
</br>
</br>
<div class="row" id="progbar-space" >
<div class="col-md-3"></div>
<div class="col-md-6 bg-light" style="border:1px solid black; border-radius: 10px;padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px">
<p id="proglabel1"></p>
<div class="container">
<div class="progress" style="height: 25px">
<div id="progbar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 100%">Please Wait...</div>
</div>
</div>
</br>
<p id="proglabel2"></p>
<button id="skip" type="button" class="btn btn-warning">Skip This Download</button>
</div>
<div class="col-md-3"></div>
</div>
<div class="row elaborateBTN" id="elaborateBTN">
<div class="col">
<button id="start" type="button" class="btn btn-success">Elaborate</button>
</div>
</div>
</br>
</br>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<ul id="listah" class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-4">
<p>Nome Thread</p>
</div>
<div class="col-md-4">
<p>Immagini</p>
</div>
<div class="col-md-4">
<p>Blacklista/Download</p>
</div>
</div>
</li>
</ul>
</div>
</div>
</br>
</br>
<div class="row elaborateBTN" id="elaborateBTN">
<div class="col">
<button id="start" type="button" class="btn btn-success">Elaborate</button>
</div>
</div>
</br>
</div>
</div> </center>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
==================================================
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
-->
</body>
</body>
</html>