This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pipButton.addEventListener('click', async () => { | |
| const chatScreen = document.querySelector("#chat-screen"); | |
| // Open a Picture-in-Picture window. | |
| const pipWindow = await documentPictureInPicture.requestWindow(); | |
| // Move the player to the Picture-in-Picture window. | |
| pipWindow.document.body.append(chatScreen); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <button popovertarget="my-popover" class="trigger-btn"> Open Popover </button> | |
| <div id="my-popover" popover=manual> | |
| <p>I am a popover with more information. Hit the close button or toggle to close me.<p> | |
| <button class="close-btn" popovertarget="my-popover" popovertargetaction="hide"> | |
| <span aria-hidden="true">❌</span> | |
| <span class="sr-only">Close</span> | |
| </button> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <button popovertarget="my-popover"> Open Popover </button> | |
| <div id="my-popover" popover> | |
| <p>I am a popover with more information. Hit <kbd>esc</kbd> or click away to close me.<p> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const model = genAI.getGenerativeModel({ model: "gemini-pro" }); | |
| const prompt = `This is an article or news from website ${request.body.url}. Please summary to ${paragraph} paragraph in the ${language} lanaguage. This is full article ${plainContent}`; | |
| const result = await model.generateContent([prompt]); | |
| console.log(result.response.text()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { extract } from '@extractus/article-extractor' | |
| const input = 'https://travel.kapook.com/view241146.html' | |
| try { | |
| const article = await extract(input) | |
| console.log(article) | |
| // { | |
| // "url": "https://travel.kapook.com/view241146.html", | |
| // "title": "ร้านซาลาเปาเจ้าอร่อย กรุงเทพฯ ไส้แน่น พร้อมเดลิเวอรี่ถึงบ้าน", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use the attribution build: | |
| import { onINP } from "web-vitals/attribution"; | |
| // Example reporting function that's passed to web-vitals: | |
| const report = ({ name, value, attribution }) => { | |
| console.log(name); | |
| console.log(value); | |
| console.log(attribution.eventType); | |
| console.log(attribution.eventTarget); | |
| }; | |
| // Pass the reporting function to the INP reporter: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const swReg = await navigator.serviceWorker.ready | |
| const bgFetchRegistration = await swReg.backgroundFetch.fetch('postr-download', ['image.png'], { | |
| title: 'Postr.me is capturing', | |
| icons: [{ | |
| sizes: '512x512', | |
| src: '/assets/img/icon-512.png', | |
| type: 'image/png' | |
| }], | |
| downloadTotal: 60 * 1024 * 1024 | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| addEventListener('backgroundfetchclick', async (event) => { | |
| const bgFetch = event.registration | |
| if (bgFetch.result === 'success') { | |
| const cache = await caches.open('postr-download') | |
| const records = await cache.matchAll() | |
| const cacheList = [] | |
| for (const record of records) { | |
| const recordDate = new Date(record.headers.get('date')) | |
| cacheList.push({ | |
| url: record.url, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| importScripts( | |
| 'https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js' | |
| ) | |
| workbox.routing.registerRoute( | |
| new workbox.routing.Route(({ request }) => { | |
| return request.url.includes('/generate') | |
| }, | |
| new workbox.strategies.CacheFirst({ | |
| // Use a custom cache name. | |
| cacheName: 'postr-download', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| addEventListener('backgroundfetchsuccess', event => { | |
| event.updateUI({ | |
| title: 'Postr.me capturing sucessful', | |
| icons: [{ | |
| sizes: '512x512', | |
| src: '/assets/img/icon-512.png', | |
| type: 'image/png' | |
| }] | |
| }) | |
| event.waitUntil( |