-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.html
146 lines (129 loc) · 4.52 KB
/
verify.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Coordinate Marker</title>
<style>
#image-container {
position: relative;
display: inline-block;
}
.cross {
position: absolute;
width: 30px;
height: 30px;
background-color: transparent;
}
.cross:before, .cross:after {
content: '';
position: absolute;
background: red;
}
.cross:before {
width: 2px;
height: 30px;
top: 0;
left: 14px;
}
.cross:after {
width: 30px;
height: 2px;
top: 14px;
left: 0;
}
#navigation {
margin-top: 20px;
}
#image-url {
margin-bottom: 10px;
font-style: italic;
}
</style>
</head>
<body>
<h1>Image Coordinate Marker</h1>
<form id="coordinate-form">
<label for="input">Enter URLs and Coordinates (one per line):</label><br>
<textarea id="input" placeholder="URL - X: <value>, Y: <value>" style="width: 600px; height: 100px;"></textarea><br>
<button type="submit">Submit</button>
</form>
<br>
<div id="image-url"></div>
<div id="image-container"></div>
<div id="navigation" style="display: none;">
<button id="prev">Previous</button>
<button id="next">Next</button>
</div>
<script>
const form = document.getElementById('coordinate-form');
const imageContainer = document.getElementById('image-container');
const navigation = document.getElementById('navigation');
const prevButton = document.getElementById('prev');
const nextButton = document.getElementById('next');
const imageUrlDisplay = document.getElementById('image-url');
let entries = [];
let currentIndex = 0;
form.addEventListener('submit', (e) => {
e.preventDefault();
const input = document.getElementById('input').value.trim();
entries = input.split('\n').map(line => {
const match = line.match(/^(https?:\/\/\S+)\s*-\s*X:\s*(\d+\.?\d*),\s*Y:\s*(\d+\.?\d*)$/);
if (match) {
const [_, url, x, y] = match;
return { url, x: parseFloat(x), y: parseFloat(y) };
}
return null;
}).filter(entry => entry);
if (entries.length === 0) {
alert('Please enter valid entries in the format: URL - X: <value>, Y: <value>');
return;
}
currentIndex = 0;
showImage();
navigation.style.display = 'block';
});
function showImage() {
if (entries.length === 0) return;
const { url, x, y } = entries[currentIndex];
imageContainer.innerHTML = '';
imageUrlDisplay.textContent = `Currently viewing: ${url}`;
const img = document.createElement('img');
img.src = url;
img.style.maxWidth = '800px';
img.style.display = 'block';
img.onload = () => {
const originalWidth = img.naturalWidth;
const originalHeight = img.naturalHeight;
const displayedWidth = img.width;
const displayedHeight = img.height;
const scaleX = displayedWidth / originalWidth;
const scaleY = displayedHeight / originalHeight;
const scaledX = x * scaleX;
const scaledY = y * scaleY;
const cross = document.createElement('div');
cross.className = 'cross';
cross.style.left = `${scaledX - 15}px`;
cross.style.top = `${scaledY - 15}px`;
imageContainer.appendChild(cross);
};
img.onerror = () => {
alert('Failed to load image: ' + url);
};
imageContainer.appendChild(img);
}
prevButton.addEventListener('click', () => {
if (currentIndex > 0) {
currentIndex--;
showImage();
}
});
nextButton.addEventListener('click', () => {
if (currentIndex < entries.length - 1) {
currentIndex++;
showImage();
}
});
</script>
</body>
</html>