This commit is contained in:
Azgaar 2020-06-23 02:29:39 +03:00
parent f14ca97fb4
commit f424f242da
7 changed files with 231 additions and 212 deletions

View file

@ -937,7 +937,7 @@ function parseLoadedData(data) {
if (version < 1.3) {
// v 1.3 added global options object
const winds = options.slice(); // previostly wnd was saved in settings[19]
const winds = options.slice(); // previostly wind was saved in settings[19]
const year = rand(100, 2000);
const era = Names.getBaseShort(P(.7) ? 1 : rand(nameBases.length)) + " Era";
const eraShort = era[0] + "E";
@ -1047,6 +1047,11 @@ function parseLoadedData(data) {
}()
changeMapSize();
// set options
yearInput.value = options.year;
eraInput.value = options.era;
if (window.restoreDefaultEvents) restoreDefaultEvents();
focusOn(); // based on searchParams focus on point, cell or burg
invokeActiveZooming();

View file

@ -5,6 +5,18 @@ function editNotes(id, name) {
select.options.length = 0;
for (const note of notes) {select.options.add(new Option(note.id, note.id));}
// initiate pell (html editor)
const editor = Pell.init({
element: document.getElementById("notesText"),
onChange: html => {
const id = document.getElementById("notesSelect").value;
const note = notes.find(note => note.id === id);
if (!note) return;
note.legend = html;
showNote(note);
}
});
// select an object
if (notes.length || id) {
if (!id) id = notes[0].id;
@ -17,18 +29,18 @@ function editNotes(id, name) {
}
select.value = id;
notesName.value = note.name;
notesText.value = note.legend;
editor.content.innerHTML = note.legend;
showNote(note);
} else {
const value = "There are no added notes. Click on element (e.g. label) and add a free text note";
document.getElementById("notesText").value = value;
editor.content.innerHTML = "There are no added notes. Click on element (e.g. label) and add a free text note";
document.getElementById("notesName").value = "";
}
// open a dialog
$("#notesEditor").dialog({
title: "Notes Editor", minWidth: "40em",
position: {my: "center", at: "center", of: "svg"}
position: {my: "center", at: "center", of: "svg"},
close: () => notesText.innerHTML = ""
});
if (modules.editNotes) return;
@ -37,7 +49,6 @@ function editNotes(id, name) {
// add listeners
document.getElementById("notesSelect").addEventListener("change", changeObject);
document.getElementById("notesName").addEventListener("input", changeName);
document.getElementById("notesText").addEventListener("input", changeText);
document.getElementById("notesPin").addEventListener("click", () => options.pinNotes = !options.pinNotes);
document.getElementById("notesFocus").addEventListener("click", validateHighlightElement);
document.getElementById("notesDownload").addEventListener("click", downloadLegends);
@ -55,7 +66,7 @@ function editNotes(id, name) {
const note = notes.find(note => note.id === this.value);
if (!note) return;
notesName.value = note.name;
notesText.value = note.legend;
editor.content.innerHTML = note.legend;
}
function changeName() {
@ -66,14 +77,6 @@ function editNotes(id, name) {
showNote(note);
}
function changeText() {
const id = document.getElementById("notesSelect").value;
const note = notes.find(note => note.id === id);
if (!note) return;
note.legend = this.value;
showNote(note);
}
function validateHighlightElement() {
const select = document.getElementById("notesSelect");
const element = document.getElementById(select.value);

View file

@ -602,10 +602,10 @@ void function() {
const prompt = document.getElementById("prompt");
const form = prompt.querySelector("#promptForm");
window.prompt = function(promptTest = "Please provide an input", options = {default:1, step:.01, min:0, max:100}, callback) {
window.prompt = function(promptText = "Please provide an input", options = {default:1, step:.01, min:0, max:100}, callback) {
if (options.default === undefined) {console.error("Prompt: options object does not have default value defined"); return;}
const input = prompt.querySelector("#promptInput");
prompt.querySelector("#promptTest").innerHTML = promptTest;
prompt.querySelector("#promptText").innerHTML = promptText;
const type = typeof(options.default) === "number" ? "number" : "text";
input.type = type;
if (options.step !== undefined) input.step = options.step;