Spaces:
Running
Running
Update index.html
Browse files- index.html +48 -94
index.html
CHANGED
@@ -1,97 +1,51 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
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 |
-
text-align: center;
|
52 |
-
font-size: 20px;
|
53 |
-
color: #333;
|
54 |
-
margin-top: 50px;
|
55 |
-
}
|
56 |
-
</style>
|
57 |
-
</head>
|
58 |
-
<body>
|
59 |
-
<h1>Choose the Best Photo</h1>
|
60 |
-
<form>
|
61 |
-
<input type="file" id="photo1Input" accept="image/*">
|
62 |
-
<input type="file" id="photo2Input" accept="image/*">
|
63 |
-
<br><br>
|
64 |
-
<button type="button" onclick="choosePhoto()">Choose Best Photo</button>
|
65 |
-
</form>
|
66 |
-
<div>
|
67 |
-
<img src="" alt="Photo 1" id="photo1">
|
68 |
-
<img src="" alt="Photo 2" id="photo2">
|
69 |
-
</div>
|
70 |
-
<p id="result"></p>
|
71 |
-
<script>
|
72 |
-
function choosePhoto() {
|
73 |
-
var photo1 = document.getElementById("photo1");
|
74 |
-
var photo2 = document.getElementById("photo2");
|
75 |
-
var photo1Input = document.getElementById("photo1Input");
|
76 |
-
var photo2Input = document.getElementById("photo2Input");
|
77 |
-
|
78 |
-
// Set image sources to uploaded files
|
79 |
-
photo1.src = URL.createObjectURL(photo1Input.files[0]);
|
80 |
-
photo2.src = URL.createObjectURL(photo2Input.files[0]);
|
81 |
-
|
82 |
-
// Determine which photo is larger
|
83 |
-
var size1 = photo1.naturalWidth * photo1.naturalHeight;
|
84 |
-
var size2 = photo2.naturalWidth * photo2.naturalHeight;
|
85 |
-
|
86 |
-
// Display result
|
87 |
-
if (size1 > size2) {
|
88 |
-
document.getElementById("result").innerHTML = "The best photo is Photo 1.";
|
89 |
-
} else if (size2 > size1) {
|
90 |
-
document.getElementById("result").innerHTML = "The best photo is Photo 2.";
|
91 |
-
} else {
|
92 |
-
document.getElementById("result").innerHTML = "Both photos are equally good.";
|
93 |
-
}
|
94 |
-
}
|
95 |
-
</script>
|
96 |
-
</body>
|
97 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<title>Photo Score App</title>
|
5 |
+
<style>
|
6 |
+
body {background-color:#f2f2f2;font-family:Arial,sans-serif;color:#333;}
|
7 |
+
h1 {text-align:center;font-size:2em;margin-top:30px;color:#4CAF50;}
|
8 |
+
form {margin:50px auto;padding:20px;background-color:#fff;border-radius:10px;
|
9 |
+
box-shadow:0 0 10px #888;width:400px;display:flex;flex-direction:column;align-items:center;}
|
10 |
+
label {font-size:1.2em;margin-top:10px;color:#555;}
|
11 |
+
input[type="file"] {margin-top:10px;font-size:1.2em;padding:10px;border:none;
|
12 |
+
background-color:#eee;border-radius:5px;width:80%;}
|
13 |
+
button {margin-top:20px;font-size:1.2em;padding:10px;border:none;background-color:#4CAF50;
|
14 |
+
color:#fff;border-radius:5px;cursor:pointer;transition:background-color 0.3s;}
|
15 |
+
button:hover {background-color:#3e8e41;}
|
16 |
+
#best-photo {max-width:400px;max-height:400px;margin-top:50px;display:block;
|
17 |
+
border-radius:10px;box-shadow:0 0 10px #888;}
|
18 |
+
h2 {margin-top:30px;font-size:1.8em;color:#4CAF50;}
|
19 |
+
</style>
|
20 |
+
</head>
|
21 |
+
<body>
|
22 |
+
<h1>Photo Score App</h1>
|
23 |
+
<form method="POST" action="" enctype="multipart/form-data">
|
24 |
+
<label for="photo1">Photo 1:</label>
|
25 |
+
<input type="file" name="photo1" id="photo1">
|
26 |
+
<label for="photo2">Photo 2:</label>
|
27 |
+
<input type="file" name="photo2" id="photo2">
|
28 |
+
<button type="submit" name="submit">Find Best Photo</button>
|
29 |
+
</form>
|
30 |
+
<div>
|
31 |
+
<h2>Best Photo:</h2>
|
32 |
+
<img src="" id="best-photo">
|
33 |
+
</div>
|
34 |
+
<script>
|
35 |
+
function calculateScore(photo) {return Math.floor(Math.random() * 10) + 1;}
|
36 |
+
function comparePhotos(photo1, photo2) {
|
37 |
+
let score1 = calculateScore(photo1);
|
38 |
+
let score2 = calculateScore(photo2);
|
39 |
+
return (score1 > score2) ? photo1 : photo2;
|
40 |
+
}
|
41 |
+
document.querySelector('form').addEventListener('submit', function(event) {
|
42 |
+
event.preventDefault();
|
43 |
+
let photo1 = document.querySelector('#photo1').files[0];
|
44 |
+
let photo2 = document.querySelector('#photo2').files[0];
|
45 |
+
let bestPhoto = comparePhotos(photo1, photo2);
|
46 |
+
let bestPhotoUrl = URL.createObjectURL(bestPhoto);
|
47 |
+
document.querySelector('#best-photo').src = bestPhotoUrl;
|
48 |
+
});
|
49 |
+
</script>
|
50 |
+
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
</html>
|