[tw5] Re: TiddlyTools/Time/AutoSaver and Streams don't play well together?

2020-10-19 Thread cmari
Thank you so much, this is great - and thanks especially for the 
explanation.
cmari

On Sunday, October 18, 2020 at 11:57:22 PM UTC-7 saq wrote:

> Thank you Eric. I'll push an update as soon as I get the chance.
>
> Regards,
> Saq
>
>
> On Monday, October 19, 2020 at 7:31:50 AM UTC+2, Eric Shulman wrote:
>>
>> On Sunday, October 18, 2020 at 5:00:36 PM UTC-7, cmari wrote:
>>>
>>> I'd like to be able to use the features of both 
>>> TiddlyTools/Time/AutoSaver 
>>>  and 
>>> Streams . But after 
>>> some experimenting, it seems that if I add both of these plugins to an 
>>> otherwise empty 5.1.22 TW, when I try to use the (TiddlyTools) Autosaver 
>>> option of "confirm before saving", I get the red javascript error 
>>> ("Uncaught TypeError: Cannot read property 'toString' of null). Is there 
>>> something I can do to prevent this error?
>>
>>
>> I took a look at the browser's debugging console, where it reports:
>> streams.html:13257 Uncaught TypeError: Cannot read property 'toString' 
>> of null
>>
>> $tw.utils.error @ streams.html:13257
>> $:/plugins/sq/streams/selection-vars-tweak.js:29 Uncaught TypeError: 
>> Cannot read property 'toString' of null
>> at TimeoutWidget.Widget.invokeActionString ($:/plugins/sq/streams/
>> selection-vars-tweak.js:29)
>> at eval (TiddlyTools/Time/action-timeout.js:40)
>>
>> Here's a summary of what occurs:
>>
>>1. The *TiddlyTools/Time/AutoSaver *countdown timer is processed by 
>>the <> macro,
>>2. which is defined in *TiddlyTools/Time/CountDown* and is called 
>>from *TiddlyTools/Time/Ticker*,
>>3. which is invoked once per second by 
>>*TiddlyTools/Time/action-timeout.js*,
>>4. which uses the *TWCore "invokeActionString()"* method.
>>5. which has been "hijacked" by the Streams plugin code contained in 
>>*$:/plugins/sq/streams/selection-vars-tweak.js*,
>>
>> Take note of these two lines from 
>> *$:/plugins/sq/streams/selection-vars-tweak.js*:
>>  if(activeElement && selection && (activeElement.tagName === "INPUT" || 
>> activeElement.tagName === "TEXTAREA")) {
>>  variables["selectionStart"] = activeElement.selectionStart.toString();
>>
>> This is where the error actually occurs.
>>
>> The problem is that the code is checking for *activeElement.tagName === 
>> "INPUT"*, which is OK when the activeElement has a "selectionStart" 
>> property.  However, in the AutoSaver settings panel, the "confirm before 
>> saving" checkbox is also an HTML "input" element, but because it is not a 
>> *text* element, it has no "selectionStart" property. Thus, attempting to 
>> invoke "toString()" throws the "Uncaught TypeError: Cannot read property 
>> 'toString' of null" error that is reported in the browser's debugging 
>> console and by the TiddlyWiki RMOD ("Red Message of Death").
>>
>> Note that 
>> https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement
>>  says 
>> this:
>>
>> Often activeElement will return a HTMLInputElement or HTMLTextAreaElement 
>>> object if it has the text selection at the time. If so, you can get more 
>>> detail by using the object's selectionStart and selectionEnd properties. 
>>> Other times the focused element might be a  element (menu) or an 
>>>  element, of type "button", "checkbox", or "radio".
>>
>>
>> The fix is to change the code in 
>> *$:/plugins/sq/streams/selection-vars-tweak.js *to ensure that when the 
>> *activeElement.tagName 
>> === "INPUT"*, the *activeElement.type === "text"*, which would then 
>> exclude "button", "checkbox", or "radio" input elements.
>>
>> Something like this will do the trick:
>>  if(activeElement && selection && ((activeElement.tagName === "INPUT" && 
>> activeElement.type === "TEXT") || activeElement.tagName === "TEXTAREA")) 
>> {
>>
>> If you edit the *$:/plugins/sq/streams/selection-vars-tweak.js* shadow 
>> tiddler and change the line of code as shown above, that will bypass the 
>> problem until Saq can provide an update to the Streams plugin.
>>
>> -e
>>
>

-- 
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/b4a38ad8-d9a7-4699-b806-17a0e2894259n%40googlegroups.com.


[tw5] Re: TiddlyTools/Time/AutoSaver and Streams don't play well together?

2020-10-19 Thread Saq Imtiaz
Thank you Eric. I'll push an update as soon as I get the chance.

Regards,
Saq

On Monday, October 19, 2020 at 7:31:50 AM UTC+2, Eric Shulman wrote:
>
> On Sunday, October 18, 2020 at 5:00:36 PM UTC-7, cmari wrote:
>>
>> I'd like to be able to use the features of both 
>> TiddlyTools/Time/AutoSaver 
>>  and 
>> Streams . But after some 
>> experimenting, it seems that if I add both of these plugins to an otherwise 
>> empty 5.1.22 TW, when I try to use the (TiddlyTools) Autosaver option of 
>> "confirm before saving", I get the red javascript error ("Uncaught 
>> TypeError: Cannot read property 'toString' of null). Is there something I 
>> can do to prevent this error?
>
>
> I took a look at the browser's debugging console, where it reports:
> streams.html:13257 Uncaught TypeError: Cannot read property 'toString' of 
> null
>
> $tw.utils.error @ streams.html:13257
> $:/plugins/sq/streams/selection-vars-tweak.js:29 Uncaught TypeError: 
> Cannot read property 'toString' of null
> at TimeoutWidget.Widget.invokeActionString ($:/plugins/sq/streams/
> selection-vars-tweak.js:29)
> at eval (TiddlyTools/Time/action-timeout.js:40)
>
> Here's a summary of what occurs:
>
>1. The *TiddlyTools/Time/AutoSaver *countdown timer is processed by 
>the <> macro,
>2. which is defined in *TiddlyTools/Time/CountDown* and is called from 
>*TiddlyTools/Time/Ticker*,
>3. which is invoked once per second by 
>*TiddlyTools/Time/action-timeout.js*,
>4. which uses the *TWCore "invokeActionString()"* method.
>5. which has been "hijacked" by the Streams plugin code contained in 
>*$:/plugins/sq/streams/selection-vars-tweak.js*,
>
> Take note of these two lines from 
> *$:/plugins/sq/streams/selection-vars-tweak.js*:
>  if(activeElement && selection && (activeElement.tagName === "INPUT" || 
> activeElement.tagName === "TEXTAREA")) {
>  variables["selectionStart"] = activeElement.selectionStart.toString();
>
> This is where the error actually occurs.
>
> The problem is that the code is checking for *activeElement.tagName === 
> "INPUT"*, which is OK when the activeElement has a "selectionStart" 
> property.  However, in the AutoSaver settings panel, the "confirm before 
> saving" checkbox is also an HTML "input" element, but because it is not a 
> *text* element, it has no "selectionStart" property. Thus, attempting to 
> invoke "toString()" throws the "Uncaught TypeError: Cannot read property 
> 'toString' of null" error that is reported in the browser's debugging 
> console and by the TiddlyWiki RMOD ("Red Message of Death").
>
> Note that 
> https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement
>  says 
> this:
>
> Often activeElement will return a HTMLInputElement or HTMLTextAreaElement 
>> object if it has the text selection at the time. If so, you can get more 
>> detail by using the object's selectionStart and selectionEnd properties. 
>> Other times the focused element might be a  element (menu) or an 
>>  element, of type "button", "checkbox", or "radio".
>
>
> The fix is to change the code in 
> *$:/plugins/sq/streams/selection-vars-tweak.js *to ensure that when the 
> *activeElement.tagName 
> === "INPUT"*, the *activeElement.type === "text"*, which would then 
> exclude "button", "checkbox", or "radio" input elements.
>
> Something like this will do the trick:
>  if(activeElement && selection && ((activeElement.tagName === "INPUT" && 
> activeElement.type === "TEXT") || activeElement.tagName === "TEXTAREA")) {
>
> If you edit the *$:/plugins/sq/streams/selection-vars-tweak.js* shadow 
> tiddler and change the line of code as shown above, that will bypass the 
> problem until Saq can provide an update to the Streams plugin.
>
> -e
>

-- 
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/320576e9-3f99-48a2-a4e1-3360377b3efeo%40googlegroups.com.


[tw5] Re: TiddlyTools/Time/AutoSaver and Streams don't play well together?

2020-10-18 Thread Eric Shulman
On Sunday, October 18, 2020 at 5:00:36 PM UTC-7, cmari wrote:
>
> I'd like to be able to use the features of both TiddlyTools/Time/AutoSaver 
>  and 
> Streams . But after some 
> experimenting, it seems that if I add both of these plugins to an otherwise 
> empty 5.1.22 TW, when I try to use the (TiddlyTools) Autosaver option of 
> "confirm before saving", I get the red javascript error ("Uncaught 
> TypeError: Cannot read property 'toString' of null). Is there something I 
> can do to prevent this error?


I took a look at the browser's debugging console, where it reports:
streams.html:13257 Uncaught TypeError: Cannot read property 'toString' of 
null

$tw.utils.error @ streams.html:13257
$:/plugins/sq/streams/selection-vars-tweak.js:29 Uncaught TypeError: Cannot 
read property 'toString' of null
at TimeoutWidget.Widget.invokeActionString ($:/plugins/sq/streams/
selection-vars-tweak.js:29)
at eval (TiddlyTools/Time/action-timeout.js:40)

Here's a summary of what occurs:

   1. The *TiddlyTools/Time/AutoSaver *countdown timer is processed by the 
   <> macro,
   2. which is defined in *TiddlyTools/Time/CountDown* and is called from 
   *TiddlyTools/Time/Ticker*,
   3. which is invoked once per second by 
   *TiddlyTools/Time/action-timeout.js*,
   4. which uses the *TWCore "invokeActionString()"* method.
   5. which has been "hijacked" by the Streams plugin code contained in 
   *$:/plugins/sq/streams/selection-vars-tweak.js*,
   
Take note of these two lines from 
*$:/plugins/sq/streams/selection-vars-tweak.js*:
 if(activeElement && selection && (activeElement.tagName === "INPUT" || 
activeElement.tagName === "TEXTAREA")) {
 variables["selectionStart"] = activeElement.selectionStart.toString();

This is where the error actually occurs.

The problem is that the code is checking for *activeElement.tagName === 
"INPUT"*, which is OK when the activeElement has a "selectionStart" 
property.  However, in the AutoSaver settings panel, the "confirm before 
saving" checkbox is also an HTML "input" element, but because it is not a 
*text* element, it has no "selectionStart" property. Thus, attempting to 
invoke "toString()" throws the "Uncaught TypeError: Cannot read property 
'toString' of null" error that is reported in the browser's debugging 
console and by the TiddlyWiki RMOD ("Red Message of Death").

Note that 
https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement
 says 
this:

Often activeElement will return a HTMLInputElement or HTMLTextAreaElement 
> object if it has the text selection at the time. If so, you can get more 
> detail by using the object's selectionStart and selectionEnd properties. 
> Other times the focused element might be a  element (menu) or an 
>  element, of type "button", "checkbox", or "radio".


The fix is to change the code in 
*$:/plugins/sq/streams/selection-vars-tweak.js *to ensure that when the 
*activeElement.tagName 
=== "INPUT"*, the *activeElement.type === "text"*, which would then exclude 
"button", "checkbox", or "radio" input elements.

Something like this will do the trick:
 if(activeElement && selection && ((activeElement.tagName === "INPUT" && 
activeElement.type === "TEXT") || activeElement.tagName === "TEXTAREA")) {

If you edit the *$:/plugins/sq/streams/selection-vars-tweak.js* shadow 
tiddler and change the line of code as shown above, that will bypass the 
problem until Saq can provide an update to the Streams plugin.

-e

-- 
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/0ade0c78-589a-4ef6-9e81-1dd46ffd650fo%40googlegroups.com.