-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
606 lines (544 loc) · 26 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title id="metaTitle">AI Summary Helper</title>
<meta id="metaDescription" name="description" content="AI Summary Helper enhances your browsing experience.">
<!-- icon -->
<link rel="icon" type="image/svg+xml" href="icon.svg">
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Lato:wght@400;700&display=swap" rel="stylesheet">
<!-- hreflang tags -->
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=en" hreflang="en">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=es" hreflang="es">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=de" hreflang="de">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=fr" hreflang="fr">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=it" hreflang="it">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=pt" hreflang="pt">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=nl" hreflang="nl">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=jp" hreflang="jp">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=cn" hreflang="cn">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=ru" hreflang="ru">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=kr" hreflang="kr">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=ar" hreflang="ar">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=ua" hreflang="ua">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=pl" hreflang="pl">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=ind" hreflang="ind">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=th" hreflang="th">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=sv" hreflang="sv">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=da" hreflang="da">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=no" hreflang="no">
<link rel="alternate" href="https://philffm.github.io/ai-summary-helper/?lang=id" hreflang="id">
<meta name="google-site-verification" content="_QcmSOybAqnxQ1YH95ay00G4LZgwxLg-1Pb50QBpI2c" />
<meta name="robots" content="follow, index">
<!-- Open Graph Meta Tags -->
<meta property="og:title" content="AI Summary Helper">
<meta property="og:description" content="AI Summary Helper - Summarize the web in your language">
<meta property="og:image" content="https://philffm.github.io/ai-summary-helper/og-share.jpeg">
<meta property="og:url" content="https://philffm.github.io/ai-summary-helper/">
<meta property="og:type" content="website">
<script>
let data; // Declare data in a broader scope
async function loadContent(lang = 'en') {
try {
let translations;
const languageMap = {
'en': 'en',
'en-US': 'en',
'en-GB': 'en',
'es': 'es',
'es-ES': 'es',
'es-MX': 'es',
'de': 'de',
'de-DE': 'de',
'fr': 'fr',
'fr-FR': 'fr',
'it': 'it',
'it-IT': 'it',
'pt': 'pt',
'pt-PT': 'pt',
'pt-BR': 'pt',
'nl': 'nl',
'nl-NL': 'nl',
'ru': 'ru',
'ru-RU': 'ru',
'ua': 'ua',
'uk-UA': 'ua',
'pl': 'pl',
'pl-PL': 'pl',
'sv': 'sv',
'sv-SE': 'sv',
'da': 'da',
'da-DK': 'da',
'jp': 'jp',
'ja': 'jp',
'ja-JP': 'jp',
'cn': 'cn',
'zh': 'cn',
'zh-CN': 'cn',
'zh-Hans-CN': 'cn',
'zh-TW': 'cn',
'kr': 'kr',
'ko': 'kr',
'ko-KR': 'kr',
'hi': 'hi',
'hi-IN': 'hi',
'mr': 'hi',
'mr-IN': 'hi',
'th': 'th',
'th-TH': 'th',
'id': 'ind-bahasa',
'id-ID': 'ind-bahasa',
'ind-bahasa': 'ind-bahasa',
'ar': 'ar',
'ar-SA': 'ar',
'tr': 'tr',
'tr-TR': 'tr',
'bg': 'bg',
'bg-BG': 'bg',
'ro': 'ro',
'ro-RO': 'ro'
};
// Use the mapped language code or default to English
const mappedLang = languageMap[lang] || 'en';
const response = await fetch(`lang/${mappedLang}.json`);
if (!response.ok) {
throw new Error(`Failed to load language file: ${mappedLang}`);
}
data = await response.json();
if (!data.aisummary) {
const enResponse = await fetch('lang/en.json');
if (!enResponse.ok) {
throw new Error('Failed to load English language file for aisummary');
}
const enData = await enResponse.json();
data.aisummary = enData.aisummary;
}
// Update the page content with the loaded data
document.getElementById('metaTitle').textContent = data.title;
document.getElementById('metaDescription').setAttribute('content', data.aboutText);
document.getElementById('title').textContent = data.title;
document.getElementById('aboutText').innerHTML = convertMarkdownLinks(data.aboutText);
const featureList = document.getElementById('featureList');
featureList.innerHTML = data.featureList.map(item => `
<div class="feature-card">
${convertMarkdownLinks(item)}
</div>
`).join('');
document.getElementById('localizedFeature').textContent = data.localizedFeature.headline;
document.getElementById('localizedFeatureText').innerHTML = convertMarkdownLinks(data.localizedFeature.text);
document.getElementById('proposeFeature').textContent = data.proposeFeature;
document.getElementById('proposeFeatureText').innerHTML = convertMarkdownLinks(data.proposeFeatureText);
document.getElementById('privacyNote').textContent = data.privacyNote;
document.getElementById('privacyNoteText').innerHTML = convertMarkdownLinks(data.privacyNoteText);
document.getElementById('funMessage').textContent = data.funMessage;
const changelogList = document.getElementById('changelogList');
changelogList.innerHTML = data.changelogList.map(item => `<li>${convertMarkdownLinks(item)}</li>`).join('');
document.getElementById('aboutCreator').textContent = data.aboutCreator;
document.getElementById('creatorText').textContent = data.creatorText;
document.getElementById('changelog').textContent = data.changelog;
document.getElementById('whyHelper').textContent = data.whyHelper;
document.getElementById('whyHelperList').textContent = data.whyHelperList;
const whyHelperList = document.getElementById('whyHelperList');
whyHelperList.innerHTML = data.whyHelperList.map(item => `<li>${convertMarkdownLinks(item)}</li>`).join('');
document.getElementById('getStarted').textContent = data.getStarted;
document.getElementById('getStartedText').innerHTML = convertMarkdownLinks(data.getStartedText);
document.getElementById('feedbackSupport').textContent = data.feedbackSupport;
document.getElementById('feedbackSupportText').innerHTML = convertMarkdownLinks(data.feedbackSupportText);
} catch (error) {
console.error('Error loading content:', error);
}
}
function convertMarkdownLinks(text) {
return text.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
}
async function createLanguageButtons() {
try {
const response = await fetch('translations.json');
const translations = await response.json();
const languageSection = document.querySelector('.language-section');
// Always add the English button
const englishButton = document.createElement('button');
englishButton.textContent = '🇬🇧 English';
englishButton.onclick = () => changeLanguage('en');
languageSection.appendChild(englishButton);
// Create buttons for all languages listed in translations.json
for (const lang of translations.languages) {
if (lang.code === 'en') continue; // Skip English as it's already added
const button = document.createElement('button');
button.textContent = `${lang.emoji} ${lang.name}`;
button.onclick = () => changeLanguage(lang.code);
languageSection.appendChild(button);
}
} catch (error) {
console.error('Error creating language buttons:', error);
}
}
function changeLanguage(lang) {
loadContent(lang);
const url = new URL(window.location);
url.searchParams.set('lang', lang);
window.history.pushState({}, '', url);
// Update the language menu button text
fetch('translations.json')
.then(response => response.json())
.then(data => {
const currentLang = data.languages.find(l => l.code === lang);
if (currentLang) {
document.getElementById('languageMenuButton').textContent = `${currentLang.emoji} ${currentLang.name}`;
}
})
.catch(error => console.error('Error updating language button:', error));
}
async function loadBlogPosts() {
try {
const response = await fetch('blog/blogPosts.json');
const posts = await response.json();
const blogPostsContainer = document.querySelector('.blog-posts');
posts.forEach(post => {
const article = document.createElement('article');
article.classList.add('blog-post');
article.innerHTML = `
<h3>${post.title}</h3>
<p><strong>Date:</strong> ${post.date}</p>
<p>${post.description} <a href="blog/${post.link}">Read more</a></p>
`;
blogPostsContainer.appendChild(article);
});
} catch (error) {
console.error('Error loading blog posts:', error);
}
}
window.onload = () => {
const urlParams = new URLSearchParams(window.location.search);
let lang = urlParams.get('lang');
// Detect browser language if no language is set in the URL
if (!lang) {
const browserLang = navigator.language || navigator.languages[0];
lang = browserLang.split('-')[0]; // Use the language code (e.g., 'en' from 'en-US')
}
loadContent(lang);
createLanguageButtons();
loadBlogPosts(); // Load blog posts on page load
// Set the initial language button text
fetch('translations.json')
.then(response => response.json())
.then(data => {
const currentLang = data.languages.find(l => l.code === lang);
if (currentLang) {
document.getElementById('languageMenuButton').textContent = `${currentLang.emoji} ${currentLang.name}`;
}
})
.catch(error => console.error('Error setting initial language button:', error));
};
document.addEventListener("DOMContentLoaded", function() {
// Initialize feature cards auto-scroll
const container = document.querySelector('.feature-cards-container');
const cards = Array.from(container.querySelectorAll('.feature-card'));
let scrollAmount = 0;
const scrollStep = 1; // Adjust this value to control the speed
const scrollInterval = 20; // Adjust this value to control the smoothness
// Duplicate the cards to create an infinite loop effect
cards.forEach(card => {
const clone = card.cloneNode(true);
container.appendChild(clone);
});
// Auto-scroll function
function autoScroll() {
scrollAmount += scrollStep;
if (scrollAmount >= container.scrollWidth / 2) {
scrollAmount = 0; // Reset scroll amount to loop
}
container.scrollTo({
left: scrollAmount,
behavior: 'smooth' // Smooth scrolling
});
}
// Start auto-scrolling
setInterval(autoScroll, scrollInterval);
// Initialize language menu button
const languageMenuButton = document.getElementById('languageMenuButton');
const languageMenu = document.getElementById('languageMenu');
languageMenuButton.addEventListener('click', () => {
languageMenu.classList.toggle('show');
if (languageMenu.classList.contains('show')) {
const buttons = languageMenu.querySelectorAll('button');
buttons.forEach((button, index) => {
button.style.setProperty('--delay', `${index * 0.03}s`);
});
}
});
// Initialize extension button
document.getElementById('extensionButton').addEventListener('click', function() {
const extensionUI = document.getElementById('extensionUI');
extensionUI.classList.toggle('hidden');
if (!extensionUI.classList.contains('hidden')) {
const buttonRect = this.getBoundingClientRect();
extensionUI.style.position = 'absolute';
extensionUI.style.top = `${buttonRect.bottom + window.scrollY}px`; // Position below the button
extensionUI.style.left = `${buttonRect.left + window.scrollX + buttonRect.width - extensionUI.offsetWidth}px`; // Center horizontally
}
});
// Initialize summarize button
document.getElementById('extensionUI').addEventListener('click', function() {
if (data && data.aisummary) {
const summarySection = document.createElement('section');
summarySection.classList.add('padding-h-m');
extensionUI.classList.add('hidden');
summarySection.innerHTML = data.aisummary;
console.log(data.aisummary);
const featuresSection = document.getElementById('features-section');
featuresSection.parentNode.insertBefore(summarySection, featuresSection);
} else {
console.error('Summary data is not available');
}
});
// Fetch languages from a JSON file or define them directly
fetch('translations.json')
.then(response => response.json())
.then(data => {
const languages = data.languages; // Assuming the JSON structure has a 'languages' array
languages.forEach(lang => {
const button = document.createElement('button');
button.textContent = `${lang.emoji} ${lang.name}`;
button.onclick = () => {
changeLanguage(lang.code);
languageMenuButton.textContent = `${lang.emoji} ${lang.name}`;
languageMenu.classList.remove('show');
};
languageMenu.appendChild(button);
});
})
.catch(error => console.error('Error loading languages:', error));
});
</script>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//analytics.philwornath.de/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<div class="window-frame">
<div class="window-title-bar">
<div class="window-controls">
<button class="window-button minimize"></button>
<button class="window-button maximize"></button>
<button class="window-button close"></button>
</div>
<div class="window-row">
<div class="navigation-buttons">
<button class="navigation-button">
<span>◀</span> <!-- Left chevron -->
</button>
<button class="navigation-button">
<span>▶</span> <!-- Right chevron -->
</button>
</div>
<div class="address-bar">
<img id="logoIcon" src="icon.svg" alt="AI Summary Helper Icon" style="width: 32px; height: 32px;">
<h1 id="title" class="window-title">AI Summary Helper</h1>
<button id="languageMenuButton" class="buttonIcon">🌍 Language</button>
</div>
<!-- Extension button with tooltip -->
<button class="extension-button" id="extensionButton">
<img src="icon.svg" alt="AI Summary Helper Icon" style="width: 32px; height: 32px;">
</button>
</div>
</div>
<div id="languageMenu" class="language-menu hidden">
<!-- Language options will be dynamically inserted here -->
</div>
<section id="features-section">
<!-- Optional: Scroll Buttons -->
<div class="feature-cards-wrapper">
<div id="featureList" class="feature-cards-container">
<!-- Feature cards will be dynamically inserted here -->
</div>
</div>
</section>
<div class="window-content">
<header>
<img src="aish.png" alt="AI Summary Helper Preview" style="max-width: 100%;">
<p id="aboutText"></p>
<a class="primary-option" target="_blank" href="https://philwornath.gumroad.com/l/ai-summary-helper">Get it on Gumroad</a>
<a class="secondary-option" target="_blank" href="https://chrome.google.com/webstore/detail/ai-summary-helper-summari/hldbejcjaedipeegjcinmhejdndchkmb">Chrome Web Store</a>
<a class="secondary-option" target="_blank" href="https://philffm.github.io/ai-summary-helper/bookmarklet-generator/">Bookmarklet Generator</a>
</header>
<main>
<section></section>
<h2 id="localizedFeature"></h2>
<p id="localizedFeatureText"></p>
</section>
<section>
<h2 id="proposeFeature"></h2>
<p id="proposeFeatureText"></p>
</section>
<section>
<h2 id="privacyNote"></h2>
<p id="privacyNoteText"></p>
</section>
<section>
<p id="funMessage"></p>
</section>
<section>
<h2 id="changelog">Changelog</h2>
<ul id="changelogList"></ul>
</section>
<section>
<h2 id="aboutCreator"></h2>
<p id="creatorText"></p>
</section>
<section>
<h2 id="whyHelper"></h2>
<ul id="whyHelperList"></ul>
</section>
<section>
<h2 id="getStarted"></h2>
<p id="getStartedText"></p>
</section>
<section>
<h2 id="feedbackSupport"></h2>
<p id="feedbackSupportText"></p>
</section>
<section id="blog-section">
<h2>Latest Blog Posts</h2>
<div class="blog-posts">
<!-- Blog posts will be dynamically inserted here -->
</div>
</section>
</main>
<footer>
<p>© 2024 Phil Wornath. All rights reserved. Visit the project at <a href="https://github.com/philffm/ai-summary-helper/">AI Summary Helper</a>.</p>
</footer>
</div>
</div>
<!-- Extension UI -->
<div id="extensionUI" class="extension-ui hidden">
<img src="extension.png" alt="Extension UI" class="extension-ui-image">
</div>
<style>
.tooltip {
visibility: hidden;
background-color: black;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 125%; /* Position the tooltip above the button */
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.extension-button {
border-radius: 12px;
border: 1px solid grey;
}
.extension-button:hover .tooltip {
visibility: visible;
opacity: 1;
}
.extension-ui.hidden {
display: none;
}
.extension-ui {
max-width: 500px; /* Set a maximum width */
height: auto;
position: absolute; /* Position absolute for dynamic placement */
background-color: #f9f9f9; /* Optional: Add a background color */
border-radius: 10px; /* Optional: Add rounded corners */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Optional: Add a shadow for depth */
z-index: 1000; /* Ensure it appears above other elements */
opacity: 0; /* Start with opacity 0 for fade-in effect */
animation: fadeInFlyIn .5s forwards; /* Apply fade-in animation */
}
#summarizeButton {
position: absolute;
/* width: max-content; */
bottom: 14px;
/* left: 50%; */
transform: translateX(-108%);
width: 93%;
margin: 0 12px;
background: linear-gradient(30deg, #3B6CF2, #6CCCFB);
color: white;
border: none;
padding: 10px 20px;
/* margin: 0 4px; */
/* margin: 20px; */
border-radius: 5px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
#summarizeButton:hover {
background-color: #0056b3; /* Darker blue on hover */
}
#extensionButton {
position: relative;
padding: 10px;
border-radius: 20px;
color: white;
border: none;
cursor: pointer;
outline: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
animation: pulse 2s infinite;
}
#extensionButton::after {
content: "try me";
position: absolute;
bottom: -25px; /* Position below the button */
left: 50%;
transform: translateX(-50%);
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 5px 10px;
border-radius: 3px;
font-size: 12px;
white-space: nowrap;
opacity: 0;
transition: opacity 0.3s;
}
#extensionButton:hover::after {
opacity: 1;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
}
70% {
box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
}
}
/* Add new style for the image */
.extension-ui-image {
width: 500px;
height: auto;
}
/* Mobile style */
@media (max-width: 600px) {
.extension-ui-image {
width: 320px; /* Adjust width for mobile */
height: auto;
}
}
</style>
</body>
</html>