Siteβ―Builder
Editing:
sar-summaryiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.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>SAR Summary</title> <style> body { font-family: Arial, sans-serif; padding: 20px; } .sar-summary-container { display: flex; flex-wrap: wrap; align-items: flex-start; } .phone-details { margin-right: 20px; flex: 1; } .phone-details img { max-width: 300px; height: auto; } .phone-details p { margin: 5px 0; } .phone-details a { text-decoration: none; color: #0073aa; } .phone-details a:hover { text-decoration: underline; } .sar-summary { flex: 2; font-size: 16px; } .sar-summary strong { font-weight: bold; } @media (max-width: 768px) { .sar-summary-container { flex-direction: column; } .phone-details { margin-right: 0; margin-bottom: 20px; } } .sar-ranking-box { background-color: #0044cc; /* Different color for the ranking box */ color: #fff; text-align: center; padding: 10px; border-radius: 5px; margin-bottom: 10px; position: relative; } .sar-ranking-box .sar-ranking { font-size: 18px; font-weight: bold; } .sar-ranking-box .sar-value { font-size: 16px; } .sar-ranking-box a { color: #fff; /* White color for the link */ text-decoration: underline; font-size: 20px; font-weight: bold; /* Bold font for the link */ } .sar-ranking-box .btn { position: absolute; top: 50%; transform: translateY(-50%); background-color: transparent; color: #fff; border: none; font-size: 20px; cursor: pointer; } .sar-ranking-box .btn.prev { left: 10px; } .sar-ranking-box .btn.next { right: 10px; } .sar-table-container { overflow-x: auto; } .sar-table { width: 100%; border-collapse: collapse; } .sar-table th, .sar-table td { border: 1px solid #ddd; padding: 8px; text-align: center; cursor: pointer; } .sar-table th { background-color: #000; color: #fff; font-weight: bold; } .sar-table .highlight { background-color: yellow; } .highlight-rank { background-color: yellow; color: black; padding: 0 5px; font-size: 24px; font-weight: bold; display: inline-block; } .sar-info { text-align: center; margin-top: 10px; } .sar-info a { color: #0073aa; text-decoration: none; font-weight: bold; } .sar-info a:hover { color: #005a87; } @media (max-width: 600px) { .sar-ranking-box { padding: 5px; font-size: 14px; } .sar-table th, .sar-table td { padding: 4px; font-size: 14px; } .sar-ranking-box .btn { font-size: 16px; } } .specs-container { padding: 20px; } .specs-table { width: 100%; border-collapse: collapse; margin-top: 20px; } .specs-table th, .specs-table td { border: 1px solid #ddd; padding: 10px; text-align: left; } .specs-table th { background-color: #000; color: #fff; font-weight: bold; } .spec-group-title { background-color: #0073aa; color: white; padding: 10px; text-align: left; font-size: 18px; } .review-summary { display: none; } .review-summary p { display: inline; } .review-summary a { color: #0056b3; cursor: pointer; text-decoration: underline; } </style> </head> <body> <div class="sar-summary-container"> <div class="phone-details" id="phone-details"></div> <div id="sar-summary" class="sar-summary"></div> </div> <div id="sar-ranking-container"></div> <script> document.addEventListener("DOMContentLoaded", function() { const testPositions = [ 'ushead', 'usbody', 'productspecific', 'simulheadus', 'simulbodyus', 'hotspot' ]; const testPositionNames = { 'ushead': 'Head SAR (Cellular Only)', 'usbody': 'Body SAR (Cellular Only)', 'productspecific': 'Hot Spot SAR (Cellular Only)', 'simulheadus': 'Head SAR (Wi-Fi + Cellular)', 'simulbodyus': 'Body SAR (Wi-Fi + Cellular)', 'hotspot': 'Hot Spot SAR (Wi-Fi + Cellular)' }; const urlParams = new URLSearchParams(window.location.search); const pid = urlParams.get('pid'); const currentPath = window.location.pathname.split('/'); const slug = currentPath[currentPath.length - 2]; fetch('/cache/sar2_cache.json') .then(response => response.json()) .then(phoneData => { const phone = phoneData.find(p => p.post_id == pid || (p.brand + ' ' + p.model).toLowerCase().replace(/ /g, '-') === slug); if (phone) { displayPhoneDetails(phone); displaySARSummary(phone); initializeSARRanking(phone); } else { document.getElementById('sar-summary').innerHTML = '<p>Phone data not found.</p>'; } }); function displayPhoneDetails(phone) { const { brand, model, thumbnail_url, screensize, dimensions, product_permalink, product_title, product_price } = phone; const phoneDetailsHTML = ` <img src="${thumbnail_url}" alt="${brand} ${model}"> <p><strong>${brand} ${model}</strong></p> <p>Screen Size: ${screensize || 'Coming Soon'}</p> <p>Dimensions: ${dimensions || 'Coming Soon'}</p> <p><a href="${product_permalink || 'https://www.rfsafe.com/best-phone-case-for-smartphone-radiation-protection/'}">${product_title || 'QuantaCase'}</a></p> <p>${formatPrice(product_price)}</p> `; document.getElementById('phone-details').innerHTML = phoneDetailsHTML; } function displaySARSummary(phone) { const phoneName = `${phone.brand} ${phone.model}`; const fccid = phone.fccid || 'N/A'; const ushead = phone.ushead || 'N/A'; const usbody = phone.usbody || 'N/A'; const productspecific = phone.productspecific || 'N/A'; const simulheadus = phone.simulheadus || 'N/A'; const simulbodyus = phone.simulbodyus || 'N/A'; const hotspot = phone.hotspot || 'N/A'; let summaryHTML = ` <p><br><br><br> <br> <strong>${phoneName} SAR Level Summary: </strong><br><br> The cellular transmission <strong>SAR values for the ${phoneName}</strong> (FCC ID ${fccid}) are <strong>${ushead} W/kg (watts per kilogram) at the head</strong> and <strong>${usbody} W/kg when worn on the body</strong>. `; if (productspecific !== '0.00') { summaryHTML += ` The hotspot/Airplay SAR level is <strong>${productspecific} W/kg</strong>. `; } if (simulheadus !== '0.00') { summaryHTML += ` The simultaneous transmission SAR values for ${phone.model} (cellular plus Wi-Fi) is <strong>${simulheadus} W/kg at the head</strong>, `; } if (simulbodyus !== '0.00') { summaryHTML += `<strong>${simulbodyus} W/kg when worn on the body</strong>, `; } if (hotspot !== '0.00') { summaryHTML += `and <strong>${hotspot} W/kg when used as a hotspot</strong> simultaneously with other transmitters active.<br><hr><br> `; } summaryHTML += '</p>'; document.getElementById('sar-summary').innerHTML = summaryHTML; } function formatPrice(priceString) { const [regularPrice, salePrice] = priceString.split('|'); if (salePrice && !isNaN(salePrice)) { return `<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>${regularPrice}</bdi></span></del> <ins aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>${salePrice}</bdi></span></ins>`; } else { return `<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>${regularPrice}</bdi></span></del> <span class="screen-reader-text">Check Price</span>`; } } function initializeSARRanking(phone) { let currentIndex = 0; const sarData = testPositions.map(testpos => { let rank = 'N/A'; let percent = 'N/A'; if (testpos === 'productspecific') { rank = phone['productspecific_rank'] || 'N/A'; percent = phone['productspecific_percent'] || 'N/A'; } else if (testpos === 'hotspot') { rank = phone['simulhotspot_rank'] || 'N/A'; percent = phone['simulhotspot_percent'] || 'N/A'; } else { rank = phone[`${testpos}_rank`] || 'N/A'; percent = phone[`${testpos}_percent`] || 'N/A'; } return { type: testPositionNames[testpos], link: `/phones/${phone.brand.toLowerCase().replace(/\s+/g, '-')}-${phone.model.toLowerCase().replace(/\s+/g, '-')}/`, rank: parseInt(rank), percent: percent, value: phone[testpos] || 'N/A' }; }); function updateRankingBox(index) { const data = sarData[index]; const rankingBoxHTML = ` <div class="sar-ranking-box"> <button class="btn prev" onclick="changeRanking(-1)"><<</button> <div class="sar-ranking">${data.type}</div> <div class="sar-value"> <a href="${data.link}"> <strong>${data.value} W/kg</strong> </a> <a href="${data.link}"> <span>Ranked #<span class="highlight-rank">${data.rank}</span> (${data.percent}% of limit)</span> </a> </div> <button class="btn next" onclick="changeRanking(1)">>></button> </div> <div class="sar-table-container"> <table class="sar-table"> <thead> <tr> <th>Radiation Levels</th> <th>Head</th> <th>Body</th> <th>Hot Spot</th> </tr> </thead> <tbody> <tr> <td>Cellular Only</td> <td class="${data.type === 'Head SAR (Cellular Only)' ? 'highlight' : ''}">${phone.ushead} W/kg</td> <td class="${data.type === 'Body SAR (Cellular Only)' ? 'highlight' : ''}">${phone.usbody} W/kg</td> <td class="${data.type === 'Hot Spot SAR (Cellular Only)' ? 'highlight' : ''}">${phone.productspecific} W/kg</td> </tr> <tr> <td>Wi-Fi + Cellular</td> <td class="${data.type === 'Head SAR (Wi-Fi + Cellular)' ? 'highlight' : ''}">${phone.simulheadus} W/kg</td> <td class="${data.type === 'Body SAR (Wi-Fi + Cellular)' ? 'highlight' : ''}">${phone.simulbodyus} W/kg</td> <td class="${data.type === 'Hot Spot SAR (Wi-Fi + Cellular)' ? 'highlight' : ''}">${phone.hotspot} W/kg</td> </tr> </tbody> </table> </div> `; document.getElementById('sar-ranking-container').innerHTML = rankingBoxHTML; } window.changeRanking = function (direction) { currentIndex = (currentIndex + direction + sarData.length) % sarData.length; updateRankingBox(currentIndex); }; updateRankingBox(currentIndex); } }); </script> <div class="specs-container"> <h1 id="phone-title">Phone Specifications</h1> <table class="specs-table" id="specs-table"> <tbody> </tbody> </table> </div> <script> document.addEventListener('DOMContentLoaded', function() { const phoneTitle = document.getElementById('phone-title'); const specsTableBody = document.getElementById('specs-table').querySelector('tbody'); // Extract the brand and model from the URL path const pathArray = window.location.pathname.split('/'); const phoneSlug = pathArray[pathArray.length - 2]; // Get the second last segment which is the phone folder name // Construct the JSON file path const jsonFilePath = `${phoneSlug}_cache.json`; // Fetch and display phone specs fetch(jsonFilePath) .then(response => response.json()) .then(data => { // Set the phone title const phoneName = phoneSlug.replace(/-/g, ' ').toUpperCase(); phoneTitle.textContent = phoneName + ' Specifications'; // Populate the table with specs for (const group in data) { // Add group title row const groupRow = document.createElement('tr'); const groupCell = document.createElement('td'); groupCell.setAttribute('colspan', 2); groupCell.className = 'spec-group-title'; groupCell.innerHTML = `<h2>${group}</h2>`; groupRow.appendChild(groupCell); specsTableBody.appendChild(groupRow); // Add individual specs for (const spec in data[group]) { // Add spec label row const specLabelRow = document.createElement('tr'); const specLabelCell = document.createElement('th'); specLabelCell.setAttribute('colspan', 2); specLabelCell.textContent = spec; specLabelRow.appendChild(specLabelCell); specsTableBody.appendChild(specLabelRow); // Add spec value row const specValueRow = document.createElement('tr'); const specValueCell = document.createElement('td'); specValueCell.setAttribute('colspan', 2); let value = data[group][spec]; if (value.length > 500) { const shortValue = value.substring(0, 500) + '... '; const fullValue = value; const summary = document.createElement('div'); summary.className = 'review-summary'; summary.style.display = 'block'; summary.innerHTML = `<p>${shortValue.replace(/<br\s*\/?>/gi, '\n').replace(/\n/g, '<br>')}<a onclick="toggleReview(this)">Continue reading</a></p>`; const fullReview = document.createElement('div'); fullReview.className = 'review-summary'; fullReview.style.display = 'none'; fullReview.innerHTML = `<p>${fullValue.replace(/<br\s*\/?>/gi, '\n').replace(/\n/g, '<br>')}<a onclick="toggleReview(this)"> Show less</a></p>`; specValueCell.appendChild(summary); specValueCell.appendChild(fullReview); } else { specValueCell.innerHTML = value.replace(/<br\s*\/?>/gi, '\n').replace(/\n/g, '<br>'); } specValueRow.appendChild(specValueCell); specsTableBody.appendChild(specValueRow); } } }) .catch(error => { specsTableBody.innerHTML = '<tr><td colspan="2">Error loading specifications. Please try again later.</td></tr>'; }); }); function toggleReview(link) { const summary = link.parentElement.parentElement; const fullReview = summary.nextElementSibling; if (summary.style.display === 'block') { summary.style.display = 'none'; fullReview.style.display = 'block'; } else { summary.style.display = 'block'; fullReview.style.display = 'none'; } } </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel