-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
162 lines (144 loc) · 5.2 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
<!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>Тестовое задание</title>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
body {
background: linear-gradient(180deg, rgba(224, 224, 224, 0.8) 0%, rgba(141, 241, 255, 0.64) 87.5%), #DF9BFF;
font-family: Inter;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
.cats__main {
font-size: 24px;
width: 100%;
height: 400px;
}
.cats__wrapper {
margin: 0 auto;
max-width: 600px;
}
.cats__bottoms {
font-size: 12px;
padding-top: 109px;
display: flex;
justify-content: space-between;
height: 180px;
gap: 21px;
}
.cats__bottom-item {
width: 100%;
height: 100%;
}
.cats__bottom-description {
display: flex;
justify-content: space-between;
}
.cats__bottom-header {
font-size: 1em;
line-height: 2em;
}
.cats__bottom-text {
font-size: 0.7em;
line-height: 2.2em;
background: none;
border: none;
}
.cats__bottom-text::placeholder {
color: #000000;
}
.cats__bottom-size {
font-size: 0.8em;
line-height: 2em;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script>
$(document).ready(function () {
const input = $('.cats__bottom-text');
function loadImage(url, dataImg) {
$.ajax({
url: url,
type: 'GET',
xhrFields: { responseType: 'blob' },
dataType: 'binary',
success: function (blob) {
var url = URL.createObjectURL(blob);
let image = `img[data-img = ${dataImg}]`;
let size = `span[data-size = ${dataImg}]`;
$(image).attr("src", url);
const img = $(image).get(0);
img.onload = function () {
var w = img.naturalWidth;
var h = img.naturalHeight;
console.log(h, 'h')
const str = w + 'X' + h;
$(size).text(str);
}
},
error: function (xhr, status) {
console.log('При загрузке файла произошла ошибка:', xhr);
}
});
}
input.change(function () {
const url = 'https://cataas.com/cat/says/' + $(this).val();
const dataImg = $(this).data('img');
loadImage(url, dataImg);
});
input.on('input', function () {
const url = 'https://cataas.com/cat/says/' + $(this).val();
const dataImg = $(this).data('img');
loadImage(url, dataImg);
})
});
</script>
</head>
<body>
<section class="cats__wrapper">
<div class="cats__main">
<div class="cats__bottom-item">
<p class="cats__bottom-header">Main Cat</p>
<img src="hello 1.png" data-img="main" alt="kitty">
<div class="cats__bottom-description">
<input class="cats__bottom-text js-name" data-img="main" placeholder="hello" />
<span class="cats__bottom-size" data-size="main">300x200</span>
</div>
</div>
</div>
<div class="cats__bottoms">
<div class="cats__bottom-item">
<p class="cats__bottom-header">Small cat</p>
<img src="meow 1.png" data-img="bottom-1" alt="hello 1">
<div class="cats__bottom-description">
<input class="cats__bottom-text js-name" data-img="bottom-1" placeholder="prupru" />
<span class="cats__bottom-size" data-size="bottom-1">200x100</span>
</div>
</div>
<div class="cats__bottom-item">
<p class="cats__bottom-header">Another small cat</p>
<img src="prupru 1.png" data-img="bottom-2" alt="prupru 1">
<div class="cats__bottom-description">
<input class="cats__bottom-text js-name" data-img="bottom-2" placeholder="meow" />
<span class="cats__bottom-size" data-size="bottom-2">200x100</span>
</div>
</div>
</div>
</section>
</body>
</html>