fix concurency issue at load (#762)

This commit is contained in:
Gergely Mészáros, Ph.D 2022-03-30 20:14:51 +02:00 committed by GitHub
parent 79b7df1c95
commit 4b10b60c69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 25 deletions

43
main.js
View file

@ -172,29 +172,32 @@ landmass.append("rect").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr
oceanPattern.append("rect").attr("fill", "url(#oceanic)").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight); oceanPattern.append("rect").attr("fill", "url(#oceanic)").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
oceanLayers.append("rect").attr("id", "oceanBase").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight); oceanLayers.append("rect").attr("id", "oceanBase").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
if (!location.hostname) { document.addEventListener("DOMContentLoaded", () => {
const wiki = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Run-FMG-locally"; if (!location.hostname) {
alertMessage.innerHTML = `Fantasy Map Generator cannot run serverless. const wiki = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Run-FMG-locally";
Follow the <a href="${wiki}" target="_blank">instructions</a> on how you can easily run a local web-server`; alertMessage.innerHTML = `Fantasy Map Generator cannot run serverless.
Follow the <a href="${wiki}" target="_blank">instructions</a> on how you can easily run a local web-server`;
$("#alert").dialog({ $("#alert").dialog({
resizable: false, resizable: false,
title: "Loading error", title: "Loading error",
width: "28em", width: "28em",
position: {my: "center center-4em", at: "center", of: "svg"}, position: {my: "center center-4em", at: "center", of: "svg"},
buttons: { buttons: {
OK: function () { OK: function () {
$(this).dialog("close"); $(this).dialog("close");
}
} }
} });
});
d3.select("#loading-text").transition().duration(1000).style("opacity", 0); d3.select("#loading-text").transition().duration(1000).style("opacity", 0);
d3.select("#init-rose").transition().duration(4000).style("opacity", 0); d3.select("#init-rose").transition().duration(4000).style("opacity", 0);
} else { } else {
hideLoading(); hideLoading();
checkLoadParameters(); checkLoadParameters();
} }
restoreDefaultEvents(); // apply default viewbox events
});
function hideLoading() { function hideLoading() {
d3.select("#loading").transition().duration(4000).style("opacity", 0); d3.select("#loading").transition().duration(4000).style("opacity", 0);

View file

@ -2,7 +2,6 @@
"use strict"; "use strict";
modules.editors = true; modules.editors = true;
restoreDefaultEvents(); // apply default viewbox events on load
// restore default viewbox events // restore default viewbox events
function restoreDefaultEvents() { function restoreDefaultEvents() {
@ -478,14 +477,14 @@ function createPicker() {
.attr("height", 20) .attr("height", 20)
.on("mousemove", () => tip("Color value in different color spaces. Edit to change")); .on("mousemove", () => tip("Color value in different color spaces. Edit to change"));
const html = ` const html = `
<label style="margin-right: 6px">HSL: <label style="margin-right: 6px">HSL:
<input type="number" id="pickerHSL_H" data-space="hsl" min=0 max=360 value="231">, <input type="number" id="pickerHSL_H" data-space="hsl" min=0 max=360 value="231">,
<input type="number" id="pickerHSL_S" data-space="hsl" min=0 max=100 value="70">, <input type="number" id="pickerHSL_S" data-space="hsl" min=0 max=100 value="70">,
<input type="number" id="pickerHSL_L" data-space="hsl" min=0 max=100 value="70"> <input type="number" id="pickerHSL_L" data-space="hsl" min=0 max=100 value="70">
</label> </label>
<label style="margin-right: 6px">RGB: <label style="margin-right: 6px">RGB:
<input type="number" id="pickerRGB_R" data-space="rgb" min=0 max=255 value="125">, <input type="number" id="pickerRGB_R" data-space="rgb" min=0 max=255 value="125">,
<input type="number" id="pickerRGB_G" data-space="rgb" min=0 max=255 value="142">, <input type="number" id="pickerRGB_G" data-space="rgb" min=0 max=255 value="142">,
<input type="number" id="pickerRGB_B" data-space="rgb" min=0 max=255 value="232"> <input type="number" id="pickerRGB_B" data-space="rgb" min=0 max=255 value="232">
</label> </label>
<label>HEX: <input type="text" id="pickerHEX" data-space="hex" style="width:42px" autocorrect="off" spellcheck="false" value="#7d8ee8"></label>`; <label>HEX: <input type="text" id="pickerHEX" data-space="hex" style="width:42px" autocorrect="off" spellcheck="false" value="#7d8ee8"></label>`;