summaryrefslogtreecommitdiff
path: root/resources/js/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r--resources/js/ui.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js
index 2d34a2a..6884e14 100644
--- a/resources/js/ui.js
+++ b/resources/js/ui.js
@@ -40,6 +40,8 @@ const Template = {
menuSettings: document.querySelector('#tpl___menu__settings'),
+ loadPopup: document.querySelector('#tpl___load-popup'),
+
storyPopup: document.querySelector('#tpl___story__popup'),
};
@@ -1366,6 +1368,7 @@ const UI = {
openJournalMenu () {
const popup = UI.createPopup();
+ popup.id = 'popup___journal';
const journal = UI.createTemplate(Template.menuJournal);
journal.querySelector('[data-template-slot="save"]').addEventListener('click', UI.wrapCallback(() => {
@@ -1392,6 +1395,26 @@ const UI = {
UI.drawPopup(popup);
},
+ /**
+ * @param {Function[]} loadActions
+ */
+ async showLoading (loadActions) {
+ const popup = UI.createPopup();
+ const template = UI.createTemplate(Template.loadPopup);
+ popup.querySelector('[data-template-slot="content"]').append(template);
+ UI.drawPopup(popup);
+
+ for (const idx in loadActions) {
+ await loadActions[idx]();
+ const percent = ((parseInt(idx) + 1) / loadActions.length) * 100;
+
+ template.querySelector('[data-template-slot="progress"]').value = percent;
+ template.querySelector('[data-template-slot="progress.text"]').textContent = `${percent.toFixed(2)}%`;
+ }
+
+ popup.remove();
+ },
+
/* Menu - Party */
@@ -1707,7 +1730,8 @@ const UI = {
dialog.querySelector('[data-template-slot="saveData"]').value.trim()
);
- document.querySelectorAll('.popup__overlay').forEach((element) => element.remove())
+ popup.remove();
+ document.querySelector('#popup___journal').remove();
}));
popup.querySelector('.popup').appendChild(dialog);