Hi Matabele

The pattern of using inline JavaScript handlers is not recommended for
TiddlyWiki5.

There are several reasons:

* It doesn't work well with TW5's refresh mechanism, which relies on being
able to regenerate any portion of the DOM as required; this frequently
causes inline handlers to be re-executed at unexpected times (see
http://tiddlywiki.com/static/TiddlyWiki%2520for%2520Developers.html)
* It mixes TW5 version-specific JavaScript with user content
* In multiuser environments there is a security risk to importing or
viewing tiddlers you didn't author if they can have JavaScript in them

Instead, one should write widgets or other custom modules that encapsulate
the required JavaScript.

Blacklisting the "on*" attributes on HTML elements has been on my list for
a while, so I've implemented it for 5.0.9:

https://github.com/Jermolene/TiddlyWiki5/commit/d0caf21b2df9fda9800eb30489003a87cafb1277

Best wishes

Jeremy.




On Wed, Mar 12, 2014 at 3:20 PM, Matabele <[email protected]> wrote:

> Hi
>
> For TW5 use this code in $:/SiteTitle
>
> <span title="Home"><button message="tw-home" class="btn-invisible"
> onclick="
> var defaultTiddlersTitle = '$:/DefaultTiddlers',
>     defaultTiddlersTiddler = $tw.wiki.getTiddler(defaultTiddlersTitle),
>     defaultTiddlers = [];
> if(defaultTiddlersTiddler) {
>     defaultTiddlers =
> $tw.wiki.filterTiddlers(defaultTiddlersTiddler.fields.text);
> }
> var storyTitle = '$:/StoryList',
>     story = [];
> for(var t=0; t
> <defaultTiddlers.length; t++) {
>     story[t] = defaultTiddlers[t];
> }
> $tw.wiki.addTiddler({title: storyTitle, text: '', list: story},$tw.wiki.
> getModificationFields());
> return false;
> ">My ~TiddlyWiki</button></span>
>
>
>
>
> Other buttons can also be added to the Site Title (as can similar buttons
> be added into the Site Subtitle.) I use this fullscreen button after my
> title (utilising fontawesome icons and the fullscreen plugin):
>
>
> <span title="Full screen"><$button message="tw-full-screen"
> class="btn-invisible"> <i class="fa fa-html5 silver"></i></$button></span>
>
>
>
> regards
>
>
> On Wednesday, March 5, 2014 7:52:48 PM UTC+2, Bill Mullen wrote:
>
>> I was looking for a way to re-display my DefaultTiddlers - mostly after a
>> search because the search feature was closing all the open tiddlers before
>> displaying the results.
>>
>> In my search, Morris Gray included some code in the following thread:
>>
>> https://groups.google.com/forum/#!searchin/TiddlyWiki/
>> DefaultTiddler/tiddlywiki/k3qdZ64aARQ/PpTeG7swBxkJ
>>
>> First off, thank you Morris!
>>
>> I used Morris' code in my SiteTitle tiddler as such so that clicking on
>> the site title will close all open tiddlers and display the default
>> tiddlers.
>>
>> <html><a href="javascript:void(0)" onclick="story.closeAllTiddlers
>> ();story.displayTiddlers(null,store.getTiddlerText
>> ('DefaultTiddlers').readBracketedList())"
>> ><span title="Display default tiddlers" style="cursor:pointer; color:
>> white;">My Site Title</span></a></html>
>>
>>
>> Just thought I would share a way to use Morris' code
>>
>>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/tiddlywiki.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jeremy Ruston
mailto:[email protected]

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to