forked from ellite/Wallos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logos.php
64 lines (55 loc) · 2.22 KB
/
logos.php
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
<!DOCTYPE html>
<html>
<head>
<title>Subscription Logos</title>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
const searchForm = document.getElementById("search-form");
const imageResults = document.getElementById("image-results");
searchForm.addEventListener("submit", function (e) {
e.preventDefault();
const searchTerm = document.getElementById("search").value.trim();
if (searchTerm === "") {
alert("Please enter a search term.");
return;
}
// Use the proxy to perform a Google image search
const proxyUrl = `endpoints/logos/search.php?search=${searchTerm}`;
// Send an AJAX request to the proxy
fetch(proxyUrl)
.then(response => response.json())
.then(data => {
if (data.imageUrls) {
// Display the image sources from the PHP response.
displayImageResults(data.imageUrls);
} else if (data.error) {
console.error(data.error);
}
})
.catch(error => {
console.error("Error fetching image results:", error);
});
});
function displayImageResults(imageSources) {
// Clear previous results
imageResults.innerHTML = "";
// Display the image sources as image elements
imageSources.forEach(src => {
const img = document.createElement("img");
img.src = src;
imageResults.appendChild(img);
});
}
});
</script>
</head>
<body>
<form id="search-form">
<input type="text" name="search" id="search">
<input type="submit" value="Search">
</form>
<div id="image-results">
<!-- Image results will be displayed here -->
</div>
</body>
</html>