iasjkk commited on
Commit
3fc8d32
·
verified ·
1 Parent(s): 8dee667

Upload abc.html

Browse files
Files changed (1) hide show
  1. abc.html +168 -0
abc.html ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Record Mouse Coordinates</title>
7
+ <style>
8
+ .required { color: red; }
9
+ .hidden { display: none; }
10
+ #output_file { border: 1px solid #000; }
11
+ .button { width: 90px; margin: 5px; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+
16
+ <h2>Input record XY mouse coordinates on an uploaded image:</h2>
17
+ <form id="inputForm" method="post" enctype="multipart/form-data">
18
+ <table>
19
+ <tr>
20
+ <td>Upload image <span class="required">*</span>:<br />Max 500 KB.</td>
21
+ <td><input type="file" name="inputfile" id="inputfile" size="45" required /></td>
22
+ </tr>
23
+ <tr>
24
+ <td>Please enter the Access Code as displayed below <span class="required">*</span>:</td>
25
+ <td><img src="https://www.mobilefish.com/php/secureimage/createimage.php" alt="Access code" /></td>
26
+ <td><input type="text" name="accesscode" id="accesscode" size="7" maxlength="3" required /></td>
27
+ </tr>
28
+ <tr>
29
+ <td colspan="2"><span class="required">* = required</span></td>
30
+ <td><input type="submit" value="Upload image" /></td>
31
+ </tr>
32
+ <tr>
33
+ <td>Mouse coordinate:</td>
34
+ <td>
35
+ X-coord: <input name="cssxXval" id="cssxXval" value="0" size="7" maxlength="4" readonly /> px
36
+ Y-coord: <input name="cssxYval" id="cssxYval" value="0" size="7" maxlength="4" readonly /> px
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <td colspan="3">
41
+ <canvas id="output_file" width="500" height="500"></canvas>
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <td colspan="2">Image width = <span id="cssxNewImageWidth">0</span> px<br />
46
+ Image height = <span id="cssxNewImageHeight">0</span> px<br />
47
+ Number of coordinates = <span id="cssxTotalCoordinates">0</span>
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td>Recorded coordinates:</td>
52
+ <td colspan="2">
53
+ <select name="cssxCoordinates" id="cssxCoordinates" size="10" style="width: 320px;">
54
+ <option value="-1"></option>
55
+ </select>
56
+ </td>
57
+ </tr>
58
+ <tr>
59
+ <td>Change the recorded coordinates:</td>
60
+ <td colspan="2">
61
+ X-coord: <input name="cssxXvalSelect" id="cssxXvalSelect" size="7" maxlength="4" />
62
+ Y-coord: <input name="cssxYvalSelect" id="cssxYvalSelect" size="7" maxlength="4" />
63
+ </td>
64
+ </tr>
65
+ <tr>
66
+ <td colspan="3">
67
+ <input type="button" value="Add" class="button" onclick="jsxAdd()" />
68
+ <input type="button" value="Change" class="button" onclick="jsxChange()" />
69
+ <input type="button" value="Delete" class="button" onclick="jsxDelete()" />
70
+ <input type="button" value="Delete all coordinates" class="button" onclick="jsxDeleteAll()" />
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </form>
75
+
76
+ <script>
77
+ const canvas = document.getElementById('output_file');
78
+ const ctx = canvas.getContext('2d');
79
+ let coordinates = [];
80
+
81
+ document.getElementById('inputfile').addEventListener('change', loadImage);
82
+
83
+ function loadImage(event) {
84
+ const file = event.target.files[0];
85
+ if (file) {
86
+ const reader = new FileReader();
87
+ reader.onload = function(e) {
88
+ const img = new Image();
89
+ img.onload = function() {
90
+ canvas.width = img.width;
91
+ canvas.height = img.height;
92
+ ctx.drawImage(img, 0, 0);
93
+ document.getElementById('cssxNewImageWidth').textContent = img.width;
94
+ document.getElementById('cssxNewImageHeight').textContent = img.height;
95
+ };
96
+ img.src = e.target.result;
97
+ };
98
+ reader.readAsDataURL(file);
99
+ }
100
+ }
101
+
102
+ canvas.addEventListener('mousemove', function(event) {
103
+ const rect = canvas.getBoundingClientRect();
104
+ const x = event.clientX - rect.left;
105
+ const y = event.clientY - rect.top;
106
+ document.getElementById('cssxXval').value = x;
107
+ document.getElementById('cssxYval').value = y;
108
+ });
109
+
110
+ canvas.addEventListener('mousedown', function(event) {
111
+ const rect = canvas.getBoundingClientRect();
112
+ const x = event.clientX - rect.left;
113
+ const y = event.clientY - rect.top;
114
+ coordinates.push({ x, y });
115
+ updateCoordinatesList();
116
+ });
117
+
118
+ function updateCoordinatesList() {
119
+ const select = document.getElementById('cssxCoordinates');
120
+ select.innerHTML = '';
121
+ coordinates.forEach((coord, index) => {
122
+ const option = document.createElement('option');
123
+ option.value = index;
124
+ option.textContent = `(${coord.x}, ${coord.y})`;
125
+ select.appendChild(option);
126
+ });
127
+ document.getElementById('cssxTotalCoordinates').textContent = coordinates.length;
128
+ }
129
+
130
+ function jsxAdd() {
131
+ const x = parseInt(document.getElementById('cssxXvalSelect').value);
132
+ const y = parseInt(document.getElementById('cssxYvalSelect').value);
133
+ if (!isNaN(x) && !isNaN(y)) {
134
+ coordinates.push({ x, y });
135
+ updateCoordinatesList();
136
+ }
137
+ }
138
+
139
+ function jsxChange() {
140
+ const select = document.getElementById('cssxCoordinates');
141
+ const index = select.value;
142
+ if (index >= 0) {
143
+ const x = parseInt(document.getElementById('cssxXvalSelect').value);
144
+ const y = parseInt(document.getElementById('cssxYvalSelect').value);
145
+ if (!isNaN(x) && !isNaN(y)) {
146
+ coordinates[index] = { x, y };
147
+ updateCoordinatesList();
148
+ }
149
+ }
150
+ }
151
+
152
+ function jsxDelete() {
153
+ const select = document.getElementById('cssxCoordinates');
154
+ const index = select.value;
155
+ if (index >= 0) {
156
+ coordinates.splice(index, 1);
157
+ updateCoordinatesList();
158
+ }
159
+ }
160
+
161
+ function jsxDeleteAll() {
162
+ coordinates = [];
163
+ updateCoordinatesList();
164
+ }
165
+ </script>
166
+
167
+ </body>
168
+ </html>