From b3d4c616f59ad2519f3a0b77e3b47d6571cd2486 Mon Sep 17 00:00:00 2001
From: historia <[not public]>
Date: Thu, 9 Jul 2026 19:29:17 -0400
Subject: feat: message actions are now sequences of messages with settable
delays
---
internal/admin/static/intereditor.js | 168 +++++++++++++++++++++++------------
1 file changed, 110 insertions(+), 58 deletions(-)
(limited to 'internal/admin/static/intereditor.js')
diff --git a/internal/admin/static/intereditor.js b/internal/admin/static/intereditor.js
index b46c456..5cf39a1 100644
--- a/internal/admin/static/intereditor.js
+++ b/internal/admin/static/intereditor.js
@@ -5,7 +5,7 @@
// ── Condition leaf types ──
var IE_COND_TYPES = [
- {type: 'global_flag', label: 'Global Flag', hint: 'world flag name'},
+ {type: 'global_flag', label: 'Global Flag', hint: 'global flag name'},
{type: 'player_flag', label: 'Player Flag', hint: 'player flag name'},
{type: 'has_item', label: 'Has Item', hint: 'item ID'},
{type: 'min_credits', label: 'Min Credits', hint: 'amount'},
@@ -218,11 +218,18 @@ function ie_collectAct(rootEl) {
if (!rootEl) return null;
var r = {};
- // Message (rolled into action)
- var msgEl = rootEl.querySelector('.ie-act-msg');
- if (msgEl) {
- var msg = msgEl.value.trim();
- r.message = msg;
+ // Messages — collected from the extendable delay+message rows.
+ var msgsKv = rootEl.querySelector('.ie-act-kv[data-ie-act-key="messages"]');
+ if (msgsKv) {
+ var list = [];
+ msgsKv.querySelectorAll('.ie-kv-row').forEach(function(row) {
+ var delayEl = row.querySelector('.ie-act-msg-delay');
+ var msgEl = row.querySelector('.ie-act-msg');
+ var d = delayEl ? parseInt(delayEl.value) || 0 : 0;
+ var m = msgEl ? msgEl.value.trim() : '';
+ list.push({ message: m, delay: d });
+ });
+ r.messages = list;
}
// KV-type effects — include the map even when empty (as long as the
@@ -233,6 +240,7 @@ function ie_collectAct(rootEl) {
rootEl.querySelectorAll('.ie-act-kv').forEach(function(kvEl) {
var key = kvEl.getAttribute('data-ie-act-key');
if (!key) return;
+ if (key === 'messages') return;
var map = {};
kvEl.querySelectorAll('.ie-kv-row').forEach(function(row) {
var kEl = row.querySelector('.ie-kv-key');
@@ -291,8 +299,6 @@ function ie_syncAllInteractions(data, secs) {
var act = ie_collectAct(actRoot);
if (act) data[p][idx].action = act;
else delete data[p][idx].action;
- // Clear any legacy top-level message on sync.
- delete data[p][idx].message;
}
});
});
@@ -410,7 +416,7 @@ function _ie_renderLeaf(leafType, leafVal, leafSub, not, secId, secPath, idx, gp
var h = '
';
h += '' + esc(label) + '';
if (isSearch) {
- h += '
';
+ h += '
';
h += '';
h += '';
h += '
';
@@ -420,7 +426,8 @@ function _ie_renderLeaf(leafType, leafVal, leafSub, not, secId, secPath, idx, gp
h += '';
}
if (leafType === 'player_flag' || leafType === 'global_flag') {
- h += '';
+ h += '=';
+ h += '';
}
h += '';
h += '';
@@ -434,14 +441,32 @@ function ie_renderAct(actionObj, scope, secId, idx, secPath) {
var hasAny = false;
var rows = '';
- // Message
- var msg = (actionObj && actionObj.message !== undefined && actionObj.message !== null) ? String(actionObj.message) : '';
- var msgPresent = actionObj && Object.prototype.hasOwnProperty.call(actionObj, 'message');
- if (msgPresent) {
+ // Messages — extendable list of {delay, message} entries. Mirrors the KV-section
+ // pattern: when the 'messages' key is present we render the section with rows
+ // and an internal + Add; when it goes away (last row removed) the section
+ // disappears and the addbar + Add Message button reappears. There is no
+ // section-level X.
+ var msgsPresent = actionObj && Object.prototype.hasOwnProperty.call(actionObj, 'messages') && Array.isArray(actionObj.messages);
+ if (msgsPresent) {
+ var msgs = actionObj.messages;
hasAny = true;
- rows += '