-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (44 loc) · 2 KB
/
script.js
File metadata and controls
54 lines (44 loc) · 2 KB
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
$(document).ready(function () {
// Function to get query parameters from the URL
function getQueryParameter(parameterName) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(parameterName);
}
// Check if there's an 'imei' parameter in the URL
const imeiFromUrl = getQueryParameter('imei');
if (imeiFromUrl) {
// Extract the first 8 digits of the IMEI from the URL
const imei = imeiFromUrl.substring(0, 8);
// Check if the extracted IMEI is valid (should be 8 digits)
if (/^\d{8}$/.test(imei)) {
// Construct the image filename based on the IMEI
const imageName = imei + '.jpg';
// Create an image element and set its source
const image = $('<img>').attr('src', '/home/scraper/pictures/' + imageName);
// Clear previous images and append the new one
$('#imageContainer').empty().append(image);
} else {
alert('Invalid IMEI in the URL. Please provide a valid 8-digit IMEI.');
}
} else {
// Display the placeholder image when no IMEI is provided
$('#placeholderImage').show();
}
$('#fetchButton').on('click', function () {
// Get the IMEI from the input field
const fullImei = $('#imeiInput').val();
// Extract the first 8 digits of the IMEI
const imei = fullImei.substring(0, 8);
// Check if the extracted IMEI is valid (should be 8 digits)
if (/^\d{8}$/.test(imei)) {
// Construct the image filename based on the IMEI
const imageName = imei + '.jpg';
// Create an image element and set its source
const image = $('<img>').attr('src', '/home/scraper/pictures/' + imageName);
// Clear previous images and append the new one
$('#imageContainer').empty().append(image);
} else {
alert('Please enter a valid IMEI with at least 8 digits.');
}
});
});