From 3274b700a6f655b8ecc3505e814ac5d782ae6ffe Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 13 Jul 2026 16:10:40 -0400 Subject: feat(admin): reminder text for color tags and item variables, improve placeholder text --- internal/admin/static/cardeditor.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'internal/admin/static/cardeditor.js') diff --git a/internal/admin/static/cardeditor.js b/internal/admin/static/cardeditor.js index f32ea7e..6a8cda7 100644 --- a/internal/admin/static/cardeditor.js +++ b/internal/admin/static/cardeditor.js @@ -42,7 +42,7 @@ function ced_collectFieldValue(el, type) { if (type === 'checkbox') return el.checked; if (type === 'select') return el.value; if (type === 'search') return el.value; - if (type === 'number') { var n = parseFloat(el.value); return isNaN(n) ? 0 : n; } + if (type === 'number') { var n = parseFloat(el.value); return isNaN(n) ? '' : n; } if (type === 'json') { var raw = el.value.trim(); if (!raw) return null; @@ -86,7 +86,7 @@ function ced_addKVRow(cardID, subKey) { if (!el) return; var row = document.createElement('div'); row.className = 'obj-kv-row'; - row.innerHTML = ''; + row.innerHTML = ''; el.appendChild(row); } @@ -125,7 +125,7 @@ function ced_addKVSearchRow(cardID, subKey, entity) { if (!el) return; var row = document.createElement('div'); row.className = 'obj-kv-row'; - row.innerHTML = ''; + row.innerHTML = ''; el.appendChild(row); ced_setupSearchFields(row); } @@ -398,7 +398,7 @@ function ced_addSubRow(sec, subKey, dataRef, cardPathFn) { var st = (sec.subtables || []).find(function(s) { return s.key === subKey; }); if (st) { st.fields.forEach(function(f) { - empty[f[0]] = f[2] === 'checkbox' ? false : (f[2] === 'number' ? 0 : ''); + empty[f[0]] = f[2] === 'checkbox' ? false : ''; }); } arr.push(empty); @@ -579,8 +579,18 @@ function ced_cleanOutput(obj) { } else if (typeof val === 'object' && val !== null && !Array.isArray(val)) { ced_cleanOutput(val); if (Object.keys(val).length === 0) delete obj[key]; - } else if (Array.isArray(val) && val.length === 0) { - delete obj[key]; + } else if (Array.isArray(val)) { + if (val.length === 0) { + delete obj[key]; + } else { + for (var i = val.length - 1; i >= 0; i--) { + if (typeof val[i] === 'object' && val[i] !== null) { + ced_cleanOutput(val[i]); + if (Object.keys(val[i]).length === 0) val.splice(i, 1); + } + } + if (val.length === 0) delete obj[key]; + } } } } @@ -658,3 +668,18 @@ function ced_collectAtkType(widgetID) { if (sci && sci.checked) out.push('science'); return out; } + +function ced_renderTagHelp(type) { + var h = '
'; + if (type === 'color') { + h += 'Name is displayed without an article (e.g. "John Smith" instead of "a John Smith")
'; + h += 'Cannot be attacked by players. Combat level hidden
'; + h += 'Text fields support color tags: {NN}text{/} where NN is a hex color index (00–FF).'; + } else if (type === 'crafting') { + h += 'Message fields support template variables:
%i1 = first ingredient name
%i2 = second ingredient name
%n = output item name.
Color tags are also supported: {NN}text{/} where NN is a hex color index (00–FF).'; + } else if (type === 'gather') { + h += 'Message fields support template variables: {name} = object name.
Color tags are also supported: {NN}text{/} where NN is a hex color index (00–FF).'; + } + h += '
'; + return h; +} -- cgit v1.2.3