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

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

Summary

Details

Page properties
Content
... ... @@ -96,12 +96,23 @@
96 96   var LINKDING_TAG = 'Nuclear-&-Energy';
97 97   var LINKDING_COUNT = 20;
98 98  
99 - var WEBDAV_BASE = 'https://cloud.rhebergen.org/remote.php/dav/files/jan_rhebergen/SingleFile-Archives/';
99 + var SHARE_TOKEN = 'eT2X9ttBHK5GoEY';
100 + var WEBDAV_BASE = 'https://cloud.rhebergen.org/public.php/webdav/';
100 100   var INDEX_URL = WEBDAV_BASE + 'index.json';
101 - var NC_AUTH = 'Basic amFuX3JoZWJlcmdlbjpAWnMzUUwkJmZ4TVE=';
102 + var NC_AUTH = 'Basic ' + btoa(SHARE_TOKEN + ':');
102 102  
103 103   var urlToFile = {}; // reverse map: URL -> filename
105 + var archiveMap = {}; // button index -> filename
104 104  
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 +
105 105   // Load SingleFile index, then load bookmarks
106 106   fetch(INDEX_URL, { headers: { 'Authorization': NC_AUTH } })
107 107   .then(function(r) { return r.ok ? r.json() : {}; })
... ... @@ -126,15 +126,15 @@
126 126   var container = document.getElementById('ldsf-bookmarks');
127 127   var html = '<ul>';
128 128  
129 - (data.results || []).forEach(function(bm) {
140 + (data.results || []).forEach(function(bm, idx) {
130 130   var title = bm.title || bm.website_title || bm.url;
131 - var hasArchive = urlToFile[bm.url] || urlToFile[bm.url.replace(/\/$/, '')] || urlToFile[bm.url + '/'];
132 - if (hasArchive) archiveCount++;
142 + var fname = findArchive(bm.url);
143 + if (fname) archiveCount++;
133 133  
134 134   html += '<li>';
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>';
146 + if (fname) {
147 + archiveMap[idx] = fname;
148 + html += '<button class="sf-btn" onclick="ldsfOpen(' + idx + ')" title="Archief bekijken">&#128196;</button>';
138 138   }
139 139   html += '<a href="' + bm.url + '" target="_blank">' + title + '</a>';
140 140   html += '</li>';
... ... @@ -149,17 +149,19 @@
149 149   });
150 150   }
151 151  
163 + // Open archive by index
164 + window.ldsfOpen = function(idx) {
165 + var filename = archiveMap[idx];
166 + if (!filename) return;
167 + ldsfShowArchive(filename);
168 + };
169 +
152 152   // Show archive in viewer panel
153 - window.ldsfShowArchive = function(encodedFilename, btn) {
154 - var filename = decodeURIComponent(encodedFilename);
171 + window.ldsfShowArchive = function(filename) {
155 155   var container = document.getElementById('ldsf-viewer-container');
156 156   var frame = document.getElementById('ldsf-viewer-frame');
157 157   var titleEl = document.getElementById('ldsf-viewer-title');
158 158  
159 - // Toggle active button
160 - document.querySelectorAll('#ldsf-bookmarks .sf-btn').forEach(function(b) { b.classList.remove('active'); });
161 - btn.classList.add('active');
162 -
163 163   titleEl.textContent = filename.replace(/\.html?$/i, '');
164 164   container.style.display = 'block';
165 165   frame.srcdoc = '<p style="padding:20px;color:#666">Laden...</p>';