From 402dc85bbb057717e756011e9a1f425b9294ad31 Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Tue, 19 Mar 2024 12:12:46 +0000 Subject: [PATCH 1/2] Split plugins into modules; Add keyvalue_dictionary --- lib/mapp.mjs | 2 +- lib/plugins.mjs | 192 ---------------------------- lib/plugins/_plugins.mjs | 27 ++++ lib/plugins/admin.mjs | 16 +++ lib/plugins/fullscreen.mjs | 25 ++++ lib/plugins/keyvalue_dictionary.mjs | 44 +++++++ lib/plugins/locator.mjs | 17 +++ lib/plugins/login.mjs | 18 +++ lib/plugins/svg_templates.mjs | 21 +++ lib/plugins/zoomBtn.mjs | 39 ++++++ lib/plugins/zoomToArea.mjs | 45 +++++++ 11 files changed, 253 insertions(+), 193 deletions(-) delete mode 100644 lib/plugins.mjs create mode 100644 lib/plugins/_plugins.mjs create mode 100644 lib/plugins/admin.mjs create mode 100644 lib/plugins/fullscreen.mjs create mode 100644 lib/plugins/keyvalue_dictionary.mjs create mode 100644 lib/plugins/locator.mjs create mode 100644 lib/plugins/login.mjs create mode 100644 lib/plugins/svg_templates.mjs create mode 100644 lib/plugins/zoomBtn.mjs create mode 100644 lib/plugins/zoomToArea.mjs diff --git a/lib/mapp.mjs b/lib/mapp.mjs index c166c17817..af1457fefd 100644 --- a/lib/mapp.mjs +++ b/lib/mapp.mjs @@ -24,7 +24,7 @@ import location from './location/_location.mjs' import Mapview from './mapview/_mapview.mjs' -import * as plugins from './plugins.mjs' +import plugins from './plugins/_plugins.mjs' hooks.parse(); diff --git a/lib/plugins.mjs b/lib/plugins.mjs deleted file mode 100644 index e4f7b34ceb..0000000000 --- a/lib/plugins.mjs +++ /dev/null @@ -1,192 +0,0 @@ -/** -## mapp.plugins{} - -@module plugins -*/ - -export async function svg_templates(plugin, mapview) { - - if (typeof mapp.utils.svgSymbols.templates !== 'object') { - mapp.utils.svgSymbols.templates = {} - } - - // Iterate through svg_templates entries. - const promises = Object.entries(plugin).map(entry => { - - // Fetch entry value. - return fetch(entry[1]) - .then(response => response.text()) - .then(svgString => { - - // Assign parsed svgString as entry key to templates object. - mapp.utils.svgSymbols.templates[entry[0]] = svgString - }) - }) - - await Promise.all(promises) -} - -export function locator(plugin, mapview) { - - const btnColumn = document.getElementById('mapButton'); - - // the btnColumn element only exist in the default mapp view. - if (!btnColumn) return; - - const btn = mapp.utils.html.node` -