Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
added image for when pocketbrowser doesn't load
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinify committed Feb 8, 2024
1 parent ad4f15d commit cdbbb78
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 17 deletions.
55 changes: 53 additions & 2 deletions docs/testing/index.js

Large diffs are not rendered by default.

22 changes: 8 additions & 14 deletions src/handlers/pocketbrowser/input.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { Pen } from '../../penexutils'
import { HandlerDefinition } from '../../types'

function checkIfIframeIsLoaded(iframe: HTMLIFrameElement): boolean {
var html = null;
try {
// @ts-ignore on purpose for the error to work and im to lazy for a normal check
var doc = iframe.contentDocument || iframe.contentWindow.document;
html = doc.body.innerHTML;
} catch(err){
// do nothing
}
async function checkIfIframeIsEmbedable(url: string): Promise<boolean> {
return true


return(html !== null);
}

function formatInput(input: string): string {
Expand All @@ -31,12 +24,13 @@ function inputhandler(input: string): void {
let iframe = document.getElementById('pocketbrowseriframe') as HTMLIFrameElement
iframe.setAttribute('src', input)

setTimeout(() => {

if (!checkIfIframeIsLoaded(iframe)) {
checkIfIframeIsEmbedable(input).then((state) => {
if (state) {
console.log('Iframe loaded')
} else {
iframe.setAttribute('src', `https://placehold.co/${iframe.clientWidth}x${iframe.clientHeight}?text=Cannot+load+this+website,+try+loading+a+different+website.`)
}
}, 500)
})
}
let definition: HandlerDefinition = {
type: 'input',
Expand Down
3 changes: 2 additions & 1 deletion src/styles/content.less

Large diffs are not rendered by default.

0 comments on commit cdbbb78

Please sign in to comment.