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

From version 3.1
edited by XWikiGuest
on 2026/03/11 20:17
Change comment: There is no comment for this version
To version 1.1
edited by XWikiGuest
on 2026/03/11 19:55
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -96,23 +96,12 @@
96 96   var LINKDING_TAG = 'Nuclear-&-Energy';
97 97   var LINKDING_COUNT = 20;
98 98  
99 - var SHARE_TOKEN = 'eT2X9ttBHK5GoEY';
100 - var WEBDAV_BASE = 'https://cloud.rhebergen.org/public.php/webdav/';
99 + var WEBDAV_BASE = 'https://cloud.rhebergen.org/remote.php/dav/files/jan_rhebergen/SingleFile-Archives/';
101 101   var INDEX_URL = WEBDAV_BASE + 'index.json';
102 - var NC_AUTH = 'Basic ' + btoa(SHARE_TOKEN + ':');
101 + var NC_AUTH = 'Basic amFuX3JoZWJlcmdlbjpAWnMzUUwkJmZ4TVE=';
103 103  
104 104   var urlToFile = {}; // reverse map: URL -> filename
105 - var archiveMap = {}; // button index -> filename
106 106  
107 - function findArchive(url) {
108 - // Try exact match, with/without trailing slash, and without query string
109 - var variants = [url, url.replace(/\/$/, ''), url + '/', url.replace(/\?.*$/, '')];
110 - for (var i = 0; i < variants.length; i++) {
111 - if (urlToFile[variants[i]]) return urlToFile[variants[i]];
112 - }
113 - return null;
114 - }
115 -
116 116   // Load SingleFile index, then load bookmarks
117 117   fetch(INDEX_URL, { headers: { 'Authorization': NC_AUTH } })
118 118   .then(function(r) { return r.ok ? r.json() : {}; })
... ... @@ -137,15 +137,15 @@
137 137   var container = document.getElementById('ldsf-bookmarks');
138 138   var html = '<ul>';
139 139  
140 - (data.results || []).forEach(function(bm, idx) {
129 + (data.results || []).forEach(function(bm) {
141 141   var title = bm.title || bm.website_title || bm.url;
142 - var fname = findArchive(bm.url);
143 - if (fname) archiveCount++;
131 + var hasArchive = urlToFile[bm.url] || urlToFile[bm.url.replace(/\/$/, '')] || urlToFile[bm.url + '/'];
132 + if (hasArchive) archiveCount++;
144 144  
145 145   html += '<li>';
146 - if (fname) {
147 - html += '<button class="sf-btn" data-idx="' + idx + '" title="Archief bekijken">&#128196;</button>';
148 - archiveMap[idx] = fname;
135 + if (hasArchive) {
136 + var fname = urlToFile[bm.url] || urlToFile[bm.url.replace(/\/$/, '')] || urlToFile[bm.url + '/'];
137 + html += '<button class="sf-btn" onclick="ldsfShowArchive(\'' + encodeURIComponent(fname).replace(/'/g, "\\'") + '\', this)" title="Archief bekijken">&#128196;</button>';
149 149   }
150 150   html += '<a href="' + bm.url + '" target="_blank">' + title + '</a>';
151 151   html += '</li>';
... ... @@ -154,16 +154,6 @@
154 154   html += '</ul>';
155 155   container.innerHTML = html;
156 156   document.getElementById('ldsf-status').textContent = total + ' bookmarks, ' + archiveCount + ' met archief';
157 -
158 - // Event delegation for archive buttons
159 - container.addEventListener('click', function(e) {
160 - var btn = e.target.closest('.sf-btn');
161 - if (!btn) return;
162 - var idx = btn.getAttribute('data-idx');
163 - if (idx !== null && archiveMap[idx]) {
164 - ldsfShowArchive(archiveMap[idx], btn);
165 - }
166 - });
167 167   })
168 168   .catch(function(err) {
169 169   document.getElementById('ldsf-status').textContent = 'Fout: ' + err.message;
... ... @@ -171,7 +171,8 @@
171 171   }
172 172  
173 173   // Show archive in viewer panel
174 - window.ldsfShowArchive = function(filename, btn) {
153 + window.ldsfShowArchive = function(encodedFilename, btn) {
154 + var filename = decodeURIComponent(encodedFilename);
175 175   var container = document.getElementById('ldsf-viewer-container');
176 176   var frame = document.getElementById('ldsf-viewer-frame');
177 177   var titleEl = document.getElementById('ldsf-viewer-title');