/** * The Strikes card on an account's page: every strike with what it was for, who gave it and whether it still counts; * giving one by hand and revoking one (staff with the permissions). Players see their own, read-only. */ (function () { 'use strict'; var card = document.getElementById('strikesCard'); if (!card) return; // A player's own card is read-only and doesn't name staff; staff see their own like anyone else's. // Revoking needs the server's say that this account may be managed (on your own account: self_moderation). var accountId = card.dataset.account, isSelf = !!card.dataset.self && !DASH.can('accounts_notes'), canManage = !!card.dataset.canManage; var url = isSelf ? '/api/account/strikes' : '/api/accounts/' + accountId + '/strikes'; function render(d) { document.getElementById('strikeCount').textContent = d.active; document.getElementById('strikeCount').className = 'badge rounded-pill align-middle text-bg-' + (d.active ? 'danger' : 'secondary'); document.getElementById('strikeHelp').textContent = (isSelf ? 'Given by staff when something you made was rejected or a score removed and they decided it deserved one. ' : '') + (d.expiryDays ? 'Strikes count for ' + d.expiryDays + ' days; older ones stay listed.' : 'Strikes count until revoked.'); document.getElementById('strikeList').innerHTML = d.strikes.map(function (s) { var where = s.character_id !== '0' ? ' ยท ' + fmt.character(s.character_id, s.character_name) : ''; var state = s.revoked_at ? fmt.badge('Revoked', 'secondary') : s.counts ? fmt.badge('Counts', 'danger') : fmt.badge('Expired', 'secondary'); var revoke = d.canRevoke && canManage && !s.revoked_at ? ' ' : ''; return '