Last modified by XWikiGuest on 2026/03/11 21:04

From version 10.1
edited by XWikiGuest
on 2026/03/11 20:44
Change comment: There is no comment for this version
To version 11.1
edited by XWikiGuest
on 2026/03/11 20:49
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -129,52 +129,41 @@
129 129  
130 130  function ldsfLoadBookmarks() {
131 131   var apiUrl = LDSF_LINKDING_URL + '?limit=' + LDSF_COUNT + '&q=%23' + encodeURIComponent(LDSF_TAG);
132 - console.log('Fetching bookmarks:', apiUrl);
133 133   fetch(apiUrl, { headers: { 'Authorization': 'Token ' + LDSF_TOKEN } })
134 - .then(function(r) {
135 - console.log('Linkding response status:', r.status, r.headers.get('content-type'));
136 - if (!r.ok) return r.text().then(function(t) { throw new Error('HTTP ' + r.status + ': ' + t.substring(0, 200)); });
137 - return r.json();
138 - })
133 + .then(function(r) { return r.json(); })
139 139   .then(function(data) {
140 140   var total = data.count || 0;
141 141   var archiveCount = 0;
142 142   var container = document.getElementById('ldsf-bookmarks');
143 - var ul = document.createElement('ul');
138 + var html = '<ul>';
144 144  
145 - (data.results || []).forEach(function(bm) {
140 + (data.results || []).forEach(function(bm, idx) {
146 146   var title = bm.title || bm.website_title || bm.url;
147 147   var fname = ldsfFindArchive(bm.url);
148 - if (fname) archiveCount++;
149 -
150 - var li = document.createElement('li');
151 -
152 - if (fname) {
153 - var btn = document.createElement('button');
154 - btn.className = 'sf-btn';
155 - btn.title = 'Archief bekijken';
156 - btn.textContent = '\uD83D\uDCC4';
157 - btn.addEventListener('click', (function(f) {
158 - return function() { ldsfShowArchive(f); };
159 - })(fname));
160 - li.appendChild(btn);
161 - }
162 -
163 - var a = document.createElement('a');
164 - a.href = bm.url;
165 - a.target = '_blank';
166 - a.textContent = title;
167 - li.appendChild(a);
168 - ul.appendChild(li);
143 + if (idx < 3) console.log('BM[' + idx + ']:', bm.url, '-> match:', fname);
144 + if (fname) { archiveCount++; ldsf_archiveMap[String(idx)] = fname; }
145 + html += '<li>';
146 + if (fname) html += '<span class="sf-btn" data-sfidx="' + idx + '" title="Archief bekijken">&#128196;</span>';
147 + html += '<a href="' + bm.url + '" target="_blank">' + title + '</a></li>';
169 169   });
170 170  
171 - container.innerHTML = '';
172 - container.appendChild(ul);
150 + html += '</ul>';
151 + container.innerHTML = html;
173 173   document.getElementById('ldsf-status').textContent = total + ' bookmarks, ' + archiveCount + ' met archief';
174 174   })
175 175   .catch(function(err) { document.getElementById('ldsf-status').textContent = 'Fout: ' + err.message; });
176 176  }
177 177  
157 +// Global click handler for archive buttons
158 +document.addEventListener('click', function(e) {
159 + var el = e.target;
160 + if (el && el.getAttribute && el.getAttribute('data-sfidx') !== null) {
161 + var idx = el.getAttribute('data-sfidx');
162 + console.log('Archive button clicked, idx:', idx, 'file:', ldsf_archiveMap[idx]);
163 + if (ldsf_archiveMap[idx]) ldsfShowArchive(ldsf_archiveMap[idx]);
164 + }
165 +}, true);
166 +
178 178  // Debug test button
179 179  document.getElementById('ldsf-test-btn').addEventListener('click', function() {
180 180   alert('archiveMap: ' + JSON.stringify(ldsf_archiveMap) + '\nurlToFile: ' + JSON.stringify(ldsf_urlToFile));