From 1bedf06969b8ab8e51dd4301a0831200df5c8f59 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 13 Jul 2026 18:36:29 -0400 Subject: feat(admin): tooltips added for confusing fields, hide more optional fields with buttons --- internal/admin/static/cardeditor.js | 15 +++++++++------ 1 file changed, 9 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 6a8cda7..cf3a8b7 100644 --- a/internal/admin/static/cardeditor.js +++ b/internal/admin/static/cardeditor.js @@ -301,7 +301,7 @@ function ced_updateSearchHighlight(results) { // ---- Generic field renderer (used by all card-based editors) ---- function ced_renderField(sec, f, data, idx, subPath, optStyle, cardPathFn, fieldIDFn, getValFn) { - var key = f[0], label = f[1], type = f[2], hint = f[3], wide = f[4], showIf = f[5], searchEntity = f[6]; + var key = f[0], label = f[1], type = f[2], hint = f[3], wide = f[4], showIf = f[5], searchEntity = f[6], tooltip = f[7]; var fp = subPath ? subPath + '.' + key : key; var fid = fieldIDFn(sec, fp, idx); var val; @@ -343,8 +343,13 @@ function ced_renderField(sec, f, data, idx, subPath, optStyle, cardPathFn, field return ''; } + function lblSpan() { + if (tooltip) return '' + esc(label) + ''; + return '' + esc(label) + ''; + } + if (type === 'checkbox') { - return wrap('obj-field obj-check', ' ' + esc(label) + ''); + return wrap('obj-field obj-check', ' ' + lblSpan()); } if (type === 'json') { var jstr = typeof val === 'object' ? JSON.stringify(val) : String(val); @@ -356,7 +361,7 @@ function ced_renderField(sec, f, data, idx, subPath, optStyle, cardPathFn, field } if (type === 'select') { if (hint && hint.indexOf('dyn:') === 0) { - var inner = '' + esc(label) + '' + ced_buildDynamicSelect(fid, dpAttr, val, hint.substring(4)); + var inner = lblSpan() + ced_buildDynamicSelect(fid, dpAttr, val, hint.substring(4)); return wrap('obj-field', inner); } var opts = hint ? hint.split('|') : []; @@ -672,13 +677,11 @@ function ced_collectAtkType(widgetID) { 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 += '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