Diff -- /var/www/vhosts/3dshawn.com/crm.3dshawn.com/TEMPLATES/cf_support.html
Diff
/var/www/vhosts/3dshawn.com/crm.3dshawn.com/TEMPLATES/cf_support.html
added on local at 2026-07-11 18:32:02
Added
+0
lines
Removed
-0
lines
Context
590
unchanged
Blobs
from ac0a8124b126
to ac0a8124b126
to ac0a8124b126
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.| 1 | 1 | <!-- ===================================================================== |
| 2 | 2 | CUSTOMER SUPPORT CENTER |
| 3 | 3 | /support.cgi -- contact's view of their support threads with ContactForge. |
| 4 | 4 | |
| 5 | 5 | Two-pane layout: |
| 6 | 6 | Left -- scrollable thread list with unread badges |
| 7 | 7 | Right -- active conversation + reply form (or empty state) |
| 8 | 8 | |
| 9 | 9 | Async messaging only. Live-chat UI was removed; the conversation |
| 10 | 10 | polls for new admin replies every 12s. |
| 11 | 11 | |
| 12 | 12 | Theme-aware via var(--col-*) so this works under every dashboard |
| 13 | 13 | color theme + user-side wrapper. |
| 14 | 14 | ===================================================================== --> |
| 15 | 15 | <style> |
| 16 | 16 | .sc-page { display:grid;grid-template-columns:340px 1fr;gap:20px;height:calc(100vh - 100px);min-height:560px;padding:0;margin:0 -8px; } |
| 17 | 17 | .sc-pane { background:var(--col-surface-1);border:1px solid var(--col-border);border-radius:14px;overflow:hidden;display:flex;flex-direction:column;min-height:0; } |
| 18 | 18 | |
| 19 | 19 | /* Left pane: thread list */ |
| 20 | 20 | .sc-list-head { padding:16px 18px;border-bottom:1px solid var(--col-border);display:flex;align-items:center;justify-content:space-between;gap:10px;flex-shrink:0; } |
| 21 | 21 | .sc-list-title { font-family:var(--font-display);font-size:18px;color:var(--col-text);margin:0; } |
| 22 | 22 | .sc-list-sub { font-size:11px;color:var(--col-text-3);letter-spacing:1px;text-transform:uppercase; } |
| 23 | 23 | .sc-new-btn { padding:8px 14px;background:linear-gradient(135deg,var(--col-accent),var(--col-accent-deep));color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:700;text-decoration:none;display:inline-flex;align-items:center;gap:6px;cursor:pointer; } |
| 24 | 24 | .sc-new-btn:hover { filter:brightness(1.08); } |
| 25 | 25 | .sc-list { flex:1;overflow-y:auto;padding:8px; } |
| 26 | 26 | .sc-list-empty { padding:50px 22px;text-align:center;color:var(--col-text-3);font-size:13px;line-height:1.6; } |
| 27 | 27 | /* Compact one-line thread rows -- everything on a single horizontal |
| 28 | 28 | flex line so the inbox fits 3-4x more threads per viewport. Same |
| 29 | 29 | anatomy as the admin support inbox so the two surfaces feel like |
| 30 | 30 | mirrors of each other. */ |
| 31 | 31 | .sc-thread { display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:8px;text-decoration:none;color:inherit;margin-bottom:2px;border:1px solid transparent;transition:background 0.15s,border-color 0.15s;min-height:32px; } |
| 32 | 32 | .sc-thread:hover { background:var(--col-surface-2);border-color:var(--col-border); } |
| 33 | 33 | .sc-thread.is-active { background:var(--col-accent-glow);border-color:var(--col-accent); } |
| 34 | 34 | .sc-thread-subj { font-size:13px;font-weight:600;color:var(--col-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.3;flex:1;min-width:0; } |
| 35 | 35 | .sc-thread-time { font-size:11px;color:var(--col-text-3);flex-shrink:0; } |
| 36 | 36 | .sc-pill { padding:1px 7px;border-radius:10px;font-size:10px;font-weight:700;letter-spacing:0.4px;flex-shrink:0; } |
| 37 | 37 | .sc-pill.st-open { background:rgba(59,130,246,0.18);color:#60a5fa;border:1px solid rgba(59,130,246,0.36); } |
| 38 | 38 | .sc-pill.st-waiting { background:rgba(245,158,11,0.15);color:#fbbf24;border:1px solid rgba(245,158,11,0.32); } |
| 39 | 39 | .sc-pill.st-resolved { background:rgba(34,197,94,0.15);color:#4ade80;border:1px solid rgba(34,197,94,0.32); } |
| 40 | 40 | .sc-pill.st-closed { background:rgba(148,163,184,0.15);color:#cbd5e1;border:1px solid rgba(148,163,184,0.32); } |
| 41 | 41 | .sc-pill.chat { background:rgba(124,58,237,0.18);color:#c4b5fd;border:1px solid rgba(124,58,237,0.36); } |
| 42 | 42 | .sc-unread { min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:#ef4444;color:#fff;font-size:10px;font-weight:800;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0; } |
| 43 | 43 | |
| 44 | 44 | /* Right pane: active conversation */ |
| 45 | 45 | .sc-conv { display:flex;flex-direction:column;flex:1;min-height:0; } |
| 46 | 46 | .sc-conv-head { padding:14px 20px;border-bottom:1px solid var(--col-border);display:flex;align-items:center;justify-content:space-between;gap:14px;flex-shrink:0; } |
| 47 | 47 | .sc-conv-title { font-family:var(--font-display);font-size:18px;color:var(--col-text);margin:0;display:flex;align-items:center;gap:10px;min-width:0; } |
| 48 | 48 | .sc-conv-title span { overflow:hidden;text-overflow:ellipsis;white-space:nowrap; } |
| 49 | 49 | .sc-conv-actions { display:flex;gap:8px;flex-shrink:0; } |
| 50 | 50 | .sc-btn { padding:7px 12px;background:var(--col-surface-2);border:1px solid var(--col-border-2);color:var(--col-text);border-radius:7px;font-size:12px;font-weight:600;cursor:pointer;font-family:inherit; } |
| 51 | 51 | .sc-btn:hover { background:var(--col-accent-glow);border-color:var(--col-accent); } |
| 52 | 52 | .sc-btn.is-danger { background:rgba(239,68,68,0.12);border-color:rgba(239,68,68,0.4);color:#f87171; } |
| 53 | 53 | .sc-btn.is-danger:hover { background:rgba(239,68,68,0.22); } |
| 54 | 54 | .sc-btn.is-primary { background:linear-gradient(135deg,var(--col-accent),var(--col-accent-deep));border:none;color:#fff; } |
| 55 | 55 | .sc-btn.is-primary:hover { filter:brightness(1.08); } |
| 56 | 56 | |
| 57 | 57 | .sc-stream { flex:1;overflow-y:auto;padding:18px 22px;display:flex;flex-direction:column;gap:14px; } |
| 58 | 58 | |
| 59 | 59 | .sc-msg { display:flex;gap:10px;max-width:78%; } |
| 60 | 60 | .sc-msg.is-customer { margin-left:auto;flex-direction:row-reverse; } |
| 61 | 61 | .sc-msg.is-system { margin:0 auto;max-width:90%; } |
| 62 | 62 | .sc-avatar { width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,var(--col-accent),var(--col-accent-deep));color:#fff;display:flex;align-items:center;justify-content:center;font-family:var(--font-display);font-size:14px;flex-shrink:0; } |
| 63 | 63 | .sc-msg.is-customer .sc-avatar { background:linear-gradient(135deg,#10b981,#059669); } |
| 64 | 64 | .sc-msg.is-system .sc-avatar { background:var(--col-surface-2);color:var(--col-text-3);border:1px solid var(--col-border); } |
| 65 | 65 | .sc-bubble { background:var(--col-surface-2);border:1px solid var(--col-border);border-radius:14px;padding:10px 14px;font-size:13.5px;line-height:1.55;color:var(--col-text); } |
| 66 | 66 | .sc-msg.is-customer .sc-bubble { background:var(--col-accent-glow);border-color:var(--col-accent); } |
| 67 | 67 | .sc-msg.is-system .sc-bubble { background:transparent;border:1px dashed var(--col-border-2);color:var(--col-text-3);font-style:italic;font-size:12.5px;text-align:center; } |
| 68 | 68 | .sc-meta-line { font-size:10.5px;color:var(--col-text-3);margin-top:4px;letter-spacing:0.3px; } |
| 69 | 69 | .sc-msg.is-customer .sc-meta-line { text-align:right; } |
| 70 | 70 | |
| 71 | 71 | .sc-compose { border-top:1px solid var(--col-border);padding:14px 18px;flex-shrink:0;background:var(--col-surface-2); } |
| 72 | 72 | .sc-compose textarea { width:100%;box-sizing:border-box;min-height:60px;max-height:200px;padding:10px 12px;background:var(--col-bg);border:1px solid var(--col-border-2);border-radius:8px;color:var(--col-text);font-family:inherit;font-size:13.5px;resize:vertical; } |
| 73 | 73 | .sc-compose textarea:focus { outline:none;border-color:var(--col-accent); } |
| 74 | 74 | .sc-compose-row { display:flex;justify-content:space-between;align-items:center;margin-top:8px;gap:10px; } |
| 75 | 75 | .sc-compose-hint { font-size:11px;color:var(--col-text-3); } |
| 76 | 76 | |
| 77 | 77 | .sc-invite { padding:12px 16px;margin:12px 22px 0;background:rgba(124,58,237,0.12);border:1px solid rgba(124,58,237,0.4);border-radius:10px;display:flex;align-items:center;justify-content:space-between;gap:14px; } |
| 78 | 78 | .sc-invite-text { font-size:13px;color:var(--col-text); } |
| 79 | 79 | .sc-invite-text strong { color:#c4b5fd; } |
| 80 | 80 | |
| 81 | 81 | .sc-chat-ribbon { padding:10px 16px;margin:12px 22px 0;background:rgba(34,197,94,0.10);border:1px solid rgba(34,197,94,0.4);border-radius:10px;display:flex;align-items:center;justify-content:space-between;gap:14px;font-size:12.5px;color:#4ade80; } |
| 82 | 82 | .sc-chat-ribbon .dot { width:8px;height:8px;border-radius:50%;background:#4ade80;animation:scPulse 1.4s infinite ease-in-out;display:inline-block;margin-right:8px;box-shadow:0 0 8px #4ade80; } |
| 83 | 83 | @keyframes scPulse { 0%, 100% { opacity:1 } 50% { opacity:0.35 } } |
| 84 | 84 | |
| 85 | 85 | .sc-empty { flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:40px;color:var(--col-text-3);text-align:center;gap:14px; } |
| 86 | 86 | .sc-empty h2 { font-family:var(--font-display);font-size:22px;color:var(--col-text);margin:0; } |
| 87 | 87 | .sc-empty p { margin:0;max-width:380px;line-height:1.6;font-size:13.5px; } |
| 88 | 88 | |
| 89 | 89 | /* New-request modal */ |
| 90 | 90 | .sc-modal { position:fixed;inset:0;z-index:1000;background:rgba(3,8,31,0.78);backdrop-filter:blur(6px);display:none;align-items:flex-start;justify-content:center;padding:60px 20px;overflow-y:auto; } |
| 91 | 91 | .sc-modal.is-open { display:flex; } |
| 92 | 92 | .sc-modal-card { max-width:920px;width:100%;background:var(--col-surface-1);border:1px solid var(--col-border);border-radius:14px;padding:30px 34px; } |
| 93 | 93 | .sc-modal-title { font-family:var(--font-display);font-size:26px;color:var(--col-text);margin:0 0 8px; } |
| 94 | 94 | .sc-modal-sub { font-size:12px;letter-spacing:1.5px;text-transform:uppercase;color:var(--col-text-3);margin-bottom:14px; } |
| 95 | 95 | .sc-modal-hint { font-size:13.5px;color:var(--col-text-2);line-height:1.6;margin:0 0 18px;max-width:680px; } |
| 96 | 96 | .sc-modal label { display:block;font-size:12px;font-weight:600;color:var(--col-text-2);margin-bottom:6px;margin-top:14px;letter-spacing:0.3px;text-transform:uppercase; } |
| 97 | 97 | .sc-modal input[type=text], .sc-modal textarea { width:100%;box-sizing:border-box;padding:14px 16px;background:var(--col-bg);border:1px solid var(--col-border-2);border-radius:10px;color:var(--col-text);font-family:inherit;font-size:14.5px;line-height:1.55; } |
| 98 | 98 | .sc-modal input[type=text]:focus, .sc-modal textarea:focus { outline:none;border-color:var(--col-accent);box-shadow:0 0 0 3px rgba(59,130,246,0.18); } |
| 99 | 99 | .sc-modal textarea { min-height:360px;resize:vertical; } |
| 100 | 100 | .sc-modal-actions { display:flex;gap:10px;margin-top:22px;justify-content:flex-end; } |
| 101 | 101 | |
| 102 | 102 | /* Attachment widget: drag/drop + paste + file picker, shared by the |
| 103 | 103 | new-thread modal and the reply form so customers and admins have |
| 104 | 104 | the same upload experience everywhere. */ |
| 105 | 105 | .sup-att-area { margin-top: 12px; } |
| 106 | 106 | .sup-att-strip { display:flex;flex-wrap:wrap;gap:8px;margin-bottom:10px; } |
| 107 | 107 | .sup-att-strip:empty { display:none; } |
| 108 | 108 | .sup-att-thumb { position:relative;width:78px;height:78px;border-radius:8px;overflow:hidden;border:1px solid rgba(255,255,255,0.18);background:rgba(0,0,0,0.30); } |
| 109 | 109 | .sup-att-thumb img { width:100%;height:100%;object-fit:cover;display:block; } |
| 110 | 110 | .sup-att-thumb.is-pending { opacity:0.55; } |
| 111 | 111 | .sup-att-thumb.is-pending::after { content:'';position:absolute;inset:0;background:linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);animation:sup-att-shimmer 1.1s linear infinite; } |
| 112 | 112 | .sup-att-thumb.failed { border-color:#ef4444;opacity:0.7; } |
| 113 | 113 | .sup-att-thumb.failed::after { content:'!';position:absolute;inset:0;display:grid;place-items:center;color:#fff;font-weight:800;background:rgba(239,68,68,0.55); } |
| 114 | 114 | @keyframes sup-att-shimmer { 0% { transform:translateX(-100%); } 100% { transform:translateX(100%); } } |
| 115 | 115 | .sup-att-rm { position:absolute;top:3px;right:3px;width:20px;height:20px;border-radius:50%;background:rgba(0,0,0,0.78);color:#fff;border:none;cursor:pointer;line-height:18px;font-size:16px;padding:0;display:grid;place-items:center; } |
| 116 | 116 | .sup-att-rm:hover { background:#ef4444; } |
| 117 | 117 | .sup-att-controls { display:flex;align-items:center;gap:10px;flex-wrap:wrap; } |
| 118 | 118 | .sup-att-pick { display:inline-flex;align-items:center;gap:6px;padding:7px 13px;background:rgba(255,255,255,0.08);border:1px solid rgba(255,255,255,0.18);color:var(--col-text-2);font-size:12px;font-weight:600;border-radius:8px;cursor:pointer;transition:background 0.15s, color 0.15s, border-color 0.15s; } |
| 119 | 119 | .sup-att-pick:hover { background:rgba(59,130,246,0.18);color:#fff;border-color:rgba(59,130,246,0.55); } |
| 120 | 120 | .sup-att-pick svg { width:14px;height:14px; } |
| 121 | 121 | /* Visually hide the file input but keep it focusable + clickable via |
| 122 | 122 | its parent <label>. display:none would block the file picker on |
| 123 | 123 | some mobile browsers; this positions it out of flow instead. */ |
| 124 | 124 | .sup-att-pick input[type="file"] { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; } |
| 125 | 125 | .sup-att-hint { font-size:11px;color:var(--col-text-3); } |
| 126 | 126 | .sup-att-form.att-drag { outline:2px dashed var(--col-accent);outline-offset:4px;border-radius:12px; } |
| 127 | 127 | /* Live counter chip that appears the moment files are picked, so |
| 128 | 128 | the user gets immediate confirmation even before thumbs render. */ |
| 129 | 129 | .sup-att-count { display:inline-flex;align-items:center;gap:6px;padding:5px 11px;border-radius:999px;font-size:11px;font-weight:700;letter-spacing:0.3px;text-transform:uppercase; } |
| 130 | 130 | .sup-att-count.is-working { background:rgba(245,158,11,0.18);border:1px solid rgba(245,158,11,0.45);color:#fde68a; } |
| 131 | 131 | .sup-att-count.is-ready { background:rgba(16,185,129,0.18);border:1px solid rgba(16,185,129,0.55);color:#6ee7b7; } |
| 132 | 132 | .sup-att-count.is-working::before { content:'';width:8px;height:8px;border-radius:50%;background:#f59e0b;animation:sup-att-blink 1s ease-in-out infinite; } |
| 133 | 133 | .sup-att-count.is-ready::before { content:'\2713';font-weight:800;color:#10b981; } |
| 134 | 134 | @keyframes sup-att-blink { 0%,100% { opacity:1; } 50% { opacity:0.35; } } |
| 135 | 135 | |
| 136 | 136 | /* Inline-rendered attachments inside a message bubble. */ |
| 137 | 137 | .sup-msg-atts { display:flex;flex-wrap:wrap;gap:6px;margin-top:8px; } |
| 138 | 138 | .sup-msg-att { display:block;border-radius:8px;overflow:hidden;border:1px solid rgba(255,255,255,0.15);transition:border-color 0.12s,transform 0.12s; } |
| 139 | 139 | .sup-msg-att:hover { border-color:var(--col-accent);transform:translateY(-1px); } |
| 140 | 140 | .sup-msg-att img { display:block;max-width:280px;max-height:200px;width:auto;height:auto; } |
| 141 | 141 | @media (max-width: 720px) { |
| 142 | 142 | .sc-modal-card { padding:22px 18px; } |
| 143 | 143 | .sc-modal textarea { min-height:240px; } |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | @media (max-width:1000px) { |
| 147 | 147 | .sc-page { grid-template-columns:1fr;height:auto; } |
| 148 | 148 | .sc-pane.sc-left { max-height:340px; } |
| 149 | 149 | } |
| 150 | 150 | </style> |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | <div class="page-head"> |
| 154 | 154 | <div> |
| 155 | 155 | <span class="page-eyebrow"><span class="dot"></span> Support</span> |
| 156 | 156 | <h1 class="page-title">Help & messages</h1> |
| 157 | 157 | <p class="page-subtitle">Send a question to the ContactForge team and we'll reply right here. We aim to respond within one business day.</p> |
| 158 | 158 | </div> |
| 159 | 159 | </div> |
| 160 | 160 | |
| 161 | 161 | [if:$just_opened] |
| 162 | 162 | <div class="banner" style="margin-bottom:18px;background:rgba(34,197,94,0.10);border:1px solid rgba(34,197,94,0.40);color:#4ade80;border-radius:10px;padding:12px 14px"> |
| 163 | 163 | <strong>Request submitted.</strong> A team member will reply here as soon as we can. |
| 164 | 164 | </div> |
| 165 | 165 | [/if] |
| 166 | 166 | |
| 167 | 167 | <div class="sc-page"> |
| 168 | 168 | |
| 169 | 169 | <!-- LEFT: thread list --> |
| 170 | 170 | <div class="sc-pane sc-left"> |
| 171 | 171 | <div class="sc-list-head"> |
| 172 | 172 | <div> |
| 173 | 173 | <div class="sc-list-sub">Your threads</div> |
| 174 | 174 | <h2 class="sc-list-title">$thread_count active</h2> |
| 175 | 175 | </div> |
| 176 | 176 | <button type="button" class="sc-new-btn" data-sc-open="sc-new">+ New</button> |
| 177 | 177 | </div> |
| 178 | 178 | <div class="sc-list"> |
| 179 | 179 | [if:!$has_threads] |
| 180 | 180 | <div class="sc-list-empty"> |
| 181 | 181 | No conversations yet.<br><br> |
| 182 | 182 | <button type="button" class="sc-new-btn" data-sc-open="sc-new">Start your first support request</button> |
| 183 | 183 | </div> |
| 184 | 184 | [/if] |
| 185 | 185 | [if:$has_threads] |
| 186 | 186 | [loop:@threads] |
| 187 | 187 | <a class="sc-thread[if:$loop1.is_active] is-active[/if]" href="/support.cgi?thread_id=$loop1.id" title="$loop1.subject -- $loop1.status_label"> |
| 188 | 188 | <span class="sc-thread-subj">$loop1.subject</span> |
| 189 | 189 | <span class="sc-pill $loop1.status_class">$loop1.status_label</span> |
| 190 | 190 | [if:$loop1.has_unread]<span class="sc-unread">$loop1.unread</span>[/if] |
| 191 | 191 | <span class="sc-thread-time"><span class="ts" data-ts="$loop1.last_message_epoch" data-fmt="relative">$loop1.last_at</span></span> |
| 192 | 192 | </a> |
| 193 | 193 | [/loop] |
| 194 | 194 | [/if] |
| 195 | 195 | </div> |
| 196 | 196 | </div> |
| 197 | 197 | |
| 198 | 198 | <!-- RIGHT: active conversation --> |
| 199 | 199 | <div class="sc-pane sc-right"> |
| 200 | 200 | [if:!$has_active] |
| 201 | 201 | <div class="sc-empty"> |
| 202 | 202 | <div style="font-size:48px;opacity:0.5">✉</div> |
| 203 | 203 | <h2>No conversation selected</h2> |
| 204 | 204 | <p>Pick a thread from the left to read replies, or start a new support request and the ContactForge team will get back to you.</p> |
| 205 | 205 | <button type="button" class="sc-new-btn" data-sc-open="sc-new">+ Start a new request</button> |
| 206 | 206 | </div> |
| 207 | 207 | [/if] |
| 208 | 208 | |
| 209 | 209 | [if:$has_active] |
| 210 | 210 | <div class="sc-conv"> |
| 211 | 211 | <div class="sc-conv-head"> |
| 212 | 212 | <div class="sc-conv-title"> |
| 213 | 213 | <span class="sc-pill $active_status_class" style="font-size:10px">$active_status</span> |
| 214 | 214 | <span>$active_subject</span> |
| 215 | 215 | </div> |
| 216 | 216 | </div> |
| 217 | 217 | |
| 218 | 218 | <div class="sc-stream" id="sc-stream" data-thread-id="$active_id" data-last-id="$last_message_id" data-side="customer"> |
| 219 | 219 | [loop:@messages] |
| 220 | 220 | <div class="sc-msg[if:$loop1.is_customer] is-customer[/if][if:$loop1.is_admin] is-admin[/if][if:$loop1.is_system] is-system[/if]" data-msg-id="$loop1.id"> |
| 221 | 221 | [if:!$loop1.is_system]<div class="sc-avatar">$loop1.sender_initial</div>[/if] |
| 222 | 222 | [if:$loop1.is_system]<div class="sc-avatar">ⓘ</div>[/if] |
| 223 | 223 | <div> |
| 224 | 224 | <div class="sc-bubble">$loop1.body_html</div> |
| 225 | 225 | [if:$loop1.has_attach] |
| 226 | 226 | <div class="sup-msg-atts"> |
| 227 | 227 | [loop:@attachments] |
| 228 | 228 | <a href="$loop2.url" target="_blank" rel="noopener" class="sup-msg-att" title="$loop2.name"><img src="$loop2.url" alt=""></a> |
| 229 | 229 | [/loop] |
| 230 | 230 | </div> |
| 231 | 231 | [/if] |
| 232 | 232 | <div class="sc-meta-line">$loop1.sender_name · <span class="ts" data-ts="$loop1.msg_epoch" data-fmt="datetime">$loop1.ts</span></div> |
| 233 | 233 | </div> |
| 234 | 234 | </div> |
| 235 | 235 | [/loop] |
| 236 | 236 | </div> |
| 237 | 237 | |
| 238 | 238 | <form class="sc-compose sup-att-form" id="sc-compose" data-thread-id="$active_id"> |
| 239 | 239 | <textarea name="body" id="sc-body" placeholder="Write a message..." required></textarea> |
| 240 | 240 | <div class="sup-att-area" data-att-area> |
| 241 | 241 | <div class="sup-att-strip" data-att-strip></div> |
| 242 | 242 | <div class="sup-att-controls"> |
| 243 | 243 | <label class="sup-att-pick" data-att-pick> |
| 244 | 244 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg> |
| 245 | 245 | <span>Attach image</span> |
| 246 | 246 | <input type="file" data-att-input accept="image/jpeg,image/png,image/gif,image/webp,image/bmp,.jpg,.jpeg,.png,.gif,.webp,.bmp" multiple> |
| 247 | 247 | </label> |
| 248 | 248 | <span class="sup-att-hint">Drag & drop or paste also works</span> |
| 249 | 249 | </div> |
| 250 | 250 | </div> |
| 251 | 251 | <div class="sc-compose-row"> |
| 252 | 252 | <span class="sc-compose-hint">Enter to send · Shift+Enter for a new line</span> |
| 253 | 253 | <button type="submit" class="sc-btn is-primary">Send</button> |
| 254 | 254 | </div> |
| 255 | 255 | </form> |
| 256 | 256 | </div> |
| 257 | 257 | [/if] |
| 258 | 258 | </div> |
| 259 | 259 | </div> |
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | <!-- NEW REQUEST MODAL --> |
| 263 | 263 | <div class="sc-modal[if:$show_new_form] is-open[/if]" id="sc-new" role="dialog" aria-modal="true"> |
| 264 | 264 | <div class="sc-modal-card"> |
| 265 | 265 | <div class="sc-modal-sub">New support request</div> |
| 266 | 266 | <h2 class="sc-modal-title">Tell us what's happening</h2> |
| 267 | 267 | <p class="sc-modal-hint">Take your time. The more context you give us — what you tried, screenshots, links, error text — the faster we can come back with an answer that actually fits your situation.</p> |
| 268 | 268 | [if:$has_new_err] |
| 269 | 269 | <div class="banner warning" style="margin-bottom:12px">Subject and message are both required.</div> |
| 270 | 270 | [/if] |
| 271 | 271 | <form method="post" action="/support.cgi" autocomplete="off" class="sup-att-form"> |
| 272 | 272 | <input type="hidden" name="action" value="create_thread"> |
| 273 | 273 | <label for="sc-subj">Subject</label> |
| 274 | 274 | <input id="sc-subj" type="text" name="subject" required maxlength="200" placeholder="Brief summary of the issue or question"> |
| 275 | 275 | <label for="sc-body-new">Message</label> |
| 276 | 276 | <textarea id="sc-body-new" name="body" required placeholder="What's going on? Walk us through it — what you were trying to do, what happened instead, any error text you saw. Anything you think might be relevant. We read everything."></textarea> |
| 277 | 277 | <div class="sup-att-area" data-att-area> |
| 278 | 278 | <label style="display:block;margin-top:14px">Attachments</label> |
| 279 | 279 | <div class="sup-att-strip" data-att-strip></div> |
| 280 | 280 | <div class="sup-att-controls"> |
| 281 | 281 | <label class="sup-att-pick" data-att-pick> |
| 282 | 282 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg> |
| 283 | 283 | <span>Attach images</span> |
| 284 | 284 | <input type="file" data-att-input accept="image/jpeg,image/png,image/gif,image/webp,image/bmp,.jpg,.jpeg,.png,.gif,.webp,.bmp" multiple> |
| 285 | 285 | </label> |
| 286 | 286 | <span class="sup-att-hint">Or drag & drop, or paste (JPG / PNG / GIF / WebP / BMP · 10MB max)</span> |
| 287 | 287 | </div> |
| 288 | 288 | </div> |
| 289 | 289 | <div class="sc-modal-actions"> |
| 290 | 290 | <button type="button" class="sc-btn" data-sc-close>Cancel</button> |
| 291 | 291 | <button type="submit" class="sc-btn is-primary">Send request</button> |
| 292 | 292 | </div> |
| 293 | 293 | </form> |
| 294 | 294 | </div> |
| 295 | 295 | </div> |
| 296 | 296 | |
| 297 | 297 | |
| 298 | 298 | <script> |
| 299 | 299 | (function(){ |
| 300 | 300 | // Modal open/close |
| 301 | 301 | document.addEventListener('click', function(e){ |
| 302 | 302 | var open = e.target.closest('[data-sc-open]'); |
| 303 | 303 | if (open) { var m = document.getElementById(open.getAttribute('data-sc-open')); if (m) m.classList.add('is-open'); e.preventDefault(); return; } |
| 304 | 304 | var close = e.target.closest('[data-sc-close]'); |
| 305 | 305 | if (close) { var m2 = close.closest('.sc-modal'); if (m2) m2.classList.remove('is-open'); return; } |
| 306 | 306 | if (e.target.classList && e.target.classList.contains('sc-modal')) { e.target.classList.remove('is-open'); } |
| 307 | 307 | }); |
| 308 | 308 | |
| 309 | 309 | var stream = document.getElementById('sc-stream'); |
| 310 | 310 | if (!stream) return; // no active thread |
| 311 | 311 | |
| 312 | 312 | var threadId = stream.getAttribute('data-thread-id'); |
| 313 | 313 | var lastId = parseInt(stream.getAttribute('data-last-id') || '0', 10); |
| 314 | 314 | var side = stream.getAttribute('data-side') || 'customer'; |
| 315 | 315 | |
| 316 | 316 | // Scroll to bottom on initial render -- newest at bottom. |
| 317 | 317 | stream.scrollTop = stream.scrollHeight; |
| 318 | 318 | |
| 319 | 319 | // ---- Compose form -- POST via fetch so we don't reload the page ---- |
| 320 | 320 | var compose = document.getElementById('sc-compose'); |
| 321 | 321 | var body = document.getElementById('sc-body'); |
| 322 | 322 | function sendMessage() { |
| 323 | 323 | var text = body.value.trim(); |
| 324 | 324 | if (!text) return; |
| 325 | 325 | // Capture FormData BEFORE disabling the textarea -- FormData() |
| 326 | 326 | // skips disabled fields, which silently drops the body and the |
| 327 | 327 | // server returns "empty message". Do NOT re-append body either, |
| 328 | 328 | // or CGI->Vars joins duplicates with \0 producing "test\0test". |
| 329 | 329 | var data = new FormData(compose); |
| 330 | 330 | data.append('thread_id', threadId); |
| 331 | 331 | data.append('async', '1'); |
| 332 | 332 | body.disabled = true; |
| 333 | 333 | // Snapshot the attached thumbs so we can optimistically append |
| 334 | 334 | // them after send -- pollNow occasionally misses (server-side |
| 335 | 335 | // crash on the poll endpoint) and we don't want the sender to |
| 336 | 336 | // think nothing happened. |
| 337 | 337 | var strip = compose.querySelector('[data-att-strip]'); |
| 338 | 338 | var attUrls = []; |
| 339 | 339 | if (strip) { |
| 340 | 340 | strip.querySelectorAll('.sup-att-thumb img').forEach(function(im){ attUrls.push(im.src); }); |
| 341 | 341 | } |
| 342 | 342 | var sentText = text; |
| 343 | 343 | fetch('/support_send.cgi', { method:'POST', body:data }) |
| 344 | 344 | .then(function(r){ return r.json(); }) |
| 345 | 345 | .then(function(j){ |
| 346 | 346 | body.disabled = false; |
| 347 | 347 | if (!j || !j.ok) { appToast({ message: 'Send failed: ' + (j && j.error ? j.error : 'unknown'), type: 'error' }); return; } |
| 348 | 348 | body.value = ''; |
| 349 | 349 | if (strip) strip.innerHTML = ''; |
| 350 | 350 | body.focus(); |
| 351 | 351 | // Optimistic render: drop the message into the stream right |
| 352 | 352 | // away with the same body+attachment HTML the server will |
| 353 | 353 | // emit on its next poll. lastId is bumped so the next poll |
| 354 | 354 | // doesn't re-add it. |
| 355 | 355 | if (j.message_id) { |
| 356 | 356 | lastId = Math.max(lastId, parseInt(j.message_id, 10) || 0); |
| 357 | 357 | var attHtml = ''; |
| 358 | 358 | if (attUrls.length) { |
| 359 | 359 | attHtml = '<div class="sup-msg-atts">' + attUrls.map(function(u){ |
| 360 | 360 | return '<a href="' + u + '" target="_blank" rel="noopener" class="sup-msg-att"><img src="' + u + '" alt=""></a>'; |
| 361 | 361 | }).join('') + '</div>'; |
| 362 | 362 | } |
| 363 | 363 | var safe = sentText.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
| 364 | 364 | appendMessage({ |
| 365 | 365 | id: j.message_id, sender_role: 'customer', sender_name: 'You', |
| 366 | 366 | body_html: safe + attHtml, ts: 'just now' |
| 367 | 367 | }); |
| 368 | 368 | } |
| 369 | 369 | pollNow(); |
| 370 | 370 | }) |
| 371 | 371 | .catch(function(err){ |
| 372 | 372 | body.disabled = false; |
| 373 | 373 | appToast({ message: 'Send failed: ' + err.message, type: 'error' }); |
| 374 | 374 | }); |
| 375 | 375 | } |
| 376 | 376 | if (compose) { |
| 377 | 377 | compose.addEventListener('submit', function(e){ e.preventDefault(); sendMessage(); }); |
| 378 | 378 | body.addEventListener('keydown', function(e){ |
| 379 | 379 | if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendMessage(); } |
| 380 | 380 | }); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // ---- Polling for new messages every 12s ---- |
| 384 | 384 | // Async messaging only. Each poll asks the server for messages |
| 385 | 385 | // newer than the highest id we've seen and appends them inline. |
| 386 | 386 | function appendMessage(m) { |
| 387 | 387 | var wrap = document.createElement('div'); |
| 388 | 388 | var roleClass = m.sender_role === 'customer' ? 'is-customer' |
| 389 | 389 | : m.sender_role === 'admin' ? 'is-admin' |
| 390 | 390 | : 'is-system'; |
| 391 | 391 | wrap.className = 'sc-msg ' + roleClass; |
| 392 | 392 | wrap.setAttribute('data-msg-id', m.id); |
| 393 | 393 | var initial = (m.sender_name || '?').charAt(0).toUpperCase(); |
| 394 | 394 | var avatar = '<div class="sc-avatar">' + (m.sender_role === 'system' ? 'ⓘ' : initial) + '</div>'; |
| 395 | 395 | wrap.innerHTML = avatar + |
| 396 | 396 | '<div>' + |
| 397 | 397 | ' <div class="sc-bubble">' + m.body_html + '</div>' + |
| 398 | 398 | ' <div class="sc-meta-line">' + (m.sender_name || '') + ' · just now</div>' + |
| 399 | 399 | '</div>'; |
| 400 | 400 | stream.appendChild(wrap); |
| 401 | 401 | stream.scrollTop = stream.scrollHeight; |
| 402 | 402 | } |
| 403 | 403 | function pollNow() { |
| 404 | 404 | fetch('/support_poll.cgi?thread_id=' + encodeURIComponent(threadId) + '&since=' + lastId, { cache:'no-store' }) |
| 405 | 405 | .then(function(r){ return r.json(); }) |
| 406 | 406 | .then(function(j){ |
| 407 | 407 | if (!j || !j.ok) return; |
| 408 | 408 | (j.messages || []).forEach(function(m){ |
| 409 | 409 | if (m.id > lastId) { lastId = m.id; appendMessage(m); } |
| 410 | 410 | }); |
| 411 | 411 | }) |
| 412 | 412 | .catch(function(){ /* swallow -- next tick will retry */ }); |
| 413 | 413 | } |
| 414 | 414 | setInterval(pollNow, 12000); |
| 415 | 415 | })(); |
| 416 | 416 | </script> |
| 417 | 417 | |
| 418 | 418 | <!-- ===== Attachment widget JS (shared by modal + reply form) ===== |
| 419 | 419 | Enhances any <form class="sup-att-form"> that has a [data-att-area] |
| 420 | 420 | child: file picker, drag-and-drop on the whole form, paste-into- |
| 421 | 421 | textarea, thumbnail strip, async upload to /support_upload.cgi, |
| 422 | 422 | hidden attach_id inputs the form submits. ============================= --> |
| 423 | 423 | <script> |
| 424 | 424 | (function(){ |
| 425 | 425 | function setupAttachments(form) { |
| 426 | 426 | var area = form.querySelector('[data-att-area]'); |
| 427 | 427 | if (!area) return; |
| 428 | 428 | var input = area.querySelector('[data-att-input]'); |
| 429 | 429 | var pick = area.querySelector('[data-att-pick]'); |
| 430 | 430 | var strip = area.querySelector('[data-att-strip]'); |
| 431 | 431 | var ta = form.querySelector('textarea'); |
| 432 | 432 | |
| 433 | 433 | // Inject a live counter chip right after the picker label so the |
| 434 | 434 | // user gets immediate textual confirmation that the file was picked |
| 435 | 435 | // (the thumbnail may need a beat to render, especially on mobile). |
| 436 | 436 | var counter = document.createElement('span'); |
| 437 | 437 | counter.className = 'sup-att-count'; |
| 438 | 438 | counter.setAttribute('data-att-counter', ''); |
| 439 | 439 | counter.style.display = 'none'; |
| 440 | 440 | if (pick && pick.parentNode) pick.parentNode.insertBefore(counter, pick.nextSibling); |
| 441 | 441 | function updateCounter() { |
| 442 | 442 | var n = strip.querySelectorAll('.sup-att-thumb').length; |
| 443 | 443 | var ok = strip.querySelectorAll('input[name="attach_id"]').length; |
| 444 | 444 | var pending = n - ok; |
| 445 | 445 | if (n === 0) { counter.style.display = 'none'; return; } |
| 446 | 446 | counter.style.display = 'inline-flex'; |
| 447 | 447 | if (pending > 0) { |
| 448 | 448 | counter.textContent = n + ' selected (' + ok + ' ready, ' + pending + ' uploading...)'; |
| 449 | 449 | counter.className = 'sup-att-count is-working'; |
| 450 | 450 | } else { |
| 451 | 451 | counter.textContent = n + (n === 1 ? ' image attached' : ' images attached'); |
| 452 | 452 | counter.className = 'sup-att-count is-ready'; |
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | function makeThumb(src, id, pending, name) { |
| 457 | 457 | var t = document.createElement('div'); |
| 458 | 458 | t.className = 'sup-att-thumb' + (pending ? ' is-pending' : ''); |
| 459 | 459 | if (name) t.title = name; |
| 460 | 460 | var img = document.createElement('img'); |
| 461 | 461 | img.src = src; |
| 462 | 462 | t.appendChild(img); |
| 463 | 463 | if (!pending && id) { |
| 464 | 464 | var hidden = document.createElement('input'); |
| 465 | 465 | hidden.type = 'hidden'; |
| 466 | 466 | hidden.name = 'attach_id'; |
| 467 | 467 | hidden.value = id; |
| 468 | 468 | t.appendChild(hidden); |
| 469 | 469 | var rm = document.createElement('button'); |
| 470 | 470 | rm.type = 'button'; |
| 471 | 471 | rm.className = 'sup-att-rm'; |
| 472 | 472 | rm.innerHTML = '×'; |
| 473 | 473 | rm.setAttribute('aria-label', 'Remove attachment'); |
| 474 | 474 | rm.addEventListener('click', function(){ t.remove(); updateCounter(); }); |
| 475 | 475 | t.appendChild(rm); |
| 476 | 476 | } |
| 477 | 477 | return t; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | function upload(file) { |
| 481 | 481 | if (!file) return; |
| 482 | 482 | var t = (file.type || '').toLowerCase(); |
| 483 | 483 | var nm = (file.name || '').toLowerCase(); |
| 484 | 484 | var okType = t.indexOf('image/') === 0; |
| 485 | 485 | var okExt = false; |
| 486 | 486 | var exts = ['.jpg','.jpeg','.png','.gif','.webp','.bmp']; |
| 487 | 487 | for (var ei = 0; ei < exts.length; ei++) { |
| 488 | 488 | if (nm.length >= exts[ei].length && nm.lastIndexOf(exts[ei]) === nm.length - exts[ei].length) { okExt = true; break; } |
| 489 | 489 | } |
| 490 | 490 | if (!okType && !okExt) { |
| 491 | 491 | appToast({ message: file.name + ': not an image -- only JPG / PNG / GIF / WebP / BMP are accepted.', type: 'warning' }); |
| 492 | 492 | return; |
| 493 | 493 | } |
| 494 | 494 | var placeholder = makeThumb(URL.createObjectURL(file), null, true, file.name); |
| 495 | 495 | strip.appendChild(placeholder); |
| 496 | 496 | updateCounter(); |
| 497 | 497 | var fd = new FormData(); |
| 498 | 498 | fd.append('image', file); |
| 499 | 499 | fetch('/support_upload.cgi', { method: 'POST', body: fd, credentials: 'same-origin' }) |
| 500 | 500 | .then(function(r){ return r.json(); }) |
| 501 | 501 | .then(function(j){ |
| 502 | 502 | if (j && j.success) { |
| 503 | 503 | var real = makeThumb(j.url, j.id, false, j.filename); |
| 504 | 504 | placeholder.replaceWith(real); |
| 505 | 505 | } else { |
| 506 | 506 | placeholder.classList.add('failed'); |
| 507 | 507 | placeholder.classList.remove('is-pending'); |
| 508 | 508 | placeholder.title = (j && j.error) ? j.error : 'upload failed'; |
| 509 | 509 | } |
| 510 | 510 | updateCounter(); |
| 511 | 511 | }) |
| 512 | 512 | .catch(function(){ |
| 513 | 513 | placeholder.classList.add('failed'); |
| 514 | 514 | placeholder.classList.remove('is-pending'); |
| 515 | 515 | updateCounter(); |
| 516 | 516 | }); |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | // The file picker is opened natively by the <label> wrapping the |
| 520 | 520 | // <input type="file"> -- no JS .click() needed (which is the most |
| 521 | 521 | // reliable cross-browser path, especially on iOS Safari). We only |
| 522 | 522 | // need to listen for the change event to upload the chosen files. |
| 523 | 523 | if (input) { |
| 524 | 524 | input.addEventListener('change', function(){ |
| 525 | 525 | Array.prototype.slice.call(input.files).forEach(upload); |
| 526 | 526 | input.value = ''; |
| 527 | 527 | }); |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | // Drag/drop on the whole form so the drop zone is huge and |
| 531 | 531 | // forgiving -- users tend to drop slightly off the strip. |
| 532 | 532 | ['dragenter','dragover'].forEach(function(ev){ |
| 533 | 533 | form.addEventListener(ev, function(e){ |
| 534 | 534 | if (e.dataTransfer && Array.prototype.indexOf.call(e.dataTransfer.types, 'Files') !== -1) { |
| 535 | 535 | e.preventDefault(); |
| 536 | 536 | form.classList.add('att-drag'); |
| 537 | 537 | } |
| 538 | 538 | }); |
| 539 | 539 | }); |
| 540 | 540 | ['dragleave','dragend','drop'].forEach(function(ev){ |
| 541 | 541 | form.addEventListener(ev, function(){ form.classList.remove('att-drag'); }); |
| 542 | 542 | }); |
| 543 | 543 | form.addEventListener('drop', function(e){ |
| 544 | 544 | if (!e.dataTransfer || !e.dataTransfer.files || !e.dataTransfer.files.length) return; |
| 545 | 545 | e.preventDefault(); |
| 546 | 546 | Array.prototype.slice.call(e.dataTransfer.files).forEach(upload); |
| 547 | 547 | }); |
| 548 | 548 | |
| 549 | 549 | // Paste an image directly into the textarea (screenshot Ctrl+V). |
| 550 | 550 | if (ta) { |
| 551 | 551 | ta.addEventListener('paste', function(e){ |
| 552 | 552 | var items = e.clipboardData && e.clipboardData.items; |
| 553 | 553 | if (!items) return; |
| 554 | 554 | for (var i = 0; i < items.length; i++) { |
| 555 | 555 | if (items[i].kind === 'file') { |
| 556 | 556 | var f = items[i].getAsFile(); |
| 557 | 557 | if (f) upload(f); |
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | }); |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | document.querySelectorAll('form.sup-att-form').forEach(setupAttachments); |
| 564 | 564 | |
| 565 | 565 | // Global drag-defaults killer. Without these, dropping a file |
| 566 | 566 | // ANYWHERE outside an explicit drop zone causes the browser to |
| 567 | 567 | // navigate to that file (image opens in a new tab). We intercept |
| 568 | 568 | // dragover + drop at the window level, and if the drop didn't land |
| 569 | 569 | // on a sup-att-form we route the files to the first visible one -- |
| 570 | 570 | // so users get the attachment behavior no matter where they drop. |
| 571 | 571 | window.addEventListener('dragover', function(e){ |
| 572 | 572 | if (e.dataTransfer && Array.prototype.indexOf.call(e.dataTransfer.types, 'Files') !== -1) { |
| 573 | 573 | e.preventDefault(); |
| 574 | 574 | } |
| 575 | 575 | }); |
| 576 | 576 | window.addEventListener('drop', function(e){ |
| 577 | 577 | if (!e.dataTransfer || !e.dataTransfer.files || !e.dataTransfer.files.length) return; |
| 578 | 578 | var inForm = e.target && e.target.closest && e.target.closest('form.sup-att-form'); |
| 579 | 579 | if (inForm) return; // form's own handler will pick it up |
| 580 | 580 | e.preventDefault(); // we're catching a drop that would otherwise open in a new tab |
| 581 | 581 | var firstForm = document.querySelector('form.sup-att-form'); |
| 582 | 582 | if (!firstForm) return; |
| 583 | 583 | var area = firstForm.querySelector('[data-att-area]'); |
| 584 | 584 | if (!area || area.offsetParent === null) return; // form hidden -- bail |
| 585 | 585 | // Re-dispatch by directly invoking the form's drop pipeline. |
| 586 | 586 | var dropEvt = new DragEvent('drop', { bubbles: true, cancelable: true, dataTransfer: e.dataTransfer }); |
| 587 | 587 | firstForm.dispatchEvent(dropEvt); |
| 588 | 588 | }); |
| 589 | 589 | })(); |
| 590 | 590 | </script> |