Another To Do List Possibility

34 views
Skip to first unread message

Paul Kronenwetter

unread,
Jun 23, 2008, 10:24:03 PM6/23/08
to TiddlyWiki
All,

I've been toying with the to-do list idea, and have a proof of
concept plugin:
http://tiddlywiki.pastebin.com/m7d94633f

I have a few ideas on where it should go from here, but I'm more
interested to see if this is useful for anyone else. The additional
ideas are for there to be a button / slider on the task item instead
of it being rendered in a text box. Another is to allow for multiple
levels of indentation for sub-tasks etc...

I'm very open to suggestions on how better to code this as well...
It's my first public foray into TW plugins so be brutal :).

-Paul

Paul Kronenwetter

unread,
Jun 23, 2008, 10:29:55 PM6/23/08
to TiddlyWiki
I should also mention that the base tiddler required to use this
plugin is:

<<displayToDoList>>
<data>{"count":0}</data>

(also at http://tiddlywiki.pastebin.com/m750abb8)

So that's another addition to the capability, better error checking
and robustness. I haven't tested if it's even possible to create the
<data></data> portions programmatically.

-Paul

FND

unread,
Jun 24, 2008, 7:45:35 AM6/24/08
to Tiddl...@googlegroups.com
> I've been toying with the to-do list idea, and have a proof of
> concept plugin

Sounds interesting - could you create a sample document on Tiddlyspot*?
That way it'll be easier to get a feel for it and provide feedback.

Thanks!


-- F.


* http://tiddlyspot.com

Paul Kronenwetter

unread,
Jun 24, 2008, 9:12:01 AM6/24/08
to TiddlyWiki
Thanks Fred, I hadn't thought of using TiddltySpot. This also pointed
out to me that I missed a dependency, so great suggestion!

It's now at: http://kronenpj.tiddlyspot.com/

-Paul

Daniel Baird

unread,
Jun 26, 2008, 5:42:33 AM6/26/08
to Tiddl...@googlegroups.com
Nice job.

When I add a new task in your demo, sometimes the new task is checked
off, and sometimes it isn't. Bit erratic..

;Daniel

--
Daniel Baird
/to be or not to be/ => /(2b|[^2]b)/ => /(2|[^2])b/ => /.b/
...optimise your regexes, people!

Paul Kronenwetter

unread,
Jun 26, 2008, 11:11:51 AM6/26/08
to TiddlyWiki
Thanks Daniel! I think I've noticed that too, but didn't quite know
what to make of it. I've checked to make sure fields and tags aren't
being created since they can be with the CheckBoxPlugin. The real
kicker is that the code isn't that complex. It's mostly string
construction and a little theft from the FormTiddlerPlugin to read the
value of the text field.

I suppose I could try reducing the other plugins I use, but I don't
think I want to try recoding DataTiddlers so that just leaves CheckBox
and InlineJavascript. Replacing IJ just 'aint happening. Maybe I'll
try that if I get some time.

Other thoughts?
-Paul

Tobias Beer

unread,
Jun 26, 2008, 11:18:35 AM6/26/08
to TiddlyWiki
I played around with it a bit to enable a simple sorting mechanism.
The changed plugin code is here:

http://tiddlywiki.pastebin.com/m70ae136a


To remove borders from the table which I wrapped around the list, add
this to the shadow tiddler 'StyleSheet' (if you havent already done
so):
.viewer .noBorder,.viewer .noBorder td,.viewer .noBorder
th,.viewer .noBorder tr{border:0}

As well...
a) I'd prefer a drag & drop mechanism to sort elements, but that's not
easily available in tw, is it?
b) My bit of code seems a bit bloated... it could use a little
"refactoring" to make an extra function out of the swaping bit... well
I wasn't quite sure how to achieve that, so I guess, that's up to
you ;-)

Paul Kronenwetter

unread,
Jun 26, 2008, 11:33:14 AM6/26/08
to TiddlyWiki
Tobias - I'll take a look at it over the next few days and see if I
can't do something to refactor your contribution. I'll also use the
table / border changes. I hadn't figured that one out yet ;)

Thanks!
-Paul

Morris Gray

unread,
Jun 26, 2008, 11:49:44 AM6/26/08
to TiddlyWiki
Hi Tobias,

Your to do list doesn't like apostrophes.
It deletes everything after the apostrophe if you shift it up or down.

"Don't forget the milk" becomes Don after being moved
"Your to do list doesn't like apostrophes." becomes Your to do list
doesn

I like the idea of a clean little to do list. Keep up the good work.

Morris Gray
http://twhelp.tiddlyspot.com

Paul Kronenwetter

unread,
Jun 26, 2008, 12:57:21 PM6/26/08
to TiddlyWiki
Morris,

Actually, that's mine :) I've added it to my list of things to work
on, thanks!

-Paul

On Jun 26, 11:49 am, Morris Gray <msg...@symbex.net.au> wrote:
> Hi Tobias,
>
> Your to do list doesn't like apostrophes.
> It deletes everything after the apostrophe if you shift it up or down.
>
> "Don't forget the milk" becomes Don after being moved
> "Your to do list doesn't like apostrophes." becomes Your to do list
> doesn
>
> I like the idea of a clean little to do list.  Keep up the good work.
>
> Morris Grayhttp://twhelp.tiddlyspot.com

Morris Gray

unread,
Jun 26, 2008, 7:27:23 PM6/26/08
to TiddlyWiki
Sorry, Paul, for my oversight :-)

However I didn't mention it was the code Tobias posted at
http://tiddlywiki.pastebin.com/m70ae136a that I pasted into the
original plugin from which I discovered the bug. So I really couldn't
truthfully say to whom I should have addressed the discovery.

Nevertheless it's a cute little ToDo list :-)


Morris Gray
http://twhelp.tiddlyspot.com
A TiddlyWiki help file for beginners
http://sidebarpluginvault.tiddlyspot.com
World's largest squeezable TW plugin database

Paul Kronenwetter

unread,
Jun 26, 2008, 7:32:09 PM6/26/08
to TiddlyWiki
I've made a teeny bit of progress. I've corrected the problem Morris
found and tweaked Tobias's contribution a little. I'm looking for a
way to declare a function within a tiddler, within a <script>, and be
able to call it from another <script>. Something like this:

<script>
function yay(item) {
return item;
}
</script>

<script label="Push here">
yay("Hi there!");
</script>

The rendered document doesn't have the declared function in it
anywhere, so that's where I'm going wrong, but I don't know another
way to do it...

I'm not sure if it's possible, but if it is, it would simplify the
output by not duplicating the swap routine in each to do list item.

I also found an odd behaviour. When re-ordering items, the data
within the tiddler is correctly updated, but the checkbox display
doesn't update properly. This may be another impetus to not use
Eric's CheckBoxPlugin :(.

-Paul

PS: Should this be moved to TWDev, or is it appropriate for this
group?

Paul Kronenwetter

unread,
Jun 26, 2008, 7:34:06 PM6/26/08
to TiddlyWiki
Not a problem, I just didn't want Tobias to take the blame for my
code... :)

On Jun 26, 7:27 pm, Morris Gray <msg...@symbex.net.au> wrote:
> Sorry, Paul, for my oversight :-)
>
> However I didn't mention it was the code Tobias posted athttp://tiddlywiki.pastebin.com/m70ae136athat I pasted into the
> original plugin from which I discovered the bug. So I really couldn't
> truthfully say to whom I should have addressed the discovery.
>
> Nevertheless it's a cute little ToDo list :-)
>
> Morris Grayhttp://twhelp.tiddlyspot.com
> A TiddlyWiki help file for beginnershttp://sidebarpluginvault.tiddlyspot.com

Tobias Beer

unread,
Jun 26, 2008, 7:36:44 PM6/26/08
to TiddlyWiki
As for what Morris points out... I am quite curious what a solution to
this would look like!

Anyways, it is quite fun toying around with this.
I put up a tw with the mods I did for your plugin,
which not just includes sorting of task but now also also removing
entries...
Hope you'll find that useful somehow.

See here:

http://beertobias.googlepages.com/SortableTodosKronenpj.html

Tobias Beer

unread,
Jun 26, 2008, 7:43:58 PM6/26/08
to TiddlyWiki
Well, I just figured out that removing a task the way I implemented it
is buggy when deleting a task other than the last.
I'd quick guess, that it's due to the numbering of task data and that
one would need to renumber the entries or sth.
It's too late for me now, so I will look into that later (besides
removing of all my code redundancies ;-)

Paul Kronenwetter

unread,
Jun 26, 2008, 7:45:17 PM6/26/08
to TiddlyWiki
It's a little messy involving .replace(/'/,"'") in a few places. But
because the code is already within a string, some of the quotes need
to be escaped... Here's a snippet:

'document.getElementById(&#x27;tF' + titleURI + i +
'&#x27;).value).replace(/&#x27;/g,&#x27;\\&#x27;&#x27;);';

Yuck. But that's a little cleaner than when I thought I needed to
escape ', ", and \... DataTiddler takes care of the latter two since
they interfere with its storage of data...

Tobias - I'll take a look at your changes and merge them in later,
unless you get a chance to do it.

-Paul

Eric Shulman

unread,
Jun 26, 2008, 8:08:10 PM6/26/08
to TiddlyWiki
> I'm looking for a
> way to declare a function within a tiddler, within a <script>, and be
> able to call it from another <script>.  Something like this:

> <script>
> function yay(item) {
>   return item;}
>
> </script>
>
> <script label="Push here">
>   yay("Hi there!");
> </script>

Because <script>...</script> code is evaluated dynamically, you need
to explicitly declare the function as part of the global "window"
scope, like this:

<script>
window.yay=function(item) { return item; }
</script>

> I'm not sure if it's possible, but if it is, it would simplify the
> output by not duplicating the swap routine in each to do list item.

> I also found an odd behaviour.  When re-ordering items, the data
> within the tiddler is correctly updated, but the checkbox display
> doesn't update properly.  This may be another impetus to not use
> Eric's CheckBoxPlugin :(.

1) It appears that the only feature of CheckboxPlugin that you are
actually using is the 'onClickAfter' handler. Inasmuch as you are
already generating HTML code on-the-fly in other parts of the plugin
code, it would probably be much easier to simply use pure HTML.

2) However... it isn't clear to me why you are using DataTiddlerPlugin
to store the checkbox state information. Especially given that
CheckboxPlugin includes full support for using core-base *custom
fields* to store the state information in the tiddler using this
syntax:
[x(fieldname@tiddlername)]
and, you can omit the 'tiddlername' if you are using the current
tiddler to store the value:
[x(fieldname@)]
Thus, your checkbox generation code could be simplified to just:
text+="|[x(done"+i+"@)]|";
and all of the work to init/save/retrieve the checkbox state is done
by the plugin (including the onclick handling)

Also, if you use custom fields for storing the 'task title' text as
well, the text input could be changed to something like this:
text+="<html><input type=text size=60 ";
text+="value='"+store.getValue(title.replace(/'/g,"&#x27"),"task"+i)
+"' ";
text+=" onchange='store.setValue("+title+",this.value)' ></html>|";

HTH,
-e

P.S. This discussion should probably move to TWDev, since it is really
about writing plugin code...

Tobias Beer

unread,
Jun 27, 2008, 12:44:10 PM6/27/08
to TiddlyWiki
Fixed removing of tasks and reduced the code a bit... I also managed
to make "swaping" tasks a bit more generic.. just in case a task may
have more information attached to it (other than title and done-state)
that might need swapping later.

See here (plugin code only) and incorporate if you like what you see:

http://tiddlywiki.pastebin.com/f4984b805

or here (example):

http://beertobias.googlepages.com/SortableTodosKronenpj.html

Tobias Beer

unread,
Jun 27, 2008, 1:12:10 PM6/27/08
to TiddlyWiki
Hi Eric,

> 2) However... it isn't clear to me why you are using DataTiddlerPlugin to store the checkbox state information.

I had the same thought, however I was not sure how field data getting
and setting was achieved, so I did not fiddle with that as well while
playing with Pauls code. Thanks for the reference on how this is done
with CheckboxPlugin. I guess looking at its code may be a good start
to understand how to use native tiddler fields instead of <data>
markup within a tiddlers content.

> text+="value='"+store.getValue(title.replace(/'/g,"&#x27"),"task"+i)
What is -- title.replace(/'/g,"&#x27") -- for and why is it only done
when getting but not when setting field data? Why not simply use
'+title+' as you did for setting?

I believe you made a little mistake and forgot to reference to the
fieldname when setting, so that...
> text+=" onchange='store.setValue("+title+",this.value)' ></html>|";
should rather look like this:
> text+=" onchange='store.setValue("+title+","task"+i,this.value)' ></html>|";

Is that correct?

FND

unread,
Jun 27, 2008, 1:33:05 PM6/27/08
to Tiddl...@googlegroups.com
> P.S. This discussion should probably move to TWDev, since it is really
> about writing plugin code...

I tend to agree.

Also, Paul and Tobias, we could set you up with a Subversion account and
get you a contributors directory:
http://trac.tiddlywiki.org/browser/Trunk/contributors
That might help you collaborate on development.


-- F.

Paul Kronenwetter

unread,
Jun 27, 2008, 2:30:57 PM6/27/08
to TiddlyWiki, Tiddly...@googlegroups.com
All, CC'ing TiddlyWikiDev (I hope) to bridge and continue the thread
over there.

Tobias,

The title.replace(/'/g,"&#x27") fixes the single quote problem that
Morris found. The /'/g part is a regular expression to replace all
instances of a single quote with "&#x27" which is the javascript
version of the HTML entity code %27 or a single quote. I think Eric
was generating code quickly, on the fly and just missed putting the
replace(...) code in for setValue, it is needed.

I did some work last night converting the plugin to use fields
instead of <data> elements. Before doing a lot more, let me get that
code and Tobias's contributions into TiddlySpot and pastebin. I'll
have time this evening. As for SVN access, that's a big step isn't
it? ;). I wouldn't want anyone to get the idea that I know what I'm
doing...

Eric - As for why this, originally, used the DataTiddler plugin. I
wanted to see if I could do this plugin using a form from Udo's
FormTiddler plugin. From there it grew into an investigation of how
to reference objects from various places within the document.
Needless to say it got too complex and, being in the midst of it, I
needed another mind to tell me that I was going down a needlessly
complicated path.

Thanks!
-Paul

Tobias Beer

unread,
Jun 27, 2008, 3:42:10 PM6/27/08
to TiddlyWiki
> As for SVN access, that's a big step isn't it? ;).
> I wouldn't want anyone to get the idea that I know what I'm doing...

I'd like to join in with that, I guess. However, if at some point in
the future, I should feel like having something substantial to
contribute other than a post in the TiddlyWiki(Dev) group I'll know
now where to look to get things started svn wise. Ill see if I find a
twin thread @ TiddlyWikiDev later.

Paul Kronenwetter

unread,
Jul 2, 2008, 4:24:41 PM7/2/08
to TiddlyWikiDev, Tiddl...@googlegroups.com
All,

I've added another option to the ToDoPlugin code. It's now possible
to display complete tasks interspersed with incomplete items or as a
separate list below the incomplete list. The option is selected by
opening the plugin tiddler and selecting the option.

Version 0.1.0 of the plugin is available from my tiddlyspot page:
http://kronenpj.tiddlyspot.com/

I welcome any comments or problem reports here or via email to my
gmail address.
Share & enjoy!
-Paul

(CC'd to TiddlyWiki group as a release announcement)

Paul Kronenwetter wrote:
> Tobias - Good point. I've fixed the TiddlySpot version. I was trying
> to reduce the number of times the code appeared in the source, not
> considering the iterative concequences :)
>
> Thanks!
> -Paul
>
> On Jun 30, 5:18�pm, Tobias Beer <beertob...@googlemail.com> wrote:
> > The reason why removing a task from the top of the list takes longer
> > actually is due to swapping items... yet, it wouldn't take that long
> > if you'd remove refreshJs from swapJs and instead put it into each of
> > the commands that require refreshing the tiddler display.
> >
> > Tobias.

Paul Kronenwetter

unread,
Jul 27, 2008, 10:40:29 PM7/27/08
to TiddlyWikiDev, Tiddl...@googlegroups.com
For anyone who might be using my plugin, I've put a bit of work into
both the fields- and JSON-based versions this weekend and have
released version 0.2.0 of both. It's on my tiddlyspot page (http://
kronenpj.tiddlyspot.com/)

I've added another option, when Eric's NestedSliders plugin is
present, to include an "edit" button between the delete task button
and the checkbox . When the feature is enabled, the task appears as
normal text and the edit button reveals a text entry box. This is the
concept I mentioned in the previous post on the Dev list. Thanks to
Eric's plugin, it was very easy to create.

I've also cleaned up the code as it was repetitive and pretty
embarrassing. In doing so, I've replaced the code that used the
CheckboxPlugin in the forms plugin with HTML and form handling used by
the JSON plugin. I am also preparing to merge these two into a single
plugin that handles both fields and JSON lists dynamically. I already
have a plan for implementing it, but I wanted to get this version in
the wild first.

They both should be backward compatible with any existing to do lists
created earlier so the upgrade should be safe. If you find otherwise,
or have any suggestions for improvements, I'd love to hear them!

-Paul

On Jul 6, 9:51 pm, Paul Kronenwetter <krone...@gmail.com> wrote:
> Xavier,
>
>   Thanks for the praise...  I'm thinking about making an "edit" mode
> where the incomplete items are also rendered in standard Wiki form,
> but I haven't quite figured out how I want to do it yet.  :)
>
> Any other suggestions?
> -Paul
>
> On Jul 4, 3:54 am, Xavier Verges <xver...@gmail.com> wrote:
>
> > Cool! I've liked
> > * having links render as links when items are completed
> > * being able to specify the previsouly-too-narrow width
>
> > Nice work!


>
> > > (CC'd to TiddlyWiki group as a release announcement)
>

> > I'm not sure if it made it there.
>
> > -Xv

Reply all
Reply to author
Forward
0 new messages