source: Klonkt/src/views/pages/authorize-interaction.ejs@ 667fb41

main
Last change on this file since 667fb41 was 667fb41, checked in by roboburr <roboburr@…>, 2 months ago

feat(polls): vote on any fediverse poll from the interact page

The interact page (paste any post URL) now detects a Question and shows a ballot
(radio/checkbox + Vote) so you can vote on any fediverse poll by URL — not only
polls from accounts you follow (which vote via /news). Casts the Mastodon-standard
ballot straight to the poll's author, no timeline cache needed.

  • src/services/ActivityPubService.js — voteOnRemotePoll(site, url, choices) fetches the Question fresh, validates the choice(s) and delivers the ballot to the author; resolveRemoteNote now returns the parsed poll so the view can render options.
  • src/routes/posts.js — POST /authorize_interaction/vote; GET passes voted and skips re-resolving the target on the confirmation view.
  • src/views/pages/authorize-interaction.ejs — ballot (open) / results (closed) above the like/boost/reply actions, a "vote sent" confirmation, and scoped .auth-poll styles.
  • src/services/i18n.js — poll.voted_title/_done (nl/en/de).

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 23.2 KB
Line 
1<div class="auth-interact">
2 <% if (typeof manage !== 'undefined' && manage) { %>
3 <%- include('../partials/fedi-tabs', { active: 'reacties' }) %>
4 <h1 class="auth-interact-title"><%= t('fedi.manage_title') %></h1>
5
6 <%# Interact bookmarklet — drag to bookmarks bar, then click on any fediverse post. %>
7 <div class="fedi-bm">
8 <a class="fedi-bm-btn" id="fedi-bm-btn" href="#" draggable="true" title="<%= t('fedi.bm_help') %>">
9 <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
10 <%= t('fedi.bm_label') %>
11 </a>
12 <p class="fedi-bm-help"><%= t('fedi.bm_help') %></p>
13 </div>
14 <script>
15 (function () {
16 if (window.__fediBmWired) return; window.__fediBmWired = true;
17 var a = document.getElementById('fedi-bm-btn'); if (!a) return;
18 a.setAttribute('href', "javascript:void(window.open('" + location.origin + "/authorize_interaction?uri='+encodeURIComponent(window.location.href)))");
19 a.addEventListener('click', function (e) { e.preventDefault(); a.classList.add('nudge'); setTimeout(function(){ a.classList.remove('nudge'); }, 600); });
20 })();
21 </script>
22 <% if (!manage.length) { %>
23 <p class="auth-interact-note"><%= t('fedi.manage_empty') %></p>
24 <% } else { %>
25 <ul class="fedi-manage">
26 <% manage.forEach(function(m){ %>
27 <li class="fedi-manage-item">
28 <div class="fedi-manage-head">
29 <span class="fedi-manage-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 17 4 12 9 7"/><path d="M20 18v-2a4 4 0 0 0-4-4H4"/></svg></span>
30 <% if (m.to_handle) { %><span class="fedi-manage-to"><%= m.to_handle %></span><% } %>
31 <% if (m.created_at && typeof formatDateTime === 'function') { %><span class="fedi-manage-time"><%= formatDateTime(m.created_at) %></span><% } %>
32 </div>
33 <div class="fedi-manage-content"><%- m.content %></div>
34 <div class="fedi-manage-foot">
35 <button type="button" class="fedi-edit-btn" aria-expanded="false"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg> <%= t('fedi.edit') %></button>
36 <% if (m.in_reply_to) { %>
37 <a class="fedi-goto-btn" href="<%= m.in_reply_to %>" target="_blank" rel="nofollow noopener"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg> <%= t('fedi.goto_post') %></a>
38 <% } %>
39 <form method="post" action="/fediverse/<%= m.id %>/delete" class="fedi-del-form" data-confirm="<%= t('fedi.delete_confirm') %>">
40 <button type="submit" class="fedi-del-btn"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg> <%= t('comments.delete') %></button>
41 </form>
42 </div>
43 <form method="post" action="/fediverse/<%= m.id %>/edit" class="fedi-edit-form">
44 <textarea name="text" rows="3" maxlength="2000" class="fedi-edit-ta"><%= m.editable %></textarea>
45 <div class="fedi-edit-actions"><button type="submit" class="fedi-edit-save"><%= t('fedi.save_edit') %></button></div>
46 </form>
47 </li>
48 <% }); %>
49 </ul>
50 <script>
51 (function () {
52 if (window.__fediEditWired) return; window.__fediEditWired = true;
53 document.addEventListener('click', function (e) {
54 var b = e.target.closest && e.target.closest('.fedi-edit-btn');
55 if (!b) return;
56 var li = b.closest('.fedi-manage-item'); if (!li) return;
57 var form = li.querySelector('.fedi-edit-form'); if (!form) return;
58 var open = form.classList.toggle('is-open');
59 b.classList.toggle('is-open', open);
60 b.setAttribute('aria-expanded', open ? 'true' : 'false');
61 if (open) { var ta = form.querySelector('textarea'); if (ta) ta.focus(); }
62 });
63 })();
64 </script>
65 <% } %>
66 <p class="auth-interact-note"><a href="/"><%= t('fedi.remote_back') %></a></p>
67 <% } else if (typeof liked !== 'undefined' && liked) { %>
68 <h1 class="auth-interact-title">★ <%= t('fedi.liked_title') %></h1>
69 <p class="auth-interact-note"><%= t('fedi.liked_done') %></p>
70 <p class="auth-interact-actions">
71 <% if (uri) { %><a class="btn" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
72 <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
73 </p>
74 <% } else if (typeof boosted !== 'undefined' && boosted) { %>
75 <h1 class="auth-interact-title">🔁 <%= t('fedi.boosted_title') %></h1>
76 <p class="auth-interact-note"><%= t('fedi.boosted_done') %></p>
77 <p class="auth-interact-actions">
78 <% if (uri) { %><a class="btn" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
79 <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
80 </p>
81 <% } else if (typeof followed !== 'undefined' && followed) { %>
82 <h1 class="auth-interact-title"><%= t('fedi.followed_title') %></h1>
83 <p class="auth-interact-note"><%= t('fedi.followed_done') %></p>
84 <p class="auth-interact-actions">
85 <% if (uri) { %><a class="btn" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.view_profile') %></a><% } %>
86 <a class="btn btn-primary" href="/"><%= t('fedi.remote_back') %></a>
87 </p>
88 <% } else if (typeof sent !== 'undefined' && sent) { %>
89 <h1 class="auth-interact-title"><%= t('fedi.remote_sent_title') %></h1>
90 <p class="auth-interact-note"><%= t('fedi.remote_sent') %></p>
91 <p class="auth-interact-actions">
92 <% if (uri) { %><a class="btn btn-primary" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
93 <a class="btn" href="/"><%= t('fedi.remote_back') %></a>
94 </p>
95 <% } else if (typeof voted !== 'undefined' && voted) { %>
96 <h1 class="auth-interact-title">📊 <%= t('poll.voted_title') %></h1>
97 <p class="auth-interact-note"><%= t('poll.voted_done') %></p>
98 <p class="auth-interact-actions">
99 <% if (uri) { %><a class="btn btn-primary" href="<%= uri %>" rel="nofollow noopener"><%= t('fedi.remote_view_original') %></a><% } %>
100 <a class="btn" href="/"><%= t('fedi.remote_back') %></a>
101 </p>
102 <% } else if (typeof followTarget !== 'undefined' && followTarget) { %>
103 <h1 class="auth-interact-title"><%= t('fedi.follow_heading') %></h1>
104 <p class="auth-interact-meta">
105 <%= t('fedi.follow_intro') %>
106 <a href="<%= followTarget.actor_url %>" rel="nofollow noopener" target="_blank"><strong><%= followTarget.actor_name %></strong></a>
107 <span class="fedi-handle"><%= followTarget.actor_handle %></span>
108 </p>
109 <form method="post" action="/authorize_interaction/follow" class="auth-interact-form">
110 <input type="hidden" name="uri" value="<%= followTarget.actor_uri %>">
111 <div class="auth-interact-actions">
112 <button type="submit" class="btn btn-primary"><%= t('fedi.follow_btn') %></button>
113 <a href="/" class="btn"><%= t('comments.cancel') %></a>
114 </div>
115 </form>
116 <p class="auth-interact-note"><%= t('fedi.remote_as', { site: siteTitle }) %></p>
117 <% } else { %>
118 <h1 class="auth-interact-title"><%= t('fedi.remote_title') %></h1>
119
120 <% if (!target) { %>
121 <p class="auth-interact-note"><%= t('fedi.remote_notfound') %></p>
122 <form method="get" action="/authorize_interaction" class="auth-interact-form">
123 <input type="url" name="uri" placeholder="https://…/een-post" value="<%= uri || '' %>" required>
124 <button type="submit" class="btn btn-primary"><%= t('fedi.remote_load') %></button>
125 </form>
126 <% } else { %>
127 <p class="auth-interact-meta">
128 <%= t('fedi.remote_replying_to') %>
129 <a href="<%= target.actor_url %>" rel="nofollow noopener" target="_blank"><strong><%= target.actor_name %></strong></a>
130 <span class="fedi-handle"><%= target.actor_handle %></span>
131 </p>
132 <blockquote class="auth-interact-preview">
133 <% if (target.content) { %><div class="auth-interact-content"><%- target.content %></div>
134 <% } else if (target.preview) { %><%= target.preview %><% } %>
135 <% (target.images || []).forEach(function(im){ %>
136 <img class="auth-interact-img" src="<%= im %>" alt="" loading="lazy">
137 <% }); %>
138 </blockquote>
139 <% if (target.url || uri) { %>
140 <a class="auth-view-src" href="<%= target.url || uri %>" target="_blank" rel="nofollow noopener">
141 <svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg>
142 <span><%= t('fedi.remote_view_original') %></span>
143 </a>
144 <% } %>
145 <% if (target.poll) { var _pl = target.poll; var _tot = _pl.options.reduce(function(s,o){return s+(o.count||0);},0); %>
146 <% if (!_pl.closed) { %>
147 <form method="post" action="/authorize_interaction/vote" class="auth-poll">
148 <input type="hidden" name="uri" value="<%= uri %>">
149 <% _pl.options.forEach(function(o){ %>
150 <label class="auth-poll-choice"><input type="<%= _pl.multiple ? 'checkbox' : 'radio' %>" name="choice" value="<%= o.name %>"><span><%= o.name %></span></label>
151 <% }); %>
152 <div class="auth-interact-actions">
153 <button type="submit" class="btn btn-primary"><%= t('poll.vote') %></button>
154 </div>
155 <p class="auth-poll-foot"><% if (_pl.multiple) { %><%= t('poll.multiple') %> · <% } %><%= (_pl.voters!=null?_pl.voters:_tot) %> <%= t('poll.votes') %></p>
156 </form>
157 <% } else { %>
158 <div class="auth-poll">
159 <% _pl.options.forEach(function(o){ var _pct = _tot ? Math.round((o.count||0)*100/_tot) : 0; %>
160 <div class="auth-poll-res"><span class="auth-poll-fill" style="width:<%= _pct %>%"></span><span class="auth-poll-name"><%= o.name %></span><span class="auth-poll-pct"><%= _pct %>%</span></div>
161 <% }); %>
162 <p class="auth-poll-foot"><%= (_pl.voters!=null?_pl.voters:_tot) %> <%= t('poll.votes') %> · <%= t('poll.closed') %></p>
163 </div>
164 <% } %>
165 <% } %>
166 <% var _liked = (typeof reacted !== 'undefined' && reacted.liked); var _boosted = (typeof reacted !== 'undefined' && reacted.boosted); %>
167 <div class="auth-interact-react">
168 <form method="post" action="/authorize_interaction/like" class="fedi-react-form">
169 <input type="hidden" name="uri" value="<%= uri %>">
170 <button type="submit" class="fedi-bigact fedi-bigact-like<%= _liked ? ' is-on' : '' %>" data-on="<%= t('fedi.unlike_short') %>" data-off="<%= t('fedi.like_short') %>">
171 <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.6l2.9 5.88 6.49.95-4.7 4.58 1.11 6.46L12 17.96l-5.8 3.06 1.1-6.46-4.69-4.58 6.49-.95z"/></svg>
172 <span class="fedi-bigact-label"><%= _liked ? t('fedi.unlike_short') : t('fedi.like_short') %></span>
173 </button>
174 </form>
175 <form method="post" action="/authorize_interaction/boost" class="fedi-react-form">
176 <input type="hidden" name="uri" value="<%= uri %>">
177 <button type="submit" class="fedi-bigact fedi-bigact-boost<%= _boosted ? ' is-on' : '' %>" data-on="<%= t('tl.unboost') %>" data-off="<%= t('fedi.boost_short') %>">
178 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>
179 <span class="fedi-bigact-label"><%= _boosted ? t('tl.unboost') : t('fedi.boost_short') %></span>
180 </button>
181 </form>
182 </div>
183 <p class="auth-interact-or"><%= t('fedi.or_reply') %></p>
184 <p class="auth-interact-where">💬 <%= t('fedi.reply_where') %></p>
185 <form method="post" action="/authorize_interaction" class="auth-interact-form">
186 <input type="hidden" name="uri" value="<%= uri %>">
187 <textarea name="text" rows="4" required placeholder="<%= t('fedi.reply_ph') %>"></textarea>
188 <div class="auth-interact-actions">
189 <button type="submit" class="btn"><%= t('fedi.send') %></button>
190 <a href="<%= uri %>" class="btn"><%= t('comments.cancel') %></a>
191 </div>
192 </form>
193 <p class="auth-interact-note"><%= t('fedi.remote_as', { site: siteTitle }) %></p>
194 <% } %>
195 <% } %>
196</div>
197
198<style>
199 .auth-interact { max-width: 640px; margin: 1rem auto; padding: 0 1rem; }
200 .auth-interact-title { margin: 0 0 1rem; }
201 .auth-interact-meta { color: var(--ink-soft, #888); margin: 0 0 .75rem; }
202 .auth-interact-preview {
203 margin: 0 0 1rem; padding: .75rem 1rem; border-left: 3px solid var(--accent, #888);
204 background: color-mix(in srgb, var(--ink, #000) 4%, transparent); border-radius: 0 12px 12px 0;
205 color: var(--ink, inherit);
206 }
207 .auth-interact-form { display: flex; flex-direction: column; gap: .75rem; }
208 .auth-interact-form textarea, .auth-interact-form input[type=url] {
209 width: 100%; box-sizing: border-box; padding: .6rem .8rem; font: inherit; resize: vertical;
210 border-radius: 12px; border: 1px solid color-mix(in srgb, var(--ink, #000) 18%, transparent);
211 background: var(--paper, #fff); color: var(--ink, #000);
212 }
213 .auth-interact-actions { display: flex; gap: .5rem; align-items: center; }
214 .auth-interact-note { color: var(--ink-soft, #999); font-size: .85rem; margin-top: 1rem; }
215 .auth-interact-where { margin: .25rem 0 .85rem; padding: .6rem .8rem; font-size: .85rem; line-height: 1.5; border-radius: 10px; background: color-mix(in srgb, var(--accent, #888) 12%, transparent); color: var(--ink, inherit); }
216 .auth-interact-content { line-height: 1.55; }
217 .auth-interact-content p { margin: .35rem 0; }
218 .auth-interact-content p:first-child { margin-top: 0; }
219 .auth-interact-img { max-width: 100%; height: auto; border-radius: 10px; margin: .5rem 0 0; display: block; }
220 .auth-interact-orig { margin: .75rem 0 0; font-size: .85rem; }
221 .auth-interact-orig a { color: var(--accent, #06c); }
222 .auth-view-src { display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 1.1rem; padding: .6rem 1rem;
223 border: 1px solid color-mix(in srgb, var(--accent, #888) 45%, transparent); border-radius: 12px;
224 background: color-mix(in srgb, var(--accent, #888) 10%, transparent); color: var(--accent, #06c);
225 text-decoration: none; font-weight: 600; font-size: .92rem; transition: background .15s, border-color .15s; }
226 .auth-view-src:hover { background: color-mix(in srgb, var(--accent, #888) 18%, transparent); border-color: var(--accent, #888); }
227 .auth-interact-react { display: flex; gap: .6rem; flex-wrap: wrap; margin: 0 0 .25rem; }
228 .auth-interact-react form { margin: 0; }
229 .fedi-bigact { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1.1rem; border-radius: 999px;
230 border: 1px solid color-mix(in srgb, var(--ink, #000) 14%, transparent);
231 background: color-mix(in srgb, var(--ink, #000) 4%, transparent);
232 color: var(--ink, inherit); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap;
233 transition: background .12s, border-color .12s; }
234 .fedi-bigact svg { width: 17px; height: 17px; flex: 0 0 17px; }
235 .fedi-bigact-like svg { color: #e8b04b; }
236 .fedi-bigact-like:hover, .fedi-bigact-like.is-on { background: color-mix(in srgb, #e8b04b 16%, transparent); border-color: color-mix(in srgb, #e8b04b 55%, transparent); }
237 .fedi-bigact-boost svg { color: #2fa85a; }
238 .fedi-bigact-boost:hover, .fedi-bigact-boost.is-on { background: color-mix(in srgb, #2fa85a 16%, transparent); border-color: color-mix(in srgb, #2fa85a 55%, transparent); }
239 .fedi-manage { list-style: none; padding: 0; margin: 1.25rem 0 1rem; display: flex; flex-direction: column; gap: .7rem; }
240 .fedi-manage-item { padding: .9rem 1rem; border-radius: 14px; background: color-mix(in srgb, var(--ink, #000) 3.5%, transparent); border: 1px solid color-mix(in srgb, var(--ink, #000) 9%, transparent); transition: border-color .15s ease, box-shadow .15s ease; }
241 .fedi-manage-item:hover { border-color: color-mix(in srgb, var(--accent, #888) 28%, transparent); box-shadow: 0 2px 12px color-mix(in srgb, var(--ink, #000) 6%, transparent); }
242 .fedi-manage-head { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; }
243 .fedi-manage-icon { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
244 background: color-mix(in srgb, var(--accent, #888) 16%, transparent); color: var(--accent, #06c); }
245 .fedi-manage-icon svg { width: 14px; height: 14px; }
246 .fedi-manage-to { font-weight: 600; color: var(--ink, inherit); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
247 .fedi-manage-time { color: var(--ink-soft, #999); font-size: .76rem; margin-left: auto; flex: 0 0 auto; white-space: nowrap; }
248 .fedi-manage-content { line-height: 1.55; overflow-wrap: anywhere; padding-left: calc(26px + .5rem); }
249 .fedi-manage-content p { margin: .15rem 0; }
250 .fedi-manage-content p:first-child { margin-top: 0; }
251 .fedi-manage-content p:last-child { margin-bottom: 0; }
252 .fedi-manage-foot { display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: .5rem; margin-top: .65rem; }
253 .fedi-goto-btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid color-mix(in srgb, var(--accent, #888) 45%, transparent); background: color-mix(in srgb, var(--accent, #888) 12%, transparent); color: var(--accent, #06c); border-radius: 999px; padding: .3rem .8rem; font-size: .82rem; text-decoration: none; transition: background .15s ease; }
254 .fedi-goto-btn:hover { background: color-mix(in srgb, var(--accent, #888) 22%, transparent); }
255 .fedi-del-btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid color-mix(in srgb, #d9534f 45%, transparent); background: color-mix(in srgb, #d9534f 12%, transparent); color: #e06b66; border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .82rem; cursor: pointer; transition: background .15s ease; }
256 .fedi-del-btn:hover { background: color-mix(in srgb, #d9534f 24%, transparent); }
257 .fedi-bm { margin: 0 0 1.5rem; padding: 1rem; border-radius: 14px;
258 border: 1px dashed color-mix(in srgb, var(--accent, #888) 45%, transparent);
259 background: color-mix(in srgb, var(--accent, #888) 7%, transparent); }
260 .fedi-bm-btn { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1rem; border-radius: 999px;
261 background: var(--accent, #06c); color: #fff; font: inherit; font-weight: 600; font-size: .9rem; text-decoration: none;
262 cursor: grab; user-select: none; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent, #000) 30%, transparent); }
263 .fedi-bm-btn:active { cursor: grabbing; }
264 .fedi-bm-btn.nudge { animation: fedi-bm-nudge .6s ease; }
265 @keyframes fedi-bm-nudge { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
266 .fedi-bm-help { color: var(--ink-soft, #888); font-size: .82rem; line-height: 1.5; margin: .6rem 0 0; }
267 .fedi-edit-btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid color-mix(in srgb, var(--ink, #888) 28%, transparent);
268 background: color-mix(in srgb, var(--ink, #888) 8%, transparent); color: var(--ink-soft, #aaa); border-radius: 999px; padding: .3rem .8rem;
269 font: inherit; font-size: .82rem; cursor: pointer; transition: background .15s ease, color .15s ease; }
270 .fedi-edit-btn:hover { background: color-mix(in srgb, var(--ink, #888) 16%, transparent); }
271 .fedi-edit-btn.is-open { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
272 .fedi-del-form { margin-left: auto; }
273 .fedi-edit-form { display: none; margin: .55rem 0 0; }
274 .fedi-edit-form.is-open { display: block; }
275 .fedi-edit-ta { width: 100%; box-sizing: border-box; min-height: 70px; resize: vertical; padding: .55rem .7rem;
276 border: 1.5px solid var(--rule, #333); border-radius: 10px; background: var(--paper-2, #14141a); color: var(--ink, #eee); font: inherit; font-size: .9rem; }
277 .fedi-edit-ta:focus { outline: none; border-color: var(--accent); }
278 .fedi-edit-actions { display: flex; justify-content: flex-end; margin-top: .5rem; }
279 .fedi-edit-save { padding: .4rem 1rem; border: 0; border-radius: 999px; background: var(--accent); color: var(--paper, #fff);
280 font: inherit; font-weight: 600; font-size: .82rem; cursor: pointer; }
281 /* Poll ballot / results on the interact page */
282 .auth-poll { display: flex; flex-direction: column; gap: 8px; margin: 0 0 1rem; }
283 .auth-poll-choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer;
284 border: 1px solid color-mix(in srgb, var(--ink, #000) 14%, transparent); }
285 .auth-poll-choice:hover { border-color: var(--accent); }
286 .auth-poll-choice input { accent-color: var(--accent); }
287 .auth-poll-res { position: relative; padding: 9px 12px; border-radius: 10px; overflow: hidden; display: flex; align-items: center; gap: 8px;
288 background: color-mix(in srgb, var(--ink, #000) 6%, transparent); }
289 .auth-poll-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 22%, transparent); z-index: 0; }
290 .auth-poll-name { position: relative; z-index: 1; flex: 1; font-size: .95rem; }
291 .auth-poll-pct { position: relative; z-index: 1; font-variant-numeric: tabular-nums; font-weight: 500; }
292 .auth-poll-foot { font-size: .82rem; color: var(--ink-soft, #888); margin: .1rem 0 0; }
293</style>
294
295<script>
296/* Like/Boost toggle in place — POST via fetch, flip the button, stay on the page. */
297(function(){
298 if (window.__fediReactWired) return; window.__fediReactWired = true;
299 document.addEventListener('submit', function(e){
300 var f = e.target.closest && e.target.closest('.fedi-react-form');
301 if (!f) return;
302 e.preventDefault();
303 var btn = f.querySelector('button'); if (!btn || btn.disabled) return;
304 btn.disabled = true;
305 var body = new URLSearchParams();
306 new FormData(f).forEach(function(v, k){ body.append(k, v); });
307 fetch(f.action, { method: 'POST', body: body, headers: { 'X-Requested-With': 'fetch' }, credentials: 'same-origin' })
308 .then(function(r){ return r.ok ? r.json() : null; })
309 .then(function(j){
310 if (j) {
311 var on = !!j.on;
312 btn.classList.toggle('is-on', on);
313 var lbl = btn.querySelector('.fedi-bigact-label');
314 if (lbl) lbl.textContent = on ? (btn.getAttribute('data-on') || lbl.textContent) : (btn.getAttribute('data-off') || lbl.textContent);
315 }
316 })
317 .catch(function(){})
318 .then(function(){ btn.disabled = false; });
319 });
320})();
321</script>
Note: See TracBrowser for help on using the repository browser.