Skip to content

Commit

Permalink
search
Browse files Browse the repository at this point in the history
  • Loading branch information
jopeek committed Sep 17, 2023
1 parent 1fb9b64 commit 61c967c
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 45 deletions.
80 changes: 60 additions & 20 deletions css/dndbeyond-character-sheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
margin: 10px 0 10px 10px;
}

.dndbcs.sheet.actor .spellcasting-ability select {
margin: 0;
}

.dndbcs.sheet.actor.character .sheet-header img.profile {
flex: 0 0 205px;
max-width: 205px;
Expand Down Expand Up @@ -681,6 +685,9 @@
}

.dndbcs.sheet.actor .inventory-list .inventory-header h3,
.dndbcs.sheet.actor .actions-list .inventory-header h3,
.dndbcs.sheet.actor .features-list .inventory-header h3,
.dndbcs.sheet.actor .spellbook-list .inventory-header h3,
.dndbcs.sheet .items-list .items-header h3,
.dndbcs.sheet.actor .effects-list .items-header h3,
.dndbcs.sheet.actor.character .characteristics label {
Expand All @@ -707,23 +714,39 @@


/* width */
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar, .dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar {
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar,
.dndbcs.sheet.actor.character ol.actions-list::-webkit-scrollbar,
.dndbcs.sheet.actor.character ol.features-list::-webkit-scrollbar,
.dndbcs.sheet.actor.character ol.spellbook-list::-webkit-scrollbar,
.dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar {
width: 4px;
}

/* Track */
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar-track, .dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar-track {
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar-track,
.dndbcs.sheet.actor.character ol.actions-list::-webkit-scrollbar-track,
.dndbcs.sheet.actor.character ol.features-list::-webkit-scrollbar-track,
.dndbcs.sheet.actor.character ol.spellbook-list::-webkit-scrollbar-track,
.dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar-track {
background: transparent;
}

/* Handle */
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar-thumb, .dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar-thumb {
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar-thumb,
.dndbcs.sheet.actor.character ol.actions-list::-webkit-scrollbar-thumb,
.dndbcs.sheet.actor.character ol.features-list::-webkit-scrollbar-thumb,
.dndbcs.sheet.actor.character ol.spellbook-list::-webkit-scrollbar-thumb,
.dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar-thumb {
background: #b5b3a4;
border-color: #b5b3a4;
}

/* Handle on hover */
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar-thumb:hover, .dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar-thumb:hover {
.dndbcs.sheet.actor.character ol.inventory-list::-webkit-scrollbar-thumb:hover,
.dndbcs.sheet.actor.character ol.actions-list::-webkit-scrollbar-thumb:hover,
.dndbcs.sheet.actor.character ol.features-list::-webkit-scrollbar-thumb:hover,
.dndbcs.sheet.actor.character ol.spellbook-list::-webkit-scrollbar-thumb:hover,
.dndbcs.sheet.actor.character ol.effects-list::-webkit-scrollbar-thumb:hover {
background: #c53131;
border-color: #c53131;
}
Expand Down Expand Up @@ -755,7 +778,8 @@
.dndbcs.sheet.actor .inventory-filters ol.currency.flexrow {
justify-content: flex-end;
flex: 1;
margin: 10px 0;
margin: 0;
padding-top: 14px;
}

.dndbcs.sheet.actor .inventory-filters .currency label.denomination.pp {
Expand Down Expand Up @@ -799,7 +823,6 @@
color: #7a7971;
text-transform: uppercase;
font-size: 12px;
margin: 18px 0 0 0;
}

.dndbcs.sheet.actor .form-group.spellcasting-ability label {
Expand Down Expand Up @@ -892,7 +915,11 @@
display: none;
}

.dndbcs.sheet.actor .inventory-list .inventory-header, .dndbcs.sheet .items-list .items-header {
.dndbcs.sheet.actor .inventory-list .inventory-header,
.dndbcs.sheet.actor .actions-list .inventory-header,
.dndbcs.sheet.actor .features-list .inventory-header,
.dndbcs.sheet.actor .spellbook-list .inventory-header,
.dndbcs.sheet .items-list .items-header {
background: none;
border: 0px;
border-bottom: 1px solid #c9c7b8;
Expand All @@ -902,17 +929,25 @@
padding: 6px 0 4px 0;
}

.dndbcs.sheet.actor .inventory-list .item-list {
/* border-top: 1px solid #c9c7b8; */
.dndbcs.sheet .features-list .item-detail input[type="text"] {
width: 10px;
}

.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .item-weight,
.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .item-detail,
.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .spell-school,
.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .spell-action,
.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .spell-target,
.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .spell-slots,
.dndbcs.sheet.actor .inventory-list li.inventory-header.flexrow .spell-comps,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .item-weight,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .item-detail,
.dndbcs.sheet.actor .features-list li.inventory-header.flexrow .item-detail,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .spell-school,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .spell-action,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .spell-target,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .spell-slots,
.dndbcs.sheet.actor .actions-list li.inventory-header.flexrow .spell-comps,
.dndbcs.sheet.actor .spellbook-list li.inventory-header.flexrow .spell-school,
.dndbcs.sheet.actor .spellbook-list li.inventory-header.flexrow .spell-action,
.dndbcs.sheet.actor .spellbook-list li.inventory-header.flexrow .spell-target,
.dndbcs.sheet.actor .spellbook-list li.inventory-header.flexrow .spell-slots,
.dndbcs.sheet.actor .spellbook-list li.inventory-header.flexrow .spell-comps,
.dndbcs.sheet .items-list .items-header {
border-left: 0px;
border-right: 0px;
Expand All @@ -923,22 +958,27 @@
}

.dndbcs.sheet.actor.character .spellbook .item-controls .toggle-prepared.prepared,
.dndbcs.sheet.actor .inventory-list .item .item-name i.attuned {
.dndbcs.sheet.actor .inventory-list .item .item-name i.attuned,
.dndbcs.sheet.actor .actions-list .item .item-name i.attuned {
color: #c53131;
}

.dndbcs.sheet.actor .inventory-list .item .item-name i.attunement-required {
.dndbcs.sheet.actor .inventory-list .item .item-name i.attunement-required,
.dndbcs.sheet.actor .actions-list .item .item-name i.attunement-required {
color: #7a7971;
}

.dndbcs.sheet.actor .inventory-filters i.fas.fa-fist-raised,
.dndbcs.sheet.actor .inventory-filters i.fas.fa-magic,
.dndbcs.sheet.actor .inventory-filters i.fas.fa-th-large {
.dndbcs.sheet.actor .spellbook-filters i.fas.fa-fist-raised,
.dndbcs.sheet.actor .spellbook-filters i.fas.fa-magic,
.dndbcs.sheet.actor .spellbook-filters i.fas.fa-th-large {
margin: 20px 10px 0 10px;
color: #c53131;
}

.dndbcs.sheet.actor .inventory-list .item:last-child {
.dndbcs.sheet.actor .inventory-list .item:last-child,
.dndbcs.sheet.actor .actions-list .item:last-child,
.dndbcs.sheet.actor .features-list .item:last-child,
.dndbcs.sheet.actor .spellbook-list .item:last-child {
border-bottom: 1px solid #c9c7b8;
}

Expand Down
69 changes: 67 additions & 2 deletions dndbeyond-character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,22 @@ class DNDBeyondCharacterSheet5e extends dnd5e.applications.actor.ActorSheet5eCha
}





/* -------------------------------------------- */

activateListeners(html) {
let searchInput = html.find(".filter-search input");
searchInput.on("input", function() {
filterInventoryList(this, html);
});
}


async getData() {
const sheetData = await super.getData();

// Temporary HP
console.log("dndb", sheetData);
let hp = sheetData.system.attributes.hp;
Expand Down Expand Up @@ -80,6 +88,47 @@ class DNDBeyondCharacterSheet5e extends dnd5e.applications.actor.ActorSheet5eCha

}

async function filterInventoryList(input, html) {

let id = $(input).attr("id");
let value = $(input).val().toLowerCase();
let searchTarget;

switch (id) {
case "inventory-search":
searchTarget = html.find(
".inventory-list:not(.actions-list):not(.spellbook-list):not(.features-list) .item-name.rollable"
);
break;
case "actions-search":
searchTarget = html.find(
".actions-list:not(.spellbook-list):not(.features-list) .item-name.rollable"
);
break;
case "spellbook-search":
searchTarget = html.find(
".spellbook-list .item-name.rollable"
);
break;
case "features-search":
searchTarget = html.find(".features-list .item-name.rollable");
break;
}

searchTarget.each(function() {
let itemName = $(this).text().toLowerCase().trim();
console.log(itemName, itemName.indexOf(value.toLowerCase()));

if (itemName.indexOf(value.toLowerCase()) >= 0) {
$(this).closest(".item").removeClass("filtered").show();
} else {
$(this).closest(".item").addClass("filtered").hide();
}

});

}

Hooks.once('init', async function () {

Handlebars.registerHelper('ifeq', function (a, b, options) {
Expand Down Expand Up @@ -121,4 +170,20 @@ Hooks.on('ready', () => {
console.log("DNDBeyond-Character-Sheet | Better Rolls 5e module not installed - no big deal, carry on!");
}

// searchInput.on("blur", async function() {
// console.log("here?");
// let id = $(this).attr("id"), value = $(this).val();
// switch (id) {
// case "item-search":
// await actor2.setFlag(CONSTANTS.MODULE_ID, "item-search", value);
// break;
// case "spell-search":
// await actor2.setFlag(CONSTANTS.MODULE_ID, "spell-search", value);
// break;
// case "feat-search":
// await actor2.setFlag(CONSTANTS.MODULE_ID, "feat-search", value);
// break;
// }
// });

});
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maximum": "11"
},
"url": "https://github.com/jopeek/fvtt-dndbeyond-character-sheet",
"version": "11.230.3",
"version": "11.230.4",
"esmodules": [
"/dndbeyond-character-sheet.js"
],
Expand Down
Loading

0 comments on commit 61c967c

Please sign in to comment.