// ================================================================ // Command Log Component // ================================================================ window.renderLog = function(cmds) { const el = document.getElementById('log-content'); if (!cmds.length) { el.innerHTML = '

No commands sent yet.

'; return; } const rows = cmds.map(cmd => { const p = typeof cmd.payload === 'string' ? JSON.parse(cmd.payload) : cmd.payload; let desc = ''; if (cmd.type === 'build') { const nameGr = window.BUILDING_NAMES_GR?.[p.building_id] || p.building_id; desc = `Build: ${nameGr}`; } else if (cmd.type === 'recruit') { const nameGr = window.UNIT_NAMES_GR?.[p.unit_id] || p.unit_id; desc = `Recruit: ${p.amount}x ${nameGr}`; } else if (cmd.type === 'market_offer') { desc = `Market: ${p.offer} ${p.offer_type} ➞ ${p.demand} ${p.demand_type}`; } const statusClass = `status-${cmd.status}`; const cancelBtn = ``; const timeStr = new Date(cmd.created_at + 'Z').toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }); return ` #${cmd.id}
${timeStr} ${cmd.town_name || cmd.town_id} ${desc} ${cmd.status} ${cmd.result_msg || ''} ${cancelBtn} `; }).join(''); el.innerHTML = `${rows}
#TownCommandStatusResult
`; };