[tw5] Re: What is the simplest way to store JavaScript output value into a field?

2021-05-07 Thread Pekka
Ok I have solved it for now at least for my purposes, although I feel the 
solution is far from elegant. I will post and explain the solution for 
anyone who might be interested.

A dropdown menu is used to select an interval which is added to the current 
date. We want this new date to be stored in the field "due". To do this, we 
change the Tiddler fields within JavaScript by using $tw.wiki.setText. This 
is implemented in the next-date.js and is "invoked" by <>. 

For some reason, if <> is continuously visible in the text field 
then everything freezes. So we need to find a way to invoke the JavaScript 
temporarily. This can be achieved, albeit clumsily, using <$reveal> widget 
detailed here: https://tiddlywiki.com/static/RevealWidget.html. After 
invoking the script by showing <>, we have to hide <> 
again to prevent the freezing, and this is done by clicking the reveal 
button again. Due to the freezing the button must be clicked several times 
until "Restore Functionality" is switched back to "Set Interval".

---

\define getDate()
<$macrocall $name="next-date" title={{!!title}} 
interval={{!!next_interval}}/>
\end

<$select tiddler={{!!title}} field='next_interval' 
default={{next_interval}}>
<$list filter='[range[100]]'>
<$view field='title'/>



<$reveal type="nomatch" state="$:/state/SampleReveal2" text="show">
<$button set="$:/state/SampleReveal2" setTo="show">Set Interval 

<$reveal type="match" state="$:/state/SampleReveal2" text="show">
<$button set="$:/state/SampleReveal2" setTo="hide">Restore 
Functionality
<>


On Friday, May 7, 2021 at 3:57:46 PM UTC+3 Pekka wrote:

> Thanks to Eric Shulman's reply to jn.pierr.. question in "chaining jobs", 
> I was able to fix the issue with the following changes: 
>
> \define button_actions() <$action-setfield $tiddler=<> 
> due=<> />
> <$button actions=<>> Set Interval
> 
>
> Now the only thing left to do is to figure out how to set the interval 
> based on field values.
>
> On Friday, May 7, 2021 at 3:28:00 PM UTC+3 Pekka wrote:
>
>> I have tried to search for answers to this questions but most of them 
>> were years old and seemed rather complex. It seems to me that by now there 
>> would exist a simple solution.
>>
>> I have a simple JavaScript code that takes a number representing an 
>> interval and calculates the current date + interval. The below code will 
>> output the next date correctly in a tiddler text field but I am unable to 
>> plug this value into a tiddler field.  
>>
>> ---
>>
>> \define getNextDate()
>> <$macrocall $name="next-date" interval=5 />
>> \end
>>
>> <>
>>
>> ---
>>
>> I have tried the below method to store the output into a field. The 
>> confusing part is that both the <> and <> work fine in 
>> the text field and even though <> outputs the date in the text field, 
>> the value that is set to the field "due" will be just "<$macrocall 
>> $name="next-date" interval=5 />".
>>
>> <$set name="date" value=<>>
>> <>
>> <$button>
>> <$action-setfield $field="due" $value=<>/>
>>
>> Set interval
>>
>> 
>> 
>>
>> Any help would be greatly appreciated!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/966b8988-6916-470f-9021-034d1f707a3dn%40googlegroups.com.


[tw5] Re: What is the simplest way to store JavaScript output value into a field?

2021-05-07 Thread Pekka
Thanks to Eric Shulman's reply to jn.pierr.. question in "chaining jobs", I 
was able to fix the issue with the following changes: 

\define button_actions() <$action-setfield $tiddler=<> 
due=<> />
<$button actions=<>> Set Interval


Now the only thing left to do is to figure out how to set the interval 
based on field values.

On Friday, May 7, 2021 at 3:28:00 PM UTC+3 Pekka wrote:

> I have tried to search for answers to this questions but most of them were 
> years old and seemed rather complex. It seems to me that by now there would 
> exist a simple solution.
>
> I have a simple JavaScript code that takes a number representing an 
> interval and calculates the current date + interval. The below code will 
> output the next date correctly in a tiddler text field but I am unable to 
> plug this value into a tiddler field.  
>
> ---
>
> \define getNextDate()
> <$macrocall $name="next-date" interval=5 />
> \end
>
> <>
>
> ---
>
> I have tried the below method to store the output into a field. The 
> confusing part is that both the <> and <> work fine in 
> the text field and even though <> outputs the date in the text field, 
> the value that is set to the field "due" will be just "<$macrocall 
> $name="next-date" interval=5 />".
>
> <$set name="date" value=<>>
> <>
> <$button>
> <$action-setfield $field="due" $value=<>/>
>
> Set interval
>
> 
> 
>
> Any help would be greatly appreciated!
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5eee2c79-0960-4ee2-a633-c448de13d563n%40googlegroups.com.