This sounds exactly like what I was looking for!

Is $:/vp/ some magical prefix I don’t know about? How do I make sure the 
$:/vp/youtube-api-loaded isn’t persisted in the storage and has its value reset 
on every reload?

--

> On Tuesday, Jun 16, 2020 at 11:13 a.m., Saq Imtiaz <[email protected] 
> (mailto:[email protected])> wrote:
> Here's the first idea that comes to mind:
>
> Add a onYouTubeIframeAPIReady function that calls the following:
>
> $tw.wiki.setText(title,field,index,value,options)
>
> Use this to set the value of a tiddler like $:/vp/youtube-api-loaded to true
>
> $tw.wiki.setText("$:/vp/youtube-api-loaded","text","","true");
>
> In the refresh function of your widget, check if $:/vp/youtube-api-loaded is 
> one of the changedTiddlers. If it is, refresh the widget.
>
>
> On Tuesday, June 16, 2020 at 10:27:14 AM UTC+2, Vladimir Pouzanov wrote:
> > I was hacking arount boot.js and I noticed that the YT api script actually 
> > loads in time, it’s just that the script itself is asynchronous. From 
> > https://developers.google.com/youtube/iframe_api_reference#Requirements:
> >
> > Any web page that uses the IFrame API must also implement the following 
> > JavaScript function:
> > onYouTubeIframeAPIReady – The API will call this function when the page has 
> > finished downloading the JavaScript for the player API, which enables you 
> > to then use the API on your page. Thus, this function might create the 
> > player objects that you want to display when the page loads.
> >
> > So it’s not the question of how to delay the boot, I indeed need to force 
> > redraw some widgets after the YT api notifies the JS it finished loading.
> >
> > An obvious dirty hack is to wait until onYouTubeIframeAPIReady in the very 
> > end of boot.js but I’d still like to make this solution into a reasonable 
> > plugin.
> >
> > Any further ideas on how I can force a widget redraw from the “outside” js 
> > scope would be appreciated.
> >
> > --
> >
> >
> > > On Tuesday, Jun 16, 2020 at 6:50 a.m., Christian Byron 
> > > <[email protected] (javascript:)> wrote:
> > > Hey Vladimir
> > >
> > > I think you could a couple of things, namely :
> > > - try renaming your tiddler so it is a system tiddler ( eg 
> > > $:\script\youtube.api ) ... I believe system tiddlers are loaded before 
> > > content tiddlers ... not sure though that loading into the wiki store is 
> > > enough to execute the script tag though...
> > > - try adding the field "module-type" with the value of "startup" and see 
> > > if that changes the loading sequence enough to get it working .. not sure 
> > > if this will work with the RawMarkup tag
> > >
> > > If neither above works ... a better solution may be to change your 
> > > tiddler to be type application/javascript and replace the contents with 
> > > the code itself.. I know marking this with module-type = startup will 
> > > make this code run before any content is rendered.
> > >
> > > Pulling in external libraries this way is the prefered approach as it 
> > > makes sure it is available while offline ( although not as applicable in 
> > > your use case ) .. and as the code in that link is not very big it will 
> > > be a simple approach
> > >
> > > Cheers
> > > CB
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "TiddlyWikiDev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an 
> > > email to [email protected] (javascript:).
> > > To view this discussion on the web visit 
> > > https://groups.google.com/d/msgid/tiddlywikidev/28a13fd8-0cec-4c05-a668-88fad18637f0o%40googlegroups.com
> > >  
> > > (https://groups.google.com/d/msgid/tiddlywikidev/28a13fd8-0cec-4c05-a668-88fad18637f0o%40googlegroups.com?utm_medium=email&utm_source=footer).
> --
> You received this message because you are subscribed to the Google Groups 
> "TiddlyWikiDev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywikidev/afa7d3ad-944a-43a7-8561-2c0bba89aa79o%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/tiddlywikidev/afa7d3ad-944a-43a7-8561-2c0bba89aa79o%40googlegroups.com?utm_medium=email&utm_source=footer).

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/64b402c3-19db-4119-bba4-8c0fad49369e%40Canary.

Reply via email to