[Done] WebViewGadget + SpiderBasic-App?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

[Done] WebViewGadget + SpiderBasic-App?

Post by Kiffi »

Hello,

has anyone of you managed to display a SpiderBasic app in a WebViewGadget?

This one does not work (WebViewGadget remains empty):

Code: Select all

OpenWindow(0, 0, 0, 1000, 800, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
WebViewGadget(0, 10, 10, 980, 780)

ReadFile(0, "C:\Temp\HelloWorld\index.html") ; a simple HelloWorld-App written in SpiderBasic
Html$ = ReadString(0, #PB_File_IgnoreEOL)
CloseFile(0)

SetGadgetText(0, Html$)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Unfortunately there is also no error message or anything similar.

Thanks in advance & best regards ... Peter
Hygge
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: WebViewGadget + SpiderBasic-App?

Post by infratec »

Did you create a subdirectory named spiderbasic with the following files inside?
<script type="text/javascript" src="spiderbasic/platform.js"></script>
<script type="text/javascript" src="spiderbasic/init.js"></script>
<script type="text/javascript" src="spiderbasic/dojo/dojo.js"></script>
<script type="text/javascript" src="spiderbasic/main.js"></script>
<link rel="stylesheet" href="spiderbasic/dojo/themes/flat/flat.css" />
<link rel="stylesheet" href="spiderbasic/dojo/dgrid/css/dgrid.css" />
<script type="text/javascript" src="spiderbasic/xdate.min.js"></script>
<link rel="stylesheet" title="Default" href="spiderbasic/themes/flat/window.css" type="text/css"/>
It is not a 'single file' application.
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: WebViewGadget + SpiderBasic-App?

Post by Kiffi »

infratec wrote: Tue Dec 26, 2023 6:52 pmDid you create a subdirectory named spiderbasic with the following files inside?
Yes, of course. I created the app with the "Create App..." - function of SpiderBasic.
Hygge
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: WebViewGadget + SpiderBasic-App?

Post by infratec »

In my case this does not produce a full directory.
All this was really needed:
\Test01\spiderbasic\dojo\
\Test01\spiderbasic\dojo\cbtree\
\Test01\spiderbasic\dojo\cbtree\errors\
\Test01\spiderbasic\dojo\dgrid\
\Test01\spiderbasic\dojo\dgrid\css\
\Test01\spiderbasic\dojo\nls\
\Test01\spiderbasic\themes\
\Test01\spiderbasic\themes\flat\
\Test01\index.html
\Test01\spiderbasic.js
\Test01\spiderbasic\canvas-toBlob.min.js
\Test01\spiderbasic\dojo\cbtree\errors\CBTErrors.json
\Test01\spiderbasic\dojo\dgrid\css\dgrid.css
\Test01\spiderbasic\dojo\dojo.js
\Test01\spiderbasic\dojo\nls\colors.js
\Test01\spiderbasic\dojo\nls\dojo_de.js
\Test01\spiderbasic\filesaver.min.js
\Test01\spiderbasic\init.js
\Test01\spiderbasic\interact.min.js
\Test01\spiderbasic\jquery.blockUI.min.js
\Test01\spiderbasic\jquery.injectCSS.js
\Test01\spiderbasic\jquery.min.js
\Test01\spiderbasic\jquery-ui.custom.min.js
\Test01\spiderbasic\main.js
\Test01\spiderbasic\mousetrap.min.js
\Test01\spiderbasic\mousetrap-global-bind.min.js
\Test01\spiderbasic\paper-full.min.js
\Test01\spiderbasic\platform.js
\Test01\spiderbasic\put.min.js
\Test01\spiderbasic\themes\flat\close.png
\Test01\spiderbasic\themes\flat\window.css
\Test01\spiderbasic\xdate.min.js
\Test01\Test01.sb
Simple Test: double click on the index.html file. If it opens correct in the browser it should open also in the gadget.
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: WebViewGadget + SpiderBasic-App?

Post by Kiffi »

infratec wrote: Tue Dec 26, 2023 7:26 pmSimple Test: double click on the index.html file. If it opens correct in the browser it should open also in the gadget.
the app loads without problems in the browser. The WebViewGadget() still remains empty.

I have added a global error handler to Index.html as a test.

Code: Select all

<script type="text/javascript">
window.onerror = function(msg, url, line, col, error) {
   alert("Error: " + msg);
};
</script>
When I start my program I get the following message:
Error: Uncaught ReferenceError: dojoConfig is not defined
and afterwards:
Error: Uncaught ReferenceError: spiderCheckBrowser is not defined
The WebView runtime is up to date:

Image
Hygge
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: WebViewGadget + SpiderBasic-App?

Post by infratec »

Hm ...

Code: Select all

function spiderCheckBrowser()
is inside:

\Test01\spiderbasic\init.js

Also

Code: Select all

var dojoConfig = { ... 
In my index.html it is included:

Code: Select all

<script type="text/javascript" src="spiderbasic/init.js"></script>
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: WebViewGadget + SpiderBasic-App?

Post by Kiffi »

Very strange!

This is the HTML file that I load into the WebViewGadget:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">var spider = {}; spider.nbModules = 1; spider.nbLoadedModules = 0;</script>

<title>HelloWorld</title>

<script type="text/javascript">function onLoad() { spiderCheckBrowser(); }</script>
<script type="text/javascript" src="spiderbasic/platform.js"></script>
<script type="text/javascript" src="spiderbasic/init.js"></script>
<script type="text/javascript">dojoConfig.baseUrl = 'spiderbasic/'; </script>
<script type="text/javascript" src="spiderbasic/dojo/dojo.js"></script>
<script type="text/javascript" src="spiderbasic/main.js"></script>
<script type="text/javascript" src="spiderbasic/debug.js"></script>
<link rel="stylesheet" href="spiderbasic/dojo/themes/flat/flat.css" />
<link rel="stylesheet" href="spiderbasic/dojo/dgrid/css/dgrid.css" />
<script type="text/javascript" src="spiderbasic/xdate.min.js"></script>
<link rel="stylesheet" title="Default" href="spiderbasic/themes/flat/window.css" type="text/css"/>
<script type="text/javascript" src="spiderbasic.js?t=1703626203"></script>

</head>

<body oncontextmenu="return false;" class="flat" id="spiderbody" onload="onLoad()">

</body>
</html>
If I then right-click on the WebView gadget and select "Save as...", it will be saved here:

Code: Select all

<!DOCTYPE html>
<!-- saved from url=(0011)about:blank -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">var spider = {}; spider.nbModules = 1; spider.nbLoadedModules = 0;</script>

<title>HelloWorld</title>

<script type="text/javascript">function onLoad() { spiderCheckBrowser(); }</script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">dojoConfig.baseUrl = 'spiderbasic/'; </script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<script type="text/javascript" src=""></script>
<link rel="stylesheet" title="Default" href="" type="text/css">
<script type="text/javascript" src=""></script>

</head>

<body oncontextmenu="return false;" class="flat" id="spiderbody" onload="onLoad()">

</body></html>
All src attributes are empty. Why?
Hygge
Fred
Administrator
Administrator
Posts: 18154
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: WebViewGadget + SpiderBasic-App?

Post by Fred »

I think you will need to specify a path to have it working, I will add this for the next beta.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: WebViewGadget + SpiderBasic-App?

Post by DarkDragon »

Do you have a developer console inside the new webview or similar? This way you could check for CSP errors or similar.
bye,
Daniel
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: WebViewGadget + SpiderBasic-App?

Post by Kiffi »

No, I do not have access to the DEV console in the WebViewGadget.
Hygge
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: WebViewGadget + SpiderBasic-App?

Post by Kiffi »

Works perfectly now :D Thanks @Fred!

Code: Select all

OpenWindow   (0,  0,  0, 1000, 800,"", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
WebViewGadget(0, 10, 10,  980, 780)
SetGadgetText(0, "file://c:/temp/helloworld/index.html")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Hygge
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: [Done] WebViewGadget + SpiderBasic-App?

Post by dige »

I've read it somewhere before, but unfortunately I've forgotten it 🙈 :oops: ... what's the difference between the two gadgets again?

Code: Select all

OpenWindow   (0,  0,  0, 1600, 800,"", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
WebViewGadget(0, 10, 10,  700, 780)
WebGadget    (1, 710, 10,  700, 780, "", #PB_Web_Edge)
SetGadgetText(0, "https://www.whatsmybrowser.org")
SetGadgetText(1, "https://www.whatsmybrowser.org")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
"Daddy, I'll run faster, then it is not so far..."
Post Reply