From d23327faeeb73ffcca8d299dd39bd817a5982083 Mon Sep 17 00:00:00 2001
From: qkral <61017598+qkral@users.noreply.github.com>
Date: Sun, 19 Jan 2025 20:23:22 +0100
Subject: [PATCH 1/4] inclusion of summarizepaper toggle in arxiv-browse
---
browse/static/js/summarizepaper.js | 231 +++++++++++++++++++++++++++++
browse/static/js/toggle-labs.js | 21 +++
2 files changed, 252 insertions(+)
create mode 100644 browse/static/js/summarizepaper.js
diff --git a/browse/static/js/summarizepaper.js b/browse/static/js/summarizepaper.js
new file mode 100644
index 000000000..d4bc16e0c
--- /dev/null
+++ b/browse/static/js/summarizepaper.js
@@ -0,0 +1,231 @@
+(function () {
+ const container = document.getElementById("summarizepaper-output");
+ const toggle = document.getElementById("summarizepaper-toggle");
+
+ // Preload logo for faster rendering
+ const logoLink = document.createElement('link');
+ logoLink.rel = 'preload';
+ logoLink.as = 'image';
+ logoLink.href = 'https://summarizepaper.com/static/summarizer/images/logo.dd1579dd7c43.png';
+ document.head.appendChild(logoLink);
+
+ // Removed prefetch link to prevent CORB issues
+
+ // If no container or toggle, exit early
+ if (!container || !toggle) {
+ console.error('SummarizePaper: Missing container or toggle');
+ return;
+ }
+
+ // Simple cache to prevent unnecessary regeneration
+ const contentCache = {
+ arxivId: null,
+ html: null
+ };
+
+ // Function to clear content
+ function clearContent() {
+ container.innerHTML = "";
+ container.style.display = "none";
+ container.setAttribute('aria-hidden', 'true');
+ }
+
+ // Function to show content
+ function showContent() {
+ // Get the arXiv paper ID from the URL
+ const currentUrl = window.location.href;
+ const arxivId = currentUrl.split('/').pop();
+ const summarizepaperUrl = `https://summarizepaper.com/arxiv-id/${arxivId}/`;
+ const summarizepaperLogo = 'https://summarizepaper.com/static/summarizer/images/logo.dd1579dd7c43.png';
+
+ // Use cached content if available for the same arxiv ID
+ if (contentCache.arxivId === arxivId && contentCache.html) {
+ container.innerHTML = contentCache.html;
+ container.style.display = "block";
+ container.setAttribute('aria-hidden', 'false');
+ return;
+ }
+
+ const html = `
+
+
+
+
+
+
+
+ SummarizePaper.com
+
+
+
+
+ Get instant access to AI-powered insights:
+
+
+
+ ${[
+ 'Comprehensive global summary of the paper',
+ 'Key points and main findings',
+ 'Layman\'s explanation for everyone',
+ 'Blog post-style summary with clear explanations'
+ ].map((feature, index) => `
+
+ ${index + 1}
+ ${feature}
+
+ `).join('')}
+
+
+
+
+ 💬
+
+
+
Interactive AI Chat
+
Ask questions and get instant answers about the paper