Changeset 072a242 in Klonkt for src/views/pages
- Timestamp:
- 07/21/2026 03:26:24 AM (7 weeks ago)
- Branches:
- main
- Children:
- b9beb16
- Parents:
- dede82e
- git-author:
- Robin <roboburr@…> (07/21/2026 03:26:22 AM)
- git-committer:
- Robin <roboburr@…> (07/21/2026 03:26:24 AM)
- File:
-
- 1 edited
-
src/views/pages/paid-gate.ejs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/views/pages/paid-gate.ejs
rdede82e r072a242 37 37 var base = "<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase ? siteUrlBase : '') %>"; 38 38 var slug = "<%= pgSlug %>"; 39 var hasPatron = <%= _hasPatron ? 'true' : 'false' %>; 39 40 var btn = document.getElementById('pg-unlock'); 40 41 var status = document.getElementById('pg-status'); 41 var page = document.getElementById('pg-page');42 42 function say(msg, err) { status.hidden = false; status.textContent = msg; status.classList.toggle('is-err', !!err); } 43 43 function toLink() { location.href = base + '/paid/link?post=' + encodeURIComponent(slug); } 44 44 45 if (!window.SimpleWebAuthnBrowser || !window.PublicKeyCredential) { btn.textContent = 'Word supporter'; btn.addEventListener('click', toLink); return; } 45 // No WebAuthn here: an assertion is impossible. With a Patreon page there is 46 // already a "Word supporter" button, so hide the (dead) unlock button rather 47 // than turn it into a second "Word supporter". Without one, this IS the button. 48 if (!window.SimpleWebAuthnBrowser || !window.PublicKeyCredential) { 49 if (hasPatron) { btn.style.display = 'none'; } 50 else { btn.textContent = 'Word supporter'; btn.addEventListener('click', toLink); } 51 return; 52 } 46 53 47 54 btn.addEventListener('click', function () { … … 61 68 .then(function (r) { return r.json().then(function (j) { return { status: r.status, j: j }; }); }) 62 69 .then(function (res) { 63 if (res.j && res.j.ok) { 64 // Swap the gate for the full post, client-side (no cookie kept). 65 var h = document.createElement('div'); 66 h.innerHTML = (res.j.title ? '<h1 class="post-title">' + res.j.title + '</h1>' : '') + 67 '<div class="post-content">' + res.j.html + '</div>'; 68 page.replaceWith(h); 70 if (res.j && res.j.ok && res.j.redirect) { 71 // Reload the real post page via the one-shot unlock capability, so it 72 // renders through its normal template (layout, styles, audio). 73 location.href = res.j.redirect; 69 74 } else if (res.status === 403) { 70 75 toLink(); // no valid passkey yet (or lapsed tier): link via Patreon
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)