Siteβ―Builder
Editing:
compare-list.html
writable 0666
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Phone Comparisons</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; } .header { background-color: white; padding: 10px 20px; border-bottom: 1px solid #ccc; display: flex; justify-content: space-between; align-items: center; } .header img { height: 50px; } .nav { display: flex; gap: 20px; } .nav a { text-decoration: none; color: #0056b3; font-weight: bold; } .news-flash { background-color: red; color: white; text-align: center; padding: 10px 0; } .compare-container { padding: 20px; } .phone-list { list-style: none; padding: 0; } .phone-item { cursor: pointer; margin: 10px 0; padding: 10px; border: 1px solid #ccc; border-radius: 5px; background-color: #f9f9f9; } .comparison-list { display: none; margin: 10px 0; padding: 0; list-style: none; } .comparison-item { margin: 5px 0; } </style> </head> <body> <div class="header"> <img src="https://www.rfsafe.com/wp-content/uploads/2022/03/rfsafe-logo-r.jpg" alt="RF Safe Logo"> <div class="nav"> <a href="#">Info</a> <a href="#">News</a> <a href="#">SAR Database</a> <a href="#">QuantaCase</a> <a href="#">iPhone</a> <a href="#">Samsung</a> <a href="#">Google</a> </div> </div> <div class="news-flash"> News Flash β‘ Spot Fake Anti Radiation Phone Cases </div> <div class="compare-container" id="compare-container"> <ul class="phone-list" id="phone-list"></ul> </div> <script> document.addEventListener("DOMContentLoaded", function() { // Set the number of years back to filter phones const yearsBack = 5; // Get the current date and calculate the cutoff date const currentDate = new Date(); const cutoffDate = new Date(); cutoffDate.setFullYear(currentDate.getFullYear() - yearsBack); fetch('cache/sar2_cache.json') .then(response => response.json()) .then(phoneData => { const phoneList = document.getElementById('phone-list'); phoneData = phoneData.filter(phone => { const phoneDate = new Date(phone.releasedate); return phoneDate >= cutoffDate; }); // Sort alphanumerically phoneData.sort((a, b) => { const nameA = `${a.brand} ${a.model}`.toLowerCase(); const nameB = `${b.brand} ${b.model}`.toLowerCase(); return nameA.localeCompare(nameB, undefined, { numeric: true, sensitivity: 'base' }); }); phoneData.forEach((phone, index) => { const phoneItem = document.createElement('li'); phoneItem.className = 'phone-item'; phoneItem.textContent = `${phone.brand} ${phone.model}`; phoneItem.dataset.index = index; phoneList.appendChild(phoneItem); const comparisonList = document.createElement('ul'); comparisonList.className = 'comparison-list'; let otherPhones = phoneData.filter((_, otherIndex) => index !== otherIndex); // Sort alphanumerically otherPhones.sort((a, b) => { const nameA = `${a.brand} ${a.model}`.toLowerCase(); const nameB = `${b.brand} ${b.model}`.toLowerCase(); return nameA.localeCompare(nameB, undefined, { numeric: true, sensitivity: 'base' }); }); otherPhones.forEach(otherPhone => { const comparisonItem = document.createElement('li'); comparisonItem.className = 'comparison-item'; comparisonItem.innerHTML = ` <a href="/compare-sar.php?pid=${phone.post_id}-${otherPhone.post_id}"> Compare ${phone.brand} ${phone.model} with ${otherPhone.brand} ${otherPhone.model} </a> `; comparisonList.appendChild(comparisonItem); }); phoneItem.appendChild(comparisonList); phoneItem.addEventListener('click', function() { const currentComparisonList = this.querySelector('.comparison-list'); currentComparisonList.style.display = currentComparisonList.style.display === 'block' ? 'none' : 'block'; }); }); }); }); </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel