tractatus/public/js/check-version.js
TheFlow ac2db33732 fix(submissions): restructure Economist package and fix article display
- Create Economist SubmissionTracking package correctly:
  * mainArticle = full blog post content
  * coverLetter = 216-word SIR— letter
  * Links to blog post via blogPostId
- Archive 'Letter to The Economist' from blog posts (it's the cover letter)
- Fix date display on article cards (use published_at)
- Target publication already displaying via blue badge

Database changes:
- Make blogPostId optional in SubmissionTracking model
- Economist package ID: 68fa85ae49d4900e7f2ecd83
- Le Monde package ID: 68fa2abd2e6acd5691932150

Next: Enhanced modal with tabs, validation, export

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 08:47:42 +13:00

60 lines
2 KiB
JavaScript

/**
* Version Check Script
* Tests if browser is using cached JavaScript files
*/
// Get the version from the main docs page
fetch('/docs.html?' + Date.now())
.then(r => r.text())
.then(html => {
const match = html.match(/docs-app\.js\?v=(\d+)/);
const version = match ? match[1] : 'NOT FOUND';
const expected = '1759828916';
const correct = version === expected;
// Now fetch the actual JavaScript
return fetch('/js/docs-app.js?v=' + version + '&' + Date.now())
.then(r => r.text())
.then(js => {
const hasNewHandler = js.includes('window.location.href=');
const hasOldHandler = js.includes('event.stopPropagation()');
let html = '';
if (correct && hasNewHandler) {
html = `
<div class="box good">
<h2>✅ Version is CORRECT</h2>
<p>JavaScript version: <code>${version}</code></p>
<p>Handler includes: <code>window.location.href</code></p>
<p><strong>Downloads should work now!</strong></p>
</div>
`;
} else {
html = `
<div class="box bad">
<h2>❌ Version is WRONG</h2>
<p>JavaScript version loaded: <code>${version}</code></p>
<p>Expected: <code>${expected}</code></p>
<p>Has new handler: ${hasNewHandler ? '✅ YES' : '❌ NO'}</p>
<p><strong>Your browser is serving cached files!</strong></p>
</div>
<div class="box">
<h3>Cached JavaScript Snippet:</h3>
<pre>${js.substring(js.indexOf('onclick='), js.indexOf('onclick=') + 200).replace(/</g, '&lt;').replace(/>/g, '&gt;')}</pre>
</div>
`;
}
document.getElementById('results').innerHTML = html;
});
})
.catch(err => {
document.getElementById('results').innerHTML = `
<div class="box bad">
<h2>Error</h2>
<p>${err.message}</p>
</div>
`;
});