✈️ Dynamic Torn Travel Forecaster

async function calculateTornTravel() { var item = document.getElementById("tornItem").value; var country = document.getElementById("tornCountry").value; var output = document.getElementById("trackerOutput"); if (!country) { alert("Please select a destination country!"); return; } if (!item) { alert("Please select an item from the dropdown list!"); return; } output.style.display = "block"; output.style.color = "#ffaa66"; output.innerHTML = "⏳ Fetching live data from YATA/API..."; try { // Example endpoint structure for fetching live item/market/stock data // Replace with your actual YATA or backend endpoint URL let response = await fetch(`https://api.yata.yt/v1/bazaar/${country}`); // or your specific data source let data = await response.json(); // Parse the actual stock quantity returned by the live data feed let stockQty = data[item] ? data[item].quantity : 0; let burnRate = data[item] ? data[item].burnRate : 30; // Dynamic burn rate if provided, or calculated var baseMinutes = baseTimes[country]; var methods = [ { name: "Standard Flight", mod: 1.0 }, { name: "Airstrip Private", mod: 0.7 }, { name: "WLT Private Jet", mod: 0.5 }, { name: "BCT Speed Run", mod: 0.3 } ]; var outputText = "--- LIVE YATA FORECAST ---\n"; var overallSafe = false; methods.forEach(m => { var flightTime = Math.round(baseMinutes * m.mod); var consumption = flightTime * burnRate; var remaining = stockQty - consumption; var status = "❌ Out"; if (stockQty > 0 && remaining > 0) { status = (remaining < (stockQty * 0.25)) ? "⚠️ Risky" : "✅ Safe"; if (status === "✅ Safe") overallSafe = true; } outputText += m.name.padEnd(16, ' ') + ": " + status + " (" + flightTime + "m) [Stock: " + stockQty + "]\n"; }); output.innerHTML = outputText; // Dynamic theme styling update if (overallSafe) { output.style.color = "#00ff66"; output.style.borderLeftColor = "#00ff66"; } else { output.style.color = "#ff3333"; output.style.borderLeftColor = "#ff3333"; } } catch (error) { output.innerHTML = "❌ Error connecting to data source: " + error.message; output.style.color = "#ff3333"; } }

Privacy Preference Center