mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: notes to update on deletion
This commit is contained in:
parent
98c971b3c4
commit
9332eb7b38
3 changed files with 32 additions and 33 deletions
|
|
@ -8015,7 +8015,7 @@
|
||||||
<script defer src="modules/ui/relief-editor.js"></script>
|
<script defer src="modules/ui/relief-editor.js"></script>
|
||||||
<script defer src="modules/ui/burg-editor.js"></script>
|
<script defer src="modules/ui/burg-editor.js"></script>
|
||||||
<script defer src="modules/ui/units-editor.js"></script>
|
<script defer src="modules/ui/units-editor.js"></script>
|
||||||
<script defer src="modules/ui/notes-editor.js?v=1.89.03"></script>
|
<script defer src="modules/ui/notes-editor.js?v=1.93.09"></script>
|
||||||
<script defer src="modules/ui/diplomacy-editor.js?v=1.88.04"></script>
|
<script defer src="modules/ui/diplomacy-editor.js?v=1.88.04"></script>
|
||||||
<script defer src="modules/ui/zones-editor.js"></script>
|
<script defer src="modules/ui/zones-editor.js"></script>
|
||||||
<script defer src="modules/ui/burgs-overview.js?v=1.89.20"></script>
|
<script defer src="modules/ui/burgs-overview.js?v=1.89.20"></script>
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,14 @@
|
||||||
|
|
||||||
function editNotes(id, name) {
|
function editNotes(id, name) {
|
||||||
// elements
|
// elements
|
||||||
const notesLegend = document.getElementById("notesLegend");
|
const notesLegend = byId("notesLegend");
|
||||||
const notesName = document.getElementById("notesName");
|
const notesName = byId("notesName");
|
||||||
const notesSelect = document.getElementById("notesSelect");
|
const notesSelect = byId("notesSelect");
|
||||||
const notesPin = document.getElementById("notesPin");
|
const notesPin = byId("notesPin");
|
||||||
|
|
||||||
// update list of objects
|
// update list of objects
|
||||||
notesSelect.options.length = 0;
|
notesSelect.options.length = 0;
|
||||||
for (const note of notes) {
|
notes.forEach(({id}) => notesSelect.options.add(new Option(id, id)));
|
||||||
notesSelect.options.add(new Option(note.id, note.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// update pin notes icon
|
// update pin notes icon
|
||||||
const notesArePinned = options.pinNotes;
|
const notesArePinned = options.pinNotes;
|
||||||
|
|
@ -22,7 +20,7 @@ function editNotes(id, name) {
|
||||||
if (notes.length || id) {
|
if (notes.length || id) {
|
||||||
if (!id) id = notes[0].id;
|
if (!id) id = notes[0].id;
|
||||||
let note = notes.find(note => note.id === id);
|
let note = notes.find(note => note.id === id);
|
||||||
if (note === undefined) {
|
if (!note) {
|
||||||
if (!name) name = id;
|
if (!name) name = id;
|
||||||
note = {id, name, legend: ""};
|
note = {id, name, legend: ""};
|
||||||
notes.push(note);
|
notes.push(note);
|
||||||
|
|
@ -52,17 +50,17 @@ function editNotes(id, name) {
|
||||||
modules.editNotes = true;
|
modules.editNotes = true;
|
||||||
|
|
||||||
// add listeners
|
// add listeners
|
||||||
document.getElementById("notesSelect").addEventListener("change", changeElement);
|
byId("notesSelect").addEventListener("change", changeElement);
|
||||||
document.getElementById("notesName").addEventListener("input", changeName);
|
byId("notesName").addEventListener("input", changeName);
|
||||||
document.getElementById("notesLegend").addEventListener("blur", updateLegend);
|
byId("notesLegend").addEventListener("blur", updateLegend);
|
||||||
document.getElementById("notesPin").addEventListener("click", toggleNotesPin);
|
byId("notesPin").addEventListener("click", toggleNotesPin);
|
||||||
document.getElementById("notesFocus").addEventListener("click", validateHighlightElement);
|
byId("notesFocus").addEventListener("click", validateHighlightElement);
|
||||||
document.getElementById("notesDownload").addEventListener("click", downloadLegends);
|
byId("notesDownload").addEventListener("click", downloadLegends);
|
||||||
document.getElementById("notesUpload").addEventListener("click", () => legendsToLoad.click());
|
byId("notesUpload").addEventListener("click", () => legendsToLoad.click());
|
||||||
document.getElementById("legendsToLoad").addEventListener("change", function () {
|
byId("legendsToLoad").addEventListener("change", function () {
|
||||||
uploadFile(this, uploadLegends);
|
uploadFile(this, uploadLegends);
|
||||||
});
|
});
|
||||||
document.getElementById("notesRemove").addEventListener("click", triggerNotesRemove);
|
byId("notesRemove").addEventListener("click", triggerNotesRemove);
|
||||||
|
|
||||||
async function initEditor() {
|
async function initEditor() {
|
||||||
if (!window.tinymce) {
|
if (!window.tinymce) {
|
||||||
|
|
@ -108,8 +106,8 @@ function editNotes(id, name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateNotesBox(note) {
|
function updateNotesBox(note) {
|
||||||
document.getElementById("notesHeader").innerHTML = note.name;
|
byId("notesHeader").innerHTML = note.name;
|
||||||
document.getElementById("notesBody").innerHTML = note.legend;
|
byId("notesBody").innerHTML = note.legend;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeElement() {
|
function changeElement() {
|
||||||
|
|
@ -131,7 +129,7 @@ function editNotes(id, name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateHighlightElement() {
|
function validateHighlightElement() {
|
||||||
const element = document.getElementById(notesSelect.value);
|
const element = byId(notesSelect.value);
|
||||||
if (element) return highlightElement(element, 3);
|
if (element) return highlightElement(element, 3);
|
||||||
|
|
||||||
confirmationDialog({
|
confirmationDialog({
|
||||||
|
|
@ -157,6 +155,18 @@ function editNotes(id, name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerNotesRemove() {
|
function triggerNotesRemove() {
|
||||||
|
function removeLegend() {
|
||||||
|
notes = notes.filter(({id}) => id !== notesSelect.value);
|
||||||
|
|
||||||
|
if (!notes.length) {
|
||||||
|
$("#notesEditor").dialog("close");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeEditor();
|
||||||
|
editNotes(notes[0].id, notes[0].name);
|
||||||
|
}
|
||||||
|
|
||||||
confirmationDialog({
|
confirmationDialog({
|
||||||
title: "Remove note",
|
title: "Remove note",
|
||||||
message: "Are you sure you want to remove the selected note? There is no way to undo this action",
|
message: "Are you sure you want to remove the selected note? There is no way to undo this action",
|
||||||
|
|
@ -165,17 +175,6 @@ function editNotes(id, name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeLegend() {
|
|
||||||
const index = notes.findIndex(n => n.id === notesSelect.value);
|
|
||||||
notes.splice(index, 1);
|
|
||||||
notesSelect.options.length = 0;
|
|
||||||
if (!notes.length) {
|
|
||||||
$("#notesEditor").dialog("close");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
editNotes(notes[0].id, notes[0].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleNotesPin() {
|
function toggleNotesPin() {
|
||||||
options.pinNotes = !options.pinNotes;
|
options.pinNotes = !options.pinNotes;
|
||||||
this.classList.toggle("pressed");
|
this.classList.toggle("pressed");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// version and caching control
|
// version and caching control
|
||||||
const version = "1.93.08"; // generator version, update each time
|
const version = "1.93.09"; // generator version, update each time
|
||||||
|
|
||||||
{
|
{
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue