Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
researchersec authored Dec 25, 2023
1 parent f6f4939 commit afcbc36
Showing 1 changed file with 39 additions and 84 deletions.
123 changes: 39 additions & 84 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,37 @@
<meta charset="UTF-8">
<title>Pricing Data</title>
<style>
/* Styles for the search box and table */
body {
font-family: Arial, sans-serif;
}

.search-container {
text-align: center;
margin-top: 20px;
}

.search-input {
padding: 8px;
margin-right: 5px;
}

.search-button {
padding: 8px 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}

.search-button:hover {
background-color: #45a049;
}

table {
border-collapse: collapse;
width: 100%;
width: 80%;
margin: 20px auto;
}

th, td {
Expand All @@ -27,103 +55,30 @@
background-color: salmon;
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pricing Data</title>
<style>
/* ... (existing CSS styles) ... */
</style>
<script>
// JavaScript logic here
async function fetchPricingData(date) {
try {
const response = await fetch(`pricing_data_${date}.json`);
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching data:', error);
}
// Fetch pricing data based on date (similar to previous examples)
}

async function fetchItemNames() {
try {
const response = await fetch('items.txt');
const text = await response.text();
const lines = text.split('\n');
const itemNames = {};
lines.slice(1).forEach(line => {
const [entry, name] = line.split(',');
itemNames[entry] = name.trim();
});
return itemNames;
} catch (error) {
console.error('Error fetching item names:', error);
}
// Fetch item names from items.txt (similar to previous examples)
}

function createTable(data, itemNames) {
const table = document.createElement('table');

// Create table header
const headerRow = table.insertRow();
const dates = Object.keys(data);
dates.forEach(date => {
const headerCell = document.createElement('th');
headerCell.textContent = date;
headerRow.appendChild(headerCell);
});

// Create table body
const items = Object.values(data);
const rowCount = items.reduce((max, arr) => Math.max(max, arr.length), 0);
for (let i = 0; i < rowCount; i++) {
const row = table.insertRow();
items.forEach((item, index) => {
const cell = row.insertCell();

if (index === 0 && item[i]) {
const itemId = item[i].pricing_data[0]?.itemId;
const itemName = itemNames[itemId] || 'Unknown';
cell.textContent = itemName;
} else if (item[i]) {
const pricingData = item[i].pricing_data;
if (pricingData) {
const previousPrice = pricingData[i - 1]?.marketValue || 0;
const currentPrice = pricingData[i]?.marketValue || 0;
cell.textContent = currentPrice;

if (currentPrice > previousPrice) {
cell.classList.add('increase');
} else if (currentPrice < previousPrice) {
cell.classList.add('decrease');
}
}
}
});
}

return table;
// Generate table with pricing data and color coding (similar to previous examples)
}

async function displayPricingData(dates) {
const data = {};
for (const date of dates) {
const pricingData = await fetchPricingData(date);
data[date] = pricingData;
}

const itemNames = await fetchItemNames();

const container = document.getElementById('pricing-container');
container.innerHTML = '';
const table = createTable(data, itemNames);
container.appendChild(table);
async function displayPricingData(searchTerm) {
// Logic to display pricing data based on search term (similar to previous examples)
}
</script>
</head>
<body>
<button onclick="displayPricingData(['2023-12-21', '2023-12-22', '2023-12-23'])">Show Pricing Data</button>
<div class="search-container">
<input type="text" id="searchInput" class="search-input" placeholder="Search by Item ID or Name">
<button onclick="displayPricingData(document.getElementById('searchInput').value.trim())" class="search-button">Search</button>
</div>
<div id="pricing-container"></div>
</body>
</html>

0 comments on commit afcbc36

Please sign in to comment.