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

From version 8.1
edited by XWikiGuest
on 2026/03/11 20:33
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
... ... @@ -135,44 +135,38 @@
135 135   var total = data.count || 0;
136 136   var archiveCount = 0;
137 137   var container = document.getElementById('ldsf-bookmarks');
138 - var ul = document.createElement('ul');
138 + var html = '<ul>';
139 139  
140 - (data.results || []).forEach(function(bm) {
140 + (data.results || []).forEach(function(bm, idx) {
141 141   var title = bm.title || bm.website_title || bm.url;
142 142   var fname = ldsfFindArchive(bm.url);
143 - if (fname) archiveCount++;
144 -
145 - var li = document.createElement('li');
146 -
147 - if (fname) {
148 - var btn = document.createElement('button');
149 - btn.className = 'sf-btn';
150 - btn.title = 'Archief bekijken';
151 - btn.textContent = '\uD83D\uDCC4';
152 - btn.addEventListener('click', (function(f) {
153 - return function() { ldsfShowArchive(f); };
154 - })(fname));
155 - li.appendChild(btn);
156 - }
157 -
158 - var a = document.createElement('a');
159 - a.href = bm.url;
160 - a.target = '_blank';
161 - a.textContent = title;
162 - li.appendChild(a);
163 - 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>';
164 164   });
165 165  
166 - container.innerHTML = '';
167 - container.appendChild(ul);
150 + html += '</ul>';
151 + container.innerHTML = html;
168 168   document.getElementById('ldsf-status').textContent = total + ' bookmarks, ' + archiveCount + ' met archief';
169 169   })
170 170   .catch(function(err) { document.getElementById('ldsf-status').textContent = 'Fout: ' + err.message; });
171 171  }
172 172  
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 +
173 173  // Debug test button
174 174  document.getElementById('ldsf-test-btn').addEventListener('click', function() {
175 - alert('Klik werkt! archiveMap keys: ' + Object.keys(ldsf_archiveMap).join(','));
169 + alert('archiveMap: ' + JSON.stringify(ldsf_archiveMap) + '\nurlToFile: ' + JSON.stringify(ldsf_urlToFile));
176 176  });
177 177  
178 178  // Load index then bookmarks
... ... @@ -179,10 +179,11 @@
179 179  fetch(LDSF_WEBDAV + 'index.json', { headers: { 'Authorization': LDSF_AUTH } })
180 180  .then(function(r) { return r.ok ? r.json() : {}; })
181 181  .then(function(idx) {
176 + console.log('SingleFile index loaded:', idx);
182 182   Object.keys(idx).forEach(function(f) { ldsf_urlToFile[idx[f]] = f; });
183 183   ldsfLoadBookmarks();
184 184  })
185 -.catch(function() { ldsfLoadBookmarks(); });
180 +.catch(function(err) { console.log('SingleFile index FAILED:', err); ldsfLoadBookmarks(); });
186 186  </script>
187 187  {{/html}}
188 188