Hi TwWizards

I'm trying to make my own version of Google+ in TiddlySpace (a work in
progress...)

My greatest obstacle (at the moment) is that I can't make a html-form,
which creates a new topic - or a new subtopic to an existing topic.
It won't save changes... http://d-minus.tiddlyspace.com/#CreateTopic

I thought I had the solution when I added "var fields=merge(t?t.fields:
{},config.defaultCustomFields,true);" in the code, however it didn't
do the trick..

Please have a look at http://d-minus.tiddlyspace.com/#CreateTopic.
Feel free to give it a spin - and make changes. It's far from
finished.
All TiddlySpace users can edit it - and you are welcome to do so.
(I still have @d-plus, which I will use as a "Topics & comments" space
meant for inclusion  -When it's finished)

Here's the code for the CreateTopic tiddler (maybe you can see my
mistakes just from looking at it?):

<html><hide linebreaks><!-- see HTMLFormattingPlugin --><form
action="javascript:;"
        onsubmit="
                /* validate new title */
                var t=this.title.value;
                if (!t.length || t==this.title.defaultValue)
                        { alert('Please choose a title'); this.title.focus(); 
return
false; }
                if (store.tiddlerExists(t) && !
confirm(config.messages.overwriteWarning.format([t])))
                        { this.title.focus(); return false;
                }

                /* get current tiddler (if any) */
                var tid=store.getTiddler(t);
                var who=tid?tid.modifier:config.options.txtUserName;
                var when=tid?tid.modified:new Date();
                var txt=tid?tid.text:'';
                var tags=tid?tid.tags:[];
                var fields=merge(t?t.fields:
{},config.defaultCustomFields,true);

                /* get form values and construct new tiddler text */
                var fmt='%0- %1';
                var newtxt=fmt.format([this.felt0.value,felt1.value]);

                /* insert new text at marker (or end, if no marker) */
                var marker='/%comment%/';
                if (txt.indexOf(marker)==-1) txt=txt+newtxt;
                else txt=txt.replace(new RegExp(marker.escapeRegExp()),newtxt
+marker);

                /* get new tags and add to existing tags (if any) */
                var newtags=this.tagsfield.value.readBracketedList();
                for (var i=0; i<newtags.length; i++) 
tags.pushUnique(newtags[i]);
                var fields=merge(t?t.fields:
{},config.defaultCustomFields,true);

                /* write and show tiddler */
                store.saveTiddler(t,t,txt, who, when, tags, fields);
                story.displayTiddler(story.findContainingTiddler(this),t);
                return false;">

Tiddler title <input name="title" value="CreateTopic"
onfocus="this.select()"><br>
Text <textarea name="felt0" rows=5 style="width:100%;">Write</
textarea>
Tags <input name="tagsfield" value="topic" style="width:100%;">
<input type="submit" value="create a new topic - or add to existing">
</form></html>/%
!button
{{wrap{@@position:relative;+++^*[<img src="comment-edit.png">|add a
topic - or add subtopic to existing][<img src="shutdown.png">|
close]...<<tiddler CreateTopic>>===@@}}}
!end
%/

Cheers Måns Mårtensson

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to