[tw5] Re: [tw] how to use javascript in TW5

2018-05-18 Thread Paul Netsaver
OK PMario, thanks for the information.
By the way, the 'plusminus' was just an example.
In another envornment (dokuwiki) I used markdown for automatic text to html 
processing.
Then I used javascript to extend functionalities. Reference to js modules 
in dokuwiki could be placed in the template, so to be accessible from all 
articles.
So I could use dom to retrieve elements, attributes, classes, etc. and to 
perform other useful replacements.

For instance, I could replace §{#id .'myclass' ... inline html code ... }§ 
with  inline html code . So the 
dictionary elements were not just math symbols, but replacement for html 
code. Moreover, I use mathjax because allows inline math ${...}$ while it 
seems not available in katex...
Or I could create automatically bidirectional footnotes, based on links 
with special classes.

I could do this because the js code was kept in the final rendered code and 
executed by the browser. 
Therefore I thought to use js macro in tiddlywiki, but how to reference the 
code in all tiddlers without calling it explicitly from each one?
Maybe there's another way to do the same...

Thanks and regards 
Paul Netsaver,
Rome, IT

Il giorno venerdì 18 maggio 2018 00:58:16 UTC+2, PMario ha scritto:
>
> Hi,
>
> On Wednesday, May 16, 2018 at 10:14:33 PM UTC+2, Paul Netsaver wrote:
>
>>  moreover... are JS macros processed from the browser, after the 
>> final tiddlywiki html conversion or are they a sort of  'tiddlywiki 
>> middleware'?
>>
>
> Macros are more like "text substitusions" used by endusers. If you will 
> ... it's like middleware. 
>
> As you found out, if you want to manipulate tiddler source content, you'll 
> need javascript. ... but no js macros. 
>  
>
>> I've to know if I can program JS macros as for usual html+js websites, 
>> thinking to common dom structure or text utf-8 coding. 
>>
>
> No. 
>
> Manipulating the DOM in TW does absolutely nothing. ... It's the other way 
> around. As soon as you manipulate tiddler content, the DOM will be redrawn 
> to match tiddler state. 
>  
>
>> In the example above, §+- would be replaced with 
>>
>
> What you describe here is a parser-rule, similar to the dash-parser [1]. 
>
>
> But I'm not 100% sure, what you want to achieve. ... If you need 
> mathematical symobls, the katex-plugin may be a much simpler and much more 
> powerful possibility. 
>
> see: https://tiddlywiki.com/plugins/tiddlywiki/katex/
>
> have fun!
> mario
>
>
> [1] 
> https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/parsers/wikiparser/rules/dash.js
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/12b70830-e5f3-4a21-acb2-76b8a4dda512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw5] Re: [tw] how to use javascript in TW5

2018-05-17 Thread PMario
Hi,

On Wednesday, May 16, 2018 at 10:14:33 PM UTC+2, Paul Netsaver wrote:

>  moreover... are JS macros processed from the browser, after the final 
> tiddlywiki html conversion or are they a sort of  'tiddlywiki middleware'?
>

Macros are more like "text substitusions" used by endusers. If you will ... 
it's like middleware. 

As you found out, if you want to manipulate tiddler source content, you'll 
need javascript. ... but no js macros. 
 

> I've to know if I can program JS macros as for usual html+js websites, 
> thinking to common dom structure or text utf-8 coding. 
>

No. 

Manipulating the DOM in TW does absolutely nothing. ... It's the other way 
around. As soon as you manipulate tiddler content, the DOM will be redrawn 
to match tiddler state. 
 

> In the example above, §+- would be replaced with 
>

What you describe here is a parser-rule, similar to the dash-parser [1]. 


But I'm not 100% sure, what you want to achieve. ... If you need 
mathematical symobls, the katex-plugin may be a much simpler and much more 
powerful possibility. 

see: https://tiddlywiki.com/plugins/tiddlywiki/katex/

have fun!
mario


[1] 
https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/parsers/wikiparser/rules/dash.js

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/531882e5-89f0-417c-8b45-27ee45f00074%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw5] Re: [tw] how to use javascript in TW5

2018-05-16 Thread Paul Netsaver
Hi,
I've managed to create a JS macro and run it from inside tiddlers.
Anyway I'ld like to create an 'autoexecuting' JS macro, in order to apply 
it to all tiddlers (or maybe to specifically tagged tiddlers)
without making a call from each tiddler.
Think to a text replacing macro intercepting a list of user defined local 
entities, e.g. §+-, or a macro for creating footnotes in html, etc.
How to do it?

 moreover... are JS macros processed from the browser, after the final 
tiddlywiki html conversion or are they a sort of  'tiddlywiki middleware'? 
I've to know if I can program JS macros as for usual html+js websites, 
thinking to common dom structure or text utf-8 coding. In the example 
above, §+- would be replaced with 

Thanks and regards,
Netsaver, Rome, IT 



Il giorno martedì 21 marzo 2017 23:44:42 UTC+1, Sven Wetzel ha scritto:
>
> Hello Dave,
>
> I think you must create a widget, that creates a button with the click 
> event listener on it.
>
> Or if you want it as macro you can try this with my SPilot4TW (
> https://www.quaraman.de/tw/pilot.html):
>
> \define myfunctionbutton(text:"hello world!")
> 
> LOOP:
> PAUSE: Try it
> CLS:
> T: $text$
> ENDLOOP:
> 
> \end
>
>
> Later in the tiddler: <>
>
> This wait till the user presses the "Try it" button and then prints the 
> text.
>
> It is using another language as Javascript, but you can do this in a 
> normal Tiddler without creating a plugin yourself.
> Am 21.03.2017 um 22:51 schrieb Dave:
>
> Is  a tutorial somewhere that would teach me how to take this javascript 
> code
>
> 
> 
> 
>
> Click the button to convert the string to lowercase letters.
>
> Try it
>
> 
>
> 
> function myFunction() {
> var str = "Hello World!";
> var res = str.toLowerCase();
> document.getElementById("demo").innerHTML = res;
> }
> 
>
> 
> 
>
> and use it in a macro?
>
>
> -- 
> 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+...@googlegroups.com .
> To post to this group, send email to tiddl...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/39c1ac14-4076-4d70-80a8-e85fbb0c8efa%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/03102d5a-de93-40de-993a-7f6fcdc51c6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.