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 6.1
edited by XWikiGuest
on 2026/03/11 20:30
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -78,7 +78,6 @@
78 78  </style>
79 79  
80 80  <div id="ldsf-wrapper">
81 - <button id="ldsf-test-btn" style="background:#df691a;color:#fff;padding:8px 16px;border:none;border-radius:4px;cursor:pointer;margin-bottom:10px;">TEST KLIK</button>
82 82   <div id="ldsf-status">Laden...</div>
83 83   <div id="ldsf-bookmarks"></div>
84 84   <div id="ldsf-viewer-container">
... ... @@ -129,66 +129,36 @@
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 - })
132 + .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');
144 -
145 - (data.results || []).forEach(function(bm) {
137 + var html = '<ul>';
138 + (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);
141 + if (fname) { archiveCount++; ldsf_archiveMap[idx] = fname; }
142 + html += '<li>';
143 + if (fname) html += '<button class="sf-btn" onclick="ldsfOpen(' + idx + ')" title="Archief bekijken">&#128196;</button>';
144 + html += '<a href="' + bm.url + '" target="_blank">' + title + '</a></li>';
169 169   });
170 -
171 - container.innerHTML = '';
172 - container.appendChild(ul);
146 + html += '</ul>';
147 + 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  
178 -// Debug test button
179 -document.getElementById('ldsf-test-btn').addEventListener('click', function() {
180 - alert('archiveMap: ' + JSON.stringify(ldsf_archiveMap) + '\nurlToFile: ' + JSON.stringify(ldsf_urlToFile));
181 -});
182 -
183 183  // Load index then bookmarks
184 184  fetch(LDSF_WEBDAV + 'index.json', { headers: { 'Authorization': LDSF_AUTH } })
185 185  .then(function(r) { return r.ok ? r.json() : {}; })
186 186  .then(function(idx) {
187 - console.log('SingleFile index loaded:', idx);
188 188   Object.keys(idx).forEach(function(f) { ldsf_urlToFile[idx[f]] = f; });
189 189   ldsfLoadBookmarks();
190 190  })
191 -.catch(function(err) { console.log('SingleFile index FAILED:', err); ldsfLoadBookmarks(); });
160 +.catch(function() { ldsfLoadBookmarks(); });
192 192  </script>
193 193  {{/html}}
194 194