javascript macros in TW5

156 views
Skip to first unread message

tejjyid

unread,
Feb 18, 2017, 5:40:56 AM2/18/17
to TiddlyWiki
I finally decided I had to bite the bullet and deal with converting all my old JS macros to TW5 so that I can move forward on what will hopefully prove to be a more stable platform.

I can't find a document describing how to convert TWC JS macros, but looking at the sketchy documentation & a couple of examples, it doesn't look too hard. Maybe.

I've tried one - naturally it doesn't work, but the real problem is how am I to debug it? I can't see any error messages. TWC used to tell me I had a syntax error - I reckon the chance that I've managed to code something without one is approaching 0, but there is no error message. I can't see anything in the console either, except "saver-handler: Saving wiki with method autosave through saver tiddlyfox". That in itself is puzzling, since I'm trying to display a tiddler, not save anything.

Can somebody assist please? 

While I'm here, there's a mass of stuff between /*\ and \*/ at the top of the sample macros I looked at. Is that functional (I copied it in case it was) or documentation?

Cheers (and I hope this is worth it)

Tobias Beer

unread,
Feb 18, 2017, 6:27:54 AM2/18/17
to tiddl...@googlegroups.com
Hi tejjyid,

A good start would be ...an example. ;-)

Best wishes,

Tobias.

BJ

unread,
Feb 18, 2017, 2:28:37 PM2/18/17
to TiddlyWiki
some twc macros would have to be written as tw5 widgets, not as tw5 macros.

all the best
BJ

tejjyid

unread,
Feb 18, 2017, 3:01:45 PM2/18/17
to TiddlyWiki
https://www.dropbox.com/s/luya0x3dl0q57l8/bridgethunk.html?dl=0

bridgeHand.test contains the attempt at a new TW5 version of the TWC version in bridgeHand.old.

Winnipeg is one of tiddlers trying to use it.

Thanks

tejjyid

unread,
Feb 18, 2017, 3:03:41 PM2/18/17
to TiddlyWiki
I see. How can i identify that necessity in a given TWC macro?

BJ

unread,
Feb 18, 2017, 3:19:20 PM2/18/17
to TiddlyWiki

bridgeHand.test - I dont see this - only your twc tiddlywiki



On Saturday, February 18, 2017 at 9:03:41 PM UTC+1, tejjyid wrote:
I see. How can i identify that necessity in a given TWC macro?

macros should not modifly tiddlers or the dom, only return wikitext

tejjyid

unread,
Feb 19, 2017, 4:17:22 AM2/19/17
to TiddlyWiki
Excellent, thanks for that. 
The TW5 macros will need some thinking about.

tejjyid

unread,
Feb 19, 2017, 4:21:10 AM2/19/17
to TiddlyWiki
Ahh... OK, this should be better.

Appreciate it.


On Sunday, 19 February 2017 07:19:20 UTC+11, BJ wrote:

BJ

unread,
Feb 19, 2017, 5:12:00 AM2/19/17
to TiddlyWiki
if you remove the "using strict" from you macro, and add the field "modules-type" with value "macro", save and reload, then your macro works.

BJ

tejjyid

unread,
Feb 19, 2017, 8:07:40 PM2/19/17
to TiddlyWiki
Thanks very much.

Can I update the online documentation of Javascript macros? Because I think it can be made more clear for the inexperienced. 

tejjyid

unread,
Feb 20, 2017, 2:06:10 AM2/20/17
to TiddlyWiki
But before I do...

I made the suggested changes (did you mean "modules-type" or "module-type", BTW)? Now I have a large red window in the middle of my screen suggesting there is a javascript error in my module. Well, no real surprises there, BUT the big red window won't go away, which makes editing the tiddler with the code in it impossible.

What next?

tejjyid

unread,
Feb 20, 2017, 2:09:33 AM2/20/17
to TiddlyWiki
Scrub that - if you find a really BIG screen (although not in Firefox) there's a close button.

BJ

unread,
Feb 20, 2017, 3:05:11 AM2/20/17
to tiddl...@googlegroups.com

that should be module-type

tejjyid

unread,
Feb 20, 2017, 5:50:30 AM2/20/17
to TiddlyWiki
In fact, by making the browser full-screen in Firefox, I was able to get to the close button.

tejjyid

unread,
Feb 20, 2017, 5:53:11 AM2/20/17
to TiddlyWiki
Thanks BJ, that in fact works. I also found the error & the macro outputs the same stuff it used to. Mind you, it used to come out as a table, and now it comes out as a bunch of vertical lines, so something's a little odd, but I guess that's a different question.
Reply all
Reply to author
Forward
0 new messages