Changeset 780a7c6 in Klonkt for src/assets/js/guardian.js
- Timestamp:
- 07/24/2026 07:44:15 PM (7 weeks ago)
- Branches:
- main
- Children:
- b5924eb
- Parents:
- c26cc18
- File:
-
- 1 edited
-
src/assets/js/guardian.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/js/guardian.js
rc26cc18 r780a7c6 47 47 } 48 48 49 // ── 3. Pending offers I sent ─────────────────────────────────────────── 49 // ── 3. Offers I am a party to (sent, or a co-guardianship to co-approve) ─ 50 function answer(offerId, decision, btn) { 51 if (btn) btn.disabled = true; 52 fetch('/guardian/offer', { 53 method: 'POST', headers: { 'Content-Type': 'application/json' }, 54 body: JSON.stringify({ offer: offerId, answer: decision, site: S.site }), 55 }).then(refresh); 56 } 57 function offerCard(o) { 58 var card = el('div', 'g-card'); 59 var row = el('div', 'row'); 60 var subject = o['shaer:iAmCandidate'] 61 ? handleOf(o['shaer:ward'], o['shaer:wardHandle']) // my sent offer: about the ward 62 : handleOf(o['shaer:candidate'], o['shaer:candidateHandle']); // co-guard: who wants in 63 row.appendChild(el('span', 'who grow', subject)); 64 if (o['shaer:iAmCandidate']) { 65 // My own offer, waiting for the others to accept. 66 row.appendChild(el('span', 'tag wait', T.pending)); 67 var rt = el('button', 'quiet small', T.retract); 68 rt.addEventListener('click', function () { answer(o.id, 'reject', rt); }); 69 row.appendChild(rt); 70 } else if (o['shaer:needsMyAccept']) { 71 // A co-guardianship offer for a ward I already guard: my call. 72 row.appendChild(el('span', 'tag co', T.coguard)); 73 var ac = el('button', 'small', T.accept); 74 ac.addEventListener('click', function () { answer(o.id, 'accept', ac); }); 75 var rj = el('button', 'quiet small', T.reject); 76 rj.addEventListener('click', function () { answer(o.id, 'reject', rj); }); 77 row.appendChild(ac); row.appendChild(rj); 78 } else { 79 row.appendChild(el('span', 'tag wait', T.awaiting_others)); 80 } 81 card.appendChild(row); 82 return card; 83 } 50 84 function renderPending() { 51 85 var list = document.getElementById('pending-list'); 52 86 list.textContent = ''; 53 var pend = S.pendingOffers || []; 54 pend.forEach(function (w) { 55 var card = el('div', 'g-card'); 56 var row = el('div', 'row'); 57 row.appendChild(el('span', 'who grow', handleOf(w.other_uri, w.other_handle))); 58 row.appendChild(el('span', 'tag wait', T.pending)); 59 var btn = el('button', 'quiet small', T.retract); 60 btn.addEventListener('click', function () { remove(w.other_uri, btn); }); 61 row.appendChild(btn); 62 card.appendChild(row); 63 list.appendChild(card); 64 }); 65 show('pending-section', pend.length > 0); 87 var offers = S.offers || []; 88 offers.forEach(function (o) { list.appendChild(offerCard(o)); }); 89 show('pending-section', offers.length > 0); 66 90 } 67 91
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)