Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Evaluate(a, b)
- {
- return document.evaluate('//div[@id="' + a + '"]//*[@id="' + b + '"]/text()', document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent;
- }
- function GetMed(a)
- {
- return numberWithCommas(Evaluate(a, "cost")) / numberWithCommas(Evaluate(a, "description").substring(1));
- }
- function numberWithCommas(x) {
- return parseFloat(x.replace(new RegExp(',', 'g'), ''));
- }
- function MarkBest()
- {
- var buildings = ["tent-building", "shack-building", "cabin-building", "cottage-building", "house-building", "manor-building", "dorm-building", "apartment-building", "condo-building"];
- var bestIndex = 0;
- for (i = 0; i < buildings.length; ++i) {
- var priceForOneGPS = document.getElementById(buildings[i] + "_gps-price");
- if (priceForOneGPS === null) {
- priceForOneGPS = document.createElement('div');
- priceForOneGPS.setAttribute("id", buildings[i] + "_gps-price");
- }
- priceForOneGPS.innerHTML = GetMed(buildings[i]);
- document.getElementById(buildings[i]).appendChild(priceForOneGPS);
- document.getElementById(buildings[i]).style.color = "red";
- if (i == 0) {
- bestIndex = i;
- }
- else {
- if (GetMed(buildings[i]) < GetMed(buildings[bestIndex])) {
- bestIndex = i;
- }
- }
- }
- document.getElementById(buildings[bestIndex]).style.color = "green";
- }
- MarkBest();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement