Merge pull request #23 from r-o-b-o-t-o/fix/add-on-loads

This commit is contained in:
Axel Cocat 2022-05-14 23:58:11 +02:00 committed by GitHub
commit c95ad80e3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 742 additions and 728 deletions

View file

@ -14,7 +14,7 @@ config.json
.env
# Log files
*.log
logs/
# Git folder
.git/

View file

@ -69,6 +69,7 @@
</div>
<script type="application/javascript">
$(window).on("load", () => {
let achievementsData = {};
let $openCategory;
const $achievementTemplate = $("#achievement-template").detach().removeAttr("id");
@ -257,4 +258,5 @@
makeProgressBars();
openSummary();
});
});
</script>

View file

@ -36,7 +36,9 @@
</div>
<script type="application/javascript">
$(window).on("load", () => {
{{#each arenaTeams}}
createArenaEmblem({{this.type}}, {{{JSONstringify this.emblem}}}, $(".arena-team[data-team-id={{this.id}}] .arena-emblem")[0]);
{{/each}}
});
</script>

View file

@ -3,7 +3,6 @@
<script type="application/javascript">
const aowow_tooltips = { "renamelinks": true, };
</script>
<script type="application/javascript" src="{{aowow}}/static/widgets/power.js"></script>
{{> character-header }}
@ -47,62 +46,10 @@
</div>
</div>
<div style="display: none;">
<!-- Hackfix for aowow's tooltip opening when the page loads -->
<a href="{{aowow}}/?spell=10"></a>
</div>
<script type="application/javascript">
$(window).on("load", () => {
const talentsData = {{{JSONstringify data}}};
for (let spec = 0; spec < 2; ++spec) {
const $spec = $(`#talents-spec-${spec}`);
let nbLearned = 0;
for (const tree of talentsData.trees) {
const learned = {};
for (const talent of talentsData.talents[spec]) {
for (const s of tree.spells) {
const ranks = [s.spellRank0, s.spellRank1, s.spellRank2, s.spellRank3, s.spellRank4];
const idx = ranks.indexOf(talent);
if (idx === -1) {
continue;
}
learned[s.id] = {
spell: s,
rank: idx + 1,
};
++nbLearned;
break;
}
}
const $tree = $("#talent-tree-template")
.clone(false)
.removeAttr("id")
.appendTo($spec);
$tree.find(".header .image").attr("src", `{{aowow}}/static/images/wow/icons/medium/${tree.icon}.jpg`);
$tree.find(".header .name").text(tree.name);
createTree(tree, learned, $tree[0]);
}
if (nbLearned === 0 && spec !== 0) {
$spec.addClass("hidden");
$("#spec-links").hide();
continue;
}
const $glyphs = $spec.find(".glyphs");
for (const spell of talentsData.glyphs[spec]) {
const $a = $("<a>");
$a.attr("href", `{{aowow}}?spell=${spell}`);
$glyphs.append($a);
$glyphs.append("<br>");
}
$glyphs.parent().appendTo($spec);
}
function createTree(data, learnedTalents, container) {
const $columns = $(container).find(".col");
let points = 0;
@ -219,6 +166,55 @@
$(container).append($arrow);
}
function main() {
for (let spec = 0; spec < 2; ++spec) {
const $spec = $(`#talents-spec-${spec}`);
let nbLearned = 0;
for (const tree of talentsData.trees) {
const learned = {};
for (const talent of talentsData.talents[spec]) {
for (const s of tree.spells) {
const ranks = [s.spellRank0, s.spellRank1, s.spellRank2, s.spellRank3, s.spellRank4];
const idx = ranks.indexOf(talent);
if (idx === -1) {
continue;
}
learned[s.id] = {
spell: s,
rank: idx + 1,
};
++nbLearned;
break;
}
}
const $tree = $("#talent-tree-template")
.clone(false)
.removeAttr("id")
.appendTo($spec);
$tree.find(".header .image").attr("src", `{{aowow}}/static/images/wow/icons/medium/${tree.icon}.jpg`);
$tree.find(".header .name").text(tree.name);
createTree(tree, learned, $tree[0]);
}
if (nbLearned === 0 && spec !== 0) {
$spec.addClass("hidden");
$("#spec-links").hide();
continue;
}
const $glyphs = $spec.find(".glyphs");
for (const spell of talentsData.glyphs[spec]) {
const $a = $("<a>");
$a.attr("href", `{{aowow}}?spell=${spell}`);
$glyphs.append($a);
$glyphs.append("<br>");
}
$glyphs.parent().appendTo($spec);
}
$("#link-spec-0").on("click", () => {
$("#talents-spec-0").removeClass("hidden");
$("#talents-spec-1").addClass("hidden");
@ -232,4 +228,11 @@
if (location.hash === "#1") {
$("#link-spec-1").click();
}
$("<script>")
.attr("src", "{{aowow}}/static/widgets/power.js")
.appendTo("body");
}
main();
});
</script>

View file

@ -71,6 +71,7 @@
</div>
<script type="application/javascript">
$(window).on("load", () => {
const $model = $("#model");
const $itemSlotTemplate = $("#item-slot-template").detach().removeAttr("id");
const $mountTemplate = $("#mount-template").detach().removeAttr("id");
@ -306,6 +307,7 @@
viewer.options.background = file;
viewer.renderer.loadBackground();
viewer.options.contentPath = originalContentPath;
viewer.options.background = undefined;
}
if (charData.mounts.length === 0) {
@ -413,4 +415,5 @@
windowWidth = newWidth;
onResize();
}, 500));
});
</script>

View file

@ -59,6 +59,7 @@
</table>
<script type="application/javascript">
$(window).on("load", () => {
createGuildEmblem({{{ JSONstringify emblem }}}, $(".emblem-container .guild-emblem")[0]);
dt = $("#members").DataTable({
@ -98,4 +99,5 @@
},
order: [[1, "asc"]],
});
});
</script>

View file

@ -34,6 +34,7 @@
</table>
<script type="application/javascript">
$(window).on("load", () => {
let dt;
$("#select-realm").on("change", () => {
@ -79,4 +80,5 @@
details: true,
},
});
});
</script>