Plugin javascript tiddlers need the correct module-type to determine how they are made available/run. https://tiddlywiki.com/#ModuleType
Here is what I recommend to get you started: To get the user input of what ISBN to look up, use an edit-text widget with a temporary tiddler like $:/myplugin/isbn-search https://tiddlywiki.com/#EditTextWidget Since you want to execute an action on userinput, that is look up the isbn, use a button widget to trigger a custom action widget. You can model your action widget on https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/widgets/action-setfield.js For starters, accept a single parameter, the isbn, make the http request and in the callback, parse the response and create a tiddler. For an action widget called action-getbookinfo, it would be invoked like this inside the button widget: <$action-getbookinfo $isbn={{$:/myplugin/isbn-search}} /> On Tuesday, May 19, 2020 at 4:57:32 PM UTC+2, Flan Mou wrote: > > Update: I followed the instructions here: > > > https://tiddlywiki.com/dev/static/How%2520to%2520create%2520plugins%2520in%2520the%2520browser.html > > And created a plugin which simply contains: > > (function () { alert("Test alert"); }) > > Everything got packed and saved, and the plugin appears installed. But > when I reload the alert box doesn't appear. I would have expected the code > inside an installed plugin to run upon startup. How can I get TW to execute > my plugin code? > > On Tuesday, May 19, 2020 at 7:20:38 AM UTC-7, Flan Mou wrote: > >> Yes, for example there is the OpenLibrary API: >> >> https://openlibrary.org/developers/api >> >> I'm fine with interacting with the API, it's just that I'm not sure how >> to build even a very simple request within TW. I was expecting to be able >> to create an HTML tiddler, add a <script> tag, and write some Javascript >> with XMLHttpRequest() within it. But it seems that's not possible. For >> example I created an HTML Tiddler with: >> >> <script> >> alert("Testing"); >> </script> >> >> And that didn't work. >> >> I guess my question is: is there a way to get TW to execute arbitrary >> Javascript within a tiddler? If not, how do I make that happen? Apologies >> if this is available in the documentation somewhere but I couldn't find it. >> >> >> On Monday, May 18, 2020 at 11:59:49 PM UTC-7, PMario wrote: >>> >>> Hi, >>> Is there a public service, where you can GET the info? Without an API >>> description, it's hard to do. >>> -mario >>> >>> On Tuesday, May 19, 2020 at 6:14:29 AM UTC+2, Flan Mou wrote: >>>> >>>> Goal: to create a plugin(?) where: you type in an ISBN and it does a >>>> few HTTP GETs to get book information and populates a new tiddler with >>>> that >>>> info. >>>> >>>> I'm pretty new to TiddlyWiki and I've been trying to make my way >>>> through tiddlywiki.com/dev looking for examples I can base things off. >>>> I haven't seen anything relevant. >>>> >>>> I'd be happy for any points in useful directions. >>>> >>>> Thanks. >>>> >>> -- 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/6b0a32d9-29cf-4b56-afd8-9edda92802ee%40googlegroups.com.
