This commit is contained in:
Ross
2025-12-06 20:40:09 +00:00
parent 2663b10ebe
commit c30cb45fc3
+10 -10
View File
@@ -201,17 +201,17 @@
// Match paths like /cards/preview/123/ optionally with trailing slash // Match paths like /cards/preview/123/ optionally with trailing slash
var m = path.match(/\/cards\/preview\/(\d+)\/?$/); var m = path.match(/\/cards\/preview\/(\d+)\/?$/);
if(m){ if(m){
var root = document.getElementById('modal-root'); var root = document.getElementById('modal-root');
// If server already rendered a modal fragment into #modal-root, do nothing. // If server already rendered a modal fragment into #modal-root, do nothing.
if(root && root.innerHTML && root.innerHTML.trim().length > 0) return; if(root && root.innerHTML && root.innerHTML.trim().length > 0) return;
var url = window.location.pathname + window.location.search; var url = window.location.pathname + window.location.search;
fetch(url, {credentials: 'same-origin'}) fetch(url, {credentials: 'same-origin'})
.then(function(r){ if(!r.ok) throw new Error('fetch failed'); return r.text(); }) .then(function(r){ if(!r.ok) throw new Error('fetch failed'); return r.text(); })
.then(function(html){ .then(function(html){
var root = document.getElementById('modal-root'); var root = document.getElementById('modal-root');
if(root){ root.innerHTML = html; } if(root){ root.innerHTML = html; }
}).catch(function(){ /* ignore */ }); }).catch(function(){ /* ignore */ });
} }
}catch(e){ /* ignore */ } }catch(e){ /* ignore */ }
} }
if(document.readyState === 'loading') document.addEventListener('DOMContentLoaded', tryOpenPreviewFromUrl); if(document.readyState === 'loading') document.addEventListener('DOMContentLoaded', tryOpenPreviewFromUrl);