0.4.1f 11-Feb-2021
Initial spell loading working, without preload limitv0.3.1-spetzel2020
parent
4bee393f39
commit
f1a050d2ad
|
@ -25,7 +25,7 @@
|
||||||
const CMPBrowser = {
|
const CMPBrowser = {
|
||||||
MODULE_NAME : "compendium-browser",
|
MODULE_NAME : "compendium-browser",
|
||||||
MODULE_VERSION : "0.4.1",
|
MODULE_VERSION : "0.4.1",
|
||||||
PRELOAD : 100, //How many items, spells, or NPCs you load at once (to minimize memory usage)
|
PRELOAD : 9999, //How many items, spells, or NPCs you load at once (to minimize memory usage) - ignored for now
|
||||||
VISIBLE_ROWS : 50 //Plug for maximum rows visible in window - fetch more when actual < this
|
VISIBLE_ROWS : 50 //Plug for maximum rows visible in window - fetch more when actual < this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ class CompendiumBrowser extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
spells : this.items?.spells,
|
spells : this.items,
|
||||||
spellFilters : this.spellFilters,
|
spellFilters : this.spellFilters,
|
||||||
showSpellBrowser : (game.user.isGM || this.settings.allowSpellBrowser),
|
showSpellBrowser : (game.user.isGM || this.settings.allowSpellBrowser),
|
||||||
feats : this.items?.feats,
|
feats : this.items?.feats,
|
||||||
|
@ -547,7 +547,7 @@ class CompendiumBrowser extends Application {
|
||||||
ol[0].append(element);
|
ol[0].append(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
html.find('.spell-browser select[name=sortorder]').trigger('change');
|
this.triggerSortSpells(html);
|
||||||
|
|
||||||
// sort feat list in place
|
// sort feat list in place
|
||||||
html.find('.feat-browser select[name=sortorder]').on('change', ev => {
|
html.find('.feat-browser select[name=sortorder]').on('change', ev => {
|
||||||
|
@ -837,16 +837,14 @@ class CompendiumBrowser extends Application {
|
||||||
const items = html.find("ul#CBSpells");
|
const items = html.find("ul#CBSpells");
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
this.renderSpellData().then(newSpellsHTML => {
|
this.renderSpellData().then(newSpellsHTML => {
|
||||||
const replacement = document.createElement("ul");
|
items[0].innerHTML = newSpellsHTML;
|
||||||
replacement.setAttribute("id","CBSpells");
|
//Re-sort before setting up lazy loading
|
||||||
replacement.innerHTML = newSpellsHTML;
|
this.triggerSortSpells(html);
|
||||||
items[0].parentNode.replaceChild(replacement, items[0]);
|
|
||||||
|
|
||||||
//Lazy load images
|
//Lazy load images
|
||||||
$(replacement).find("img").each((i, img) => observer.observe(img));
|
$(items).find("img").each((i,img) => observer.observe(img));
|
||||||
|
|
||||||
//Reactivate listeners for clicking and dragging
|
//Reactivate listeners for clicking and dragging
|
||||||
this.activateItemListListeners($(replacement));
|
this.activateItemListListeners($(items));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,6 +857,12 @@ class CompendiumBrowser extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
//SORTING
|
//SORTING
|
||||||
|
triggerSortSpells(html) {
|
||||||
|
html.find('.spell-browser select[name=sortorder]').trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sortSpells(list, byName) {
|
sortSpells(list, byName) {
|
||||||
if (byName) {
|
if (byName) {
|
||||||
list.sort((a, b) => {
|
list.sort((a, b) => {
|
||||||
|
@ -1167,8 +1171,8 @@ class CompendiumBrowser extends Application {
|
||||||
type: Number,
|
type: Number,
|
||||||
range: { // If range is specified, the resulting setting will be a range slider
|
range: { // If range is specified, the resulting setting will be a range slider
|
||||||
min: 20,
|
min: 20,
|
||||||
max: 500,
|
max: 9999,
|
||||||
step: 10
|
step: 100
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue