forked from safonovpro/node-html-crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
154 lines (125 loc) · 4.17 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
<!doctype html>
<html>
<head>
<title>candd client v.1</title>
<link rel="shortcut icon" href="favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div.spinner {
height: 40px;
width: 40px;
margin: 20px auto;
border-radius: 50%;
border: dashed 2px blue;
animation-name: loader-spin;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@-webkit-keyframes loader-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial;
}
/* The grid: Four equal columns that floats next to each other */
.column {
float: left;
width: 15%;
padding: 10px;
}
/* Style the images inside the grid */
.column img {
opacity: 0.9;
cursor: pointer;
}
.column img:hover {
opacity: 1;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* The expanding image container */
.container {
position: relative;
display: none;
}
/* Expanding image text */
#imgtext {
position: absolute;
bottom: 15px;
left: 15px;
color: white;
font-size: 20px;
}
/* Closable button inside the expanded image */
.closebtn {
position: absolute;
top: 10px;
right: 15px;
color: white;
font-size: 35px;
cursor: pointer;
}
</style>
</head>
<body>
<div style="text-align:center">
<div class="spinner"></div>
<h3>System is searching...</h3>
</div>
<!-- The four columns -->
<div class="row">
</div>
<div class="container">
<span onclick="this.parentElement.style.display='none'" class="closebtn">×</span>
<img id="expandedImg" style="width:100%">
<div id="imgtext"></div>
</div>
<ul id="messages"></ul>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script src="https://cdn.socket.io/4.1.1/socket.io.min.js" integrity="sha384-cdrFIqe3RasCMNE0jeFG9xJHog/tgOVC1E9Lzve8LQN1g5WUHo0Kvk1mawWjxX7a" crossorigin="anonymous"></script>
<script>
const socket = io("ws://localhost:3000");
socket.on('log_message', function(msg){
$('#messages').append($('<li>').text(msg));
});
/* If image is what user wants add it on page ready to be zoomed. */
socket.on('ok_image', function(msg){
$('div.row').append("<div class='column'><img src='" + msg + "' alt='" + msg + "' style='width:100%' " +
"onclick='showFullImage(this);'></div>");
$('#messages').append($('<li>').text("Hoorah! The image " + msg + " is what you're looking for."));
console.log('ok image ' + msg);
});
/* If image is not what user wants add it on page and make it less visible . */
socket.on('bad_image', function(msg){
$('div.row').append("<div class='column'><img src='bad_images/" + msg + "' alt='" + msg +
"' style='width:100%; opacity: 0.2'></div>");
$('#messages').append($('<li>').text("The image " + msg + " doesn't have valid content."));
console.log('bad image ' + msg);
});
socket.on("disconnect", (reason) => {
/* The disconnection was initiated by the server. */
if (reason === "io server disconnect") {
$('div.spinner').css('animation-duration', '0s');
$('h3').html('Hopefully we found some pretty images for you.');
}
});
function showFullImage(imgs) {
var expandImg = document.getElementById("expandedImg");
var imgText = document.getElementById("imgtext");
expandImg.src = imgs.src;
imgText.innerHTML = imgs.alt;
expandImg.parentElement.style.display = "block";
}
</script>
</body>
</html>