[TW5] How to teach macro to take some data from URL and put it to list field of temp tiddler?

61 views
Skip to first unread message

Siniy-Kit

unread,
Sep 18, 2016, 4:47:53 AM9/18/16
to tiddl...@googlegroups.com
Hi! long ago I wrote my first macro. Here is it http://novye-podarki.ru/heeg.html#%24%3A%2F_loctid.js  this macro take data from current url and build a very simple table  with this data.
for example, if you go by this link _
http://novye-podarki.ru/heeg.html#!heeg#;10010;5;150;dostDrGorod;1;1740;oplNalKur;1;0;NoMon;1;0;$%D0%92%D0%BB%D0%B0%D0%B4%D0%B8%D0%BC%D0%B8%D1%80$89112564578$info@heeg.ru$2016-05-25T10:00:54.338Z_09923

macros will take data from this link and show table with order.

Now I try to teach this macro to save some data from URL to the list field of tiddler $:/temp/mylist
I try to use this hook http://tiddlywiki.com/dev/#Hook%3A%20th-saving-tiddler but get error.

I use this $tw.Tiddler("$:/temp/mylist",{"list": value}); 

Danielo Rodríguez

unread,
Sep 18, 2016, 4:53:17 AM9/18/16
to TiddlyWiki
To create a tiddler you habe to use the keyword new. Also you have to pass as parameters only objects,as many as you want,but objects

new $tw.Tiddler({title:"bla",caption:"hi"})

regards

Siniy-Kit

unread,
Sep 18, 2016, 5:19:56 AM9/18/16
to TiddlyWiki
Thank you, Danielo. I put this code
new $tw.Tiddler({title:"bla",caption:"hi"});

 to my macros,  but tiddler "bla" didn't appear. may be it is necessary  to write something else?  Or may be somebody have a full example of using this hook?

воскресенье, 18 сентября 2016 г., 11:53:17 UTC+3 пользователь Danielo Rodríguez написал:

PMario

unread,
Sep 18, 2016, 5:35:31 AM9/18/16
to TiddlyWiki
Hi

try this:

$tw.wiki.addTiddler(new $tw.Tiddler($tw.wiki.getModificationFields(), {title:"bla",caption:"hi"}));

It will show up in the recent tab now. The second  function you may want to use is: $tw.wiki.getCreationFields()that gives you the created timestamp

-m

PMario

unread,
Sep 18, 2016, 5:50:04 AM9/18/16
to TiddlyWiki
On Sunday, September 18, 2016 at 10:47:53 AM UTC+2, Siniy-Kit wrote:
Now I try to teach this macro to save some data from URL to the list field of tiddler $:/temp/mylist
I try to use this hook http://tiddlywiki.com/dev/#Hook%3A%20th-saving-tiddler but get error.

I use this $tw.Tiddler("$:/temp/mylist",{"list": value}); 

The only way to create new tiddlers is $tw.wiki.addTiddler()   

So a typical call may look like this:

var fields = {list:"a b c", an_other_field:"test"};
var title = "test-title";

$tw
.wiki.addTiddler(new $tw.Tiddler($tw.wiki.getCreationFields(),fields,{title: title},$tw.wiki.getModificationFields(), {title:"this-title-wins"}));


If you copy paste the above code into the debug console it will create a tiddler named: "this-title-wins" ... Since it is the last parameter in the new $tw.Tiddler() call. So parameter priority is from left to right!

have fun!
mario


Reply all
Reply to author
Forward
0 new messages