DeletedUser19087
Vendég
A régi helyett írtam, az csak a futtatáskor látható térképen jelenítette meg a falvak pontjait. Ennél viszont a térkép mozgatása után is kiírja. Az előző elvileg külön tudta szinezni a pontszámokat megadott játékos, barbár, vagy klán szerint. Ennek nem láttam értelmét beépíteni, hiszen ezeket a térképen be tudjuk állítani magunknak. Emiatt a pontszámot úgy állítottam be, hogy ne takarja el ezeket a színjelzéseket.
Használata:
- futtatod a térképen
Használata:
- futtatod a térképen
Kód beillesztése:
javascript:
$("#content_value").find("h2").after(createHTML());
$("#playervillage").on("click", function() {
player = "player"
indicate()
})
$("#barbarianvillage").on("click", function() {
player = "barbarian"
indicate()
})
$("#allvillage").on("click", function() {
player = "all"
indicate()
})
$("#checkbox").on("change", function(event) {
if (event.delegateTarget.checked) {
checked = "true"
} else {
checked = "false"
}
})
$(window).on("hashchange", function() {
indicate()
})
$("#button, #checkbox, #allvillage, #playervillage, #barbarianvillage").on("mouseenter", function(event) {
if (event.target.id == "button") {
$(this).css("box-shadow", "0 0 5px 3px red");
} else if (event.target.id == "checkbox") {
$(this).css("box-shadow", "0 0 5px 3px blue");
}
})
$("#button, #checkbox, #allvillage, #playervillage, #barbarianvillage").on("mouseleave", function() {
$(this).removeAttr("style");
})
function style(left, top, color) {
var style = {
"position": "absolute",
"z-index": "5",
"left": left + "px",
"top": top + "px",
"font-size": "8pt",
"font-weight": "bold",
"background-color": "#ffffff",
"opacity": ".7",
"width": "42px",
"height": "12px",
"margin-left": "0px",
"margin-top": "0px",
"display": "block",
"color": color,
"text-align": "center"
}
return style;
}
function createHTML() {
content = `<input type="radio" id="allvillage" name="name"></input>
<label for="allvillage">Minden falu pontját mutasd</label>
<br>
<input type="radio" id="playervillage" name="name"></input>
<label for="playervillage">Csak játékos falvak pontjait mutasd</label>
<br>
<input type="radio" id="barbarianvillage" name="name"></input>
<label for="barbarianvillage">Csak barbár és bónusz falvak pontjait mutasd</label>
<br><br>
<input type="checkbox" id="checkbox"></input>
<label for="checkbox"> adatok tárolása</label>
<button type="button" id="button" onclick="removeKeys()">Adatok törlése</button>`;
return content;
}
function run() {
if ($("#checkbox")[0].checked && checkbox) {
localStorage.setItem(value.id, value.points.replace(".", ""));
}
// upper number
var top = parseInt($(`#map_village_${value.id}`).css('top'), 10) + 10;
var left = parseInt($(`#map_village_${value.id}`).css('left'), 10) + 10;
var color = "black";
$(`#map_village_${value.id}`).after($(`<div id=öreg_map_hilight_${value.id}>${value.points}</div>`));
$(`#öreg_map_hilight_${value.id}`).css(style(left, top, color));
// lower number
if (localStorage.getItem(value.id) != null) {
different = Number(value.points.replace(".", "")) - Number(localStorage.getItem(value.id));
top += 12;
left = left;
if (different > 0) {
color = "green";
} else if(different == 0) {
color = "grey";
} else {
color = "red";
}
$(`#map_village_${value.id}`).after($(`<div id=öreg_map_hilights_${value.id}>${different}</div>`));
$(`#öreg_map_hilights_${value.id}`).css(style(left, top, color));
}
}
function removeKeys() {
var arr = [];
for (var i = 0; i < localStorage.length; i++){
if (Number(localStorage.key(i)) >= 0) {
arr.push(localStorage.key(i));
}
}
for (var i = 0; i < arr.length; i++) {
localStorage.removeItem(arr[i]);
}
UI.SuccessMessage("A mentett adatok törlésre kerültek.",2000);
}
function indicate() {
$("div [id*=öreg_map_hilight_]").remove();
$("div [id*=öreg_map_hilights_]").remove();
var hossz = $("div [id*=map_village_]");
for (var i = 0; i < hossz.length; i++) {
key = hossz[i].id.split("_");
value = TWMap.villages[TWMap.villageKey[key[2]]];
if (player == "all") {
run()
} else if (value.owner == "0" && player == "barbarian") {
run()
} else if (value.owner != "0" && player == "player") {
run()
}
}
}
void(0);
Utoljára egy moderátor szerkesztette: