Skip to content

Commit

Permalink
Merge pull request #14 from Qaw/master
Browse files Browse the repository at this point in the history
Add v11 compatibility, remove v10 warnings, fix minor error on select custom location
  • Loading branch information
HadaIonut authored Dec 15, 2023
2 parents 30387e7 + b3ae8cd commit 72483fc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
26 changes: 13 additions & 13 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "EEEG-Importer",
"id": "EEEG-Importer",
"title": "EEEG-Importer",
"description": "A module that allows you to import your cities generated with Eigengrau's Generator into a collection of journal entries.",
"version": "1.1.6",
"minimumCoreVersion": "10",
"compatibleCoreVersion": "10",
"author": "HadaIonut",
"dependencies": [
"version": "1.1.8",
"compatibility": {
"minimum": "10",
"verified": "11"
},

"authors": [
{
"name": "HadaIonut"
}
],
"esmodules": [
"/scripts/module.js"
],
"styles": [
"/styles/module.css"
],
"esmodules": ["/scripts/module.js"],
"styles": ["/styles/module.css"],
"languages": [
{
"lang": "en",
Expand All @@ -24,5 +24,5 @@
],
"url": "https://github.com/HadaIonut/EEEG-importer",
"manifest": "https://github.com/HadaIonut/EEEG-importer/releases/latest/download/module.json",
"download": "https://github.com/HadaIonut/EEEG-importer/releases/download/1.1.6/module.zip"
"download": "https://github.com/HadaIonut/EEEG-importer/releases/download/1.1.8/module.zip"
}
7 changes: 0 additions & 7 deletions scripts/lib/ImportWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ const prepareDisplayName = (folder) => {
return prepareDisplayName(game.folders.get(folder?.parent?.id)) + '/' + folder?.name;
}

const isFoundry8 = () => {
const foundryVersion = game.data.version;
return foundryVersion >= '0.8.0' && foundryVersion < '0.9.0';
}

export default class ImportWindow extends Application {

static get defaultOptions() {
Expand All @@ -31,8 +26,6 @@ export default class ImportWindow extends Application {
const locationSelector = html.find("#customLocation");
const locationSelectorActors = html.find('#customLocationActor');

const folders = isFoundry8() ? game.folders : game.folders.entries;

game.folders.forEach((folder) => {
if (folder.type === 'JournalEntry')
locationSelector.append(new Option(prepareDisplayName(folder), folder.id));
Expand Down
28 changes: 20 additions & 8 deletions scripts/module.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import ImportWindow from "./lib/ImportWindow.js";

Hooks.on("renderSidebarTab", async (app, html) => {
// Version 11
if (foundry.utils.isNewerVersion(game.release.generation, 10)) {
if (app?.id === "journal") {
createButton(html);
}
}
// Version 10
else if (foundry.utils.isNewerVersion(game.release.generation, 9)) {
if (app?.options?.id === "journal") {
let buttonDiv = $("<div class='action-buttons header-actions flexrow'></div>");
let button = $("<button class='import-markdown'><i class='fas fa-file-import'></i>EEEG Import</button>");
button.on('click', ()=> {
new ImportWindow().render(true);
});
buttonDiv.append(button);
html.find(".header-actions").after(buttonDiv);
createButton(html);
}
})
}
});

function createButton(html) {
let buttonDiv = $("<div class='action-buttons header-actions flexrow'></div>");
let button = $("<button class='import-markdown'><i class='fas fa-file-import'></i>EEEG Import</button>");
button.on("click", () => {
new ImportWindow().render(true);
});
buttonDiv.append(button);
html.find(".header-actions").after(buttonDiv);
}
2 changes: 0 additions & 2 deletions templates/importer.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
<label for="customLocation" class="inputDescriptor">Target folder for NPCs: </label>
<select name="customLocation" id="customLocation" class="locationsSelect">
<option value="default"> Default </option>
<option value="null"> Main Page </option>
</select>
</div>
<div id="customLocationDivActors" class="selectorDiv importWindowDiv">
<label for="customLocationActor" class="inputDescriptor">Target folder for actors: </label>
<select name="customLocation" id="customLocationActor" class="locationsSelect">
<option value="default"> Default </option>
<option value="null"> Main Page </option>
</select>
</div>
<div class="inputDescriptor importWindowDiv">Import text</div>
Expand Down

0 comments on commit 72483fc

Please sign in to comment.