-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (108 loc) · 3.34 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTTP(S) Images</title>
<style>
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.container {
width: 100vw;
height: 100vh;
padding: 40px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.container > h1 {
width: 100%;
text-align: center;
}
.container > .imgs {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.container > .imgs > .img-container {
display: flex;
flex-direction: column;
margin: 10px;
}
.container > .imgs > .img-container > img {
width: 300px;
height: 240px;
border: 1px solid #ccc;
}
.container > .imgs > .img-container > p {
font-size: 1.5rem;
text-align: center;
margin: 10px 0;
}
.container > .result-text {
font-size: 1.5rem;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h1>HTTP(S) Images</h1>
<div class="imgs">
<div class="img-container">
<img id="http-img" src="http://danzetsu.biscuitt.in/http-200.jpeg" alt="Cat 200">
<p>HTTP image</p>
</div>
<div class="img-container">
<img id="https-img" src="https://danzetsu.biscuitt.in/https-200.jpeg" alt="Cat 200">
<p>HTTPS image</p>
</div>
</div>
<p class="result-text">
Result:
<span id="result-value"></span>
</p>
</div>
<script>
(function () {
function getResult (http, https, resultValue) {
if (http && https) {
resultValue.innerText = 'HTTP and HTTPS images are loaded';
}
if (http && !https) {
resultValue.innerText = 'HTTP image is loaded';
}
if (!http && https) {
resultValue.innerText = 'HTTPS image is loaded';
}
if (!http && !https) {
resultValue.innerText = 'No images are loaded';
}
}
const httpImg = document.getElementById('http-img');
const httpsImg = document.getElementById('https-img');
const resultValue = document.getElementById('result-value');
let http, https = false;
httpImg.onload = function (ev) {
console.log('HTTP image loaded', ev);
http = true;
getResult(http, https, resultValue);
};
httpsImg.onload = function (ev) {
console.log('HTTPS image loaded', ev);
https = true;
getResult(http, https, resultValue);
};
})();
</script>
</body>
</html>