Skip to content

Commit

Permalink
Merge pull request #109 from jrconway3/improved-credits
Browse files Browse the repository at this point in the history
Improved the Way Credits Work To Be Able to Support Directories Instead of Requiring Every Individual Image
  • Loading branch information
sanderfrenken committed Mar 18, 2024
2 parents a665813 + af1a854 commit 2a826d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sources/chargen.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,25 @@ $(document).ready(function() {

function getCreditFor(fileName) {
if (fileName !== "") {
let prospect = '';
let prospectPath = '';
let prospectFile = '';
for (let creditEntry of parsedCredits) {
var creditPath = creditEntry.substring(0, creditEntry.indexOf(','));
if (fileName.startsWith(creditPath) && (creditPath.length > prospectPath.length)) {
prospect = creditEntry;
prospectPath = creditPath;
prospectFile = fileName;
}
if (creditEntry.startsWith(fileName)) {
return creditEntry;
}
};

// Found closest match!
if (prospect !== '') {
return prospect.replace(prospectPath, prospectFile);
}
}
}

Expand Down

0 comments on commit 2a826d7

Please sign in to comment.