Changeset c7ecaf9 in Klonkt for src/views/pages
- Timestamp:
- 06/26/2026 11:45:53 PM (2 months ago)
- Branches:
- main
- Children:
- 9d34855
- Parents:
- 2f42b60
- File:
-
- 1 edited
-
src/views/pages/authorize-interaction.ejs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/views/pages/authorize-interaction.ejs
r2f42b60 rc7ecaf9 96 96 </a> 97 97 <% } %> 98 <% var _liked = (typeof reacted !== 'undefined' && reacted.liked); var _boosted = (typeof reacted !== 'undefined' && reacted.boosted); %> 98 99 <div class="auth-interact-react"> 99 <form method="post" action="/authorize_interaction/like" >100 <form method="post" action="/authorize_interaction/like" class="fedi-react-form"> 100 101 <input type="hidden" name="uri" value="<%= uri %>"> 101 <button type="submit" class="fedi-bigact fedi-bigact-like<%= (typeof reacted !== 'undefined' && reacted.liked) ? ' is-on' : ''%>">102 <button type="submit" class="fedi-bigact fedi-bigact-like<%= _liked ? ' is-on' : '' %>" data-on="<%= t('fedi.unlike_short') %>" data-off="<%= t('fedi.like_short') %>"> 102 103 <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> 103 <span ><%= (typeof reacted !== 'undefined' && reacted.liked)? t('fedi.unlike_short') : t('fedi.like_short') %></span>104 <span class="fedi-bigact-label"><%= _liked ? t('fedi.unlike_short') : t('fedi.like_short') %></span> 104 105 </button> 105 106 </form> 106 <form method="post" action="/authorize_interaction/boost" >107 <form method="post" action="/authorize_interaction/boost" class="fedi-react-form"> 107 108 <input type="hidden" name="uri" value="<%= uri %>"> 108 <button type="submit" class="fedi-bigact fedi-bigact-boost<%= (typeof reacted !== 'undefined' && reacted.boosted) ? ' is-on' : ''%>">109 <button type="submit" class="fedi-bigact fedi-bigact-boost<%= _boosted ? ' is-on' : '' %>" data-on="<%= t('tl.unboost') %>" data-off="<%= t('fedi.boost_short') %>"> 109 110 <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> 110 <span ><%= (typeof reacted !== 'undefined' && reacted.boosted)? t('tl.unboost') : t('fedi.boost_short') %></span>111 <span class="fedi-bigact-label"><%= _boosted ? t('tl.unboost') : t('fedi.boost_short') %></span> 111 112 </button> 112 113 </form> … … 185 186 .fedi-del-btn:hover { background: color-mix(in srgb, #d9534f 24%, transparent); } 186 187 </style> 188 189 <script> 190 /* Like/Boost toggle in place — POST via fetch, flip the button, stay on the page. */ 191 (function(){ 192 if (window.__fediReactWired) return; window.__fediReactWired = true; 193 document.addEventListener('submit', function(e){ 194 var f = e.target.closest && e.target.closest('.fedi-react-form'); 195 if (!f) return; 196 e.preventDefault(); 197 var btn = f.querySelector('button'); if (!btn || btn.disabled) return; 198 btn.disabled = true; 199 var body = new URLSearchParams(); 200 new FormData(f).forEach(function(v, k){ body.append(k, v); }); 201 fetch(f.action, { method: 'POST', body: body, headers: { 'X-Requested-With': 'fetch' }, credentials: 'same-origin' }) 202 .then(function(r){ return r.ok ? r.json() : null; }) 203 .then(function(j){ 204 if (j) { 205 var on = !!j.on; 206 btn.classList.toggle('is-on', on); 207 var lbl = btn.querySelector('.fedi-bigact-label'); 208 if (lbl) lbl.textContent = on ? (btn.getAttribute('data-on') || lbl.textContent) : (btn.getAttribute('data-off') || lbl.textContent); 209 } 210 }) 211 .catch(function(){}) 212 .then(function(){ btn.disabled = false; }); 213 }); 214 })(); 215 </script>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)