+ Reply to Thread
Page 5 of 11 FirstFirst ... 3 4 5 6 7 ... LastLast
Results 41 to 50 of 108

Thread: TODO Template on lyonsdemo site?

  1. #41
    Join Date
    May 2009
    Location
    Houston, Tx
    Posts
    237

    Default

    Well that sort-of worked. I'm no longer getting the error! But the todo list is having some super-weird behavior... For instance, if an item is not completed, checking the box doesn't automaticlly update it, but when you click the edit button after checking the box it updates the page properties and the gui. But it doesn't work the same backwards. Unchecking the box and clicking edit will change the page properties but not the gui. It's so weird. No errors are popping up either...

    This is only happening on IE.

  2. #42
    Join Date
    May 2009
    Location
    Houston, Tx
    Posts
    237

    Default

    I did some testing and came up with these results:
    Code:
    Deki.$('#todolist input').bind('change', function() {
             var $this = Deki.$(this);
             @todoupdate({ index: $this.val(), entry: { done: $this.checked } });
     });
    This code is running, but the selector isn't picking anything up. (I figured this out by placing a lot of alert()s everywhere. :P )

    Again, this is only happening in IE

    Edit: Well, I did even more testing and found that if you change 'change' to 'click' it almost works. When setting something as unfinished, it changes, but when setting something as completed it does not.
    Last edited by blakeh; 06-11-2009 at 08:47 PM.

  3. #43
    Join Date
    May 2009
    Location
    Houston, Tx
    Posts
    237

    Default

    Quote Originally Posted by pktloss View Post
    Well I sure hope someone can explain this to me. I am seeing something that is very odd IMHO.

    It seems I have the To Do script working, but very odd behavior.

    If I go to the page in Firefox and add a task via the To Do it works.

    If I then go to the page in IE8 I see the task I added. If I try to add a task in IE8 I loose the new task I tried to add as well as the old task that was previously there.

    If I go back to Firefox the task is gone from Firefox as well. I can add it again and all works fine. If I stay within Firefox there is no problem, but if I go to IE8 there is a problem only when trying to add a task.

    The real kicker to this is that if I go to the lyonsdemo site in IE8 and use the TODO there it works just fine. I can add tasks and such with no issue using IE8.

    Does this make sense to someone and help in some way to figure out what is going on?
    On further investigation, I found that this is the case that I'm seeing. I only thought it was different because I switched back to Firefox and refreshed and everything was fine. It almost seems like IE8 is caching the API call and restoring that instead of calling it again (Deki.Api.Reload(#todolist); ) It's so weird. All the page properties are right but the page isn't behaving.

  4. #44
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    It's quite possible that IE8 is doing some kind of caching. $.ajax has a parameter to disable caching, which amounts to adding random data to the uri. You could add a query parameter to the Deki.Api.Reload function call. This would force IE to re-fetch it since the URI is not the same anymore.

    It would look like this:
    Code:
    Deki.Api.Reload(#todolist, { nocache: new Date().getTime() })
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  5. #45
    Join Date
    May 2009
    Location
    Houston, Tx
    Posts
    237

    Default

    That fixed it! I'm not seeing any problems anymore so here's the final code:
    Code:
    <h1>ToDo</h1>
    <p>&nbsp;</p>
    <pre class="script">
    // includes
    dekiapi();
    jquery.ui('smoothness');
    &lt;div id="deki-todo"&gt;
    // input form
    &lt;form&gt;
        &lt;input id="todoid" type="hidden" value="" /&gt;
    &nbsp;&nbsp;&nbsp; &lt;div class="todo-assign"&gt;
    &nbsp;&nbsp;&nbsp; " Task: "; 
    &nbsp;&nbsp;&nbsp; &lt;/div&gt;
        &lt;div class="todo-who"&gt;
        " Who: ";
        &lt;select id="todowho"&gt;
            foreach(var u in site.users where !u.anonymous) {
                &lt;option value=(u.name) selected=((u.id == user.id) ? 'selected' : nil)&gt;u.name&lt;/option&gt;
            }
        &lt;/select&gt;
        &lt;/div&gt;
        &lt;div class="todo-what"&gt;
        "What: "; &lt;input id="todowhat" type="text" /&gt;
        &lt;/div&gt;
    &nbsp;&nbsp;&nbsp; &lt;div class="todo-when"&gt;
        " When: "; &lt;input id="todowhen" type="text" value=(date.format(date.now, 'MM/dd/yyyy')) ctor="$this.datepicker();" /&gt;
        &lt;/div&gt;
    &nbsp;&nbsp;&nbsp; &lt;div class="todo-submit"&gt;
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;input id="todoadd" type="button" value="Add" ctor="
            when($this.click) {
                @todoupdate({ index: #todoid.val(), entry: { what: #todowhat.val(), who: #todowho.val(), when: #todowhen.val(), author: {{user.name}}, done: false }});
                #todoid.val('');
                #todowhat.val('');
                #todoadd.val('Add');
                #tododelete.hide();
                #todoadd.blur();
            }
            when(#tododelete.click) {
                @todoupdate({ index: #todoid.val(), entry: null });
                #todoid.val('');
                #todowhat.val('');
                #todoadd.val('Add');
                #tododelete.hide();
                #todoadd.blur();
            }
            when(@todoedit) {
                Deki.Api.ReadPageProperty(null, 'urn:custom.mindtouch.com#todo', function(result) {
                    var data = YAHOO.lang.JSON.parse(result.value || '[]');
                    #todoid.val(@todoedit.index);
                    #todowhat.val(data[@todoedit.index].what);
                    #todowhen.val(data[@todoedit.index].when);
                    #todowho.val(data[@todoedit.index].who);
                    #todoadd.val('Update');
                    #tododelete.show();
                }, function(result) {
                    alert('An error occurred trying to read the TODO list (status: ' + result.status + ' - ' + result.text + ')');
                });
            }
            when(@todoupdate) {
                Deki.Api.ReadPageProperty(null, 'urn:custom.mindtouch.com#todo', function(result) {
                    var data = eval('(' + (result.value || '[]') + ')');
                    if(@todoupdate.index !== '') {
                        if(@todoupdate.entry === null) {
                            data.splice(@todoupdate.index, 1);
                        } else {
                            Deki.$.extend(data[@todoupdate.index], @todoupdate.entry);
                        }
                    } else {
                        data.push(@todoupdate.entry);
                    }
                    if(result.etag) {
                        Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag, function() {
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Deki.Api.Reload(#todolist, { nocache: new Date().getTime() }, function() { ToDoWireControls(); });
                        }, function(result) {
                            alert('An error occurred trying to update the TODO list (status: ' + result.status + ' - ' + result.text + ')');
                        });
                    } else {
                        Deki.Api.CreatePageProperty(null, 'urn:custom.mindtouch.com#todo', YAHOO.lang.JSON.stringify(data), function() {
                            Deki.Api.Reload(#todolist);
                        }, function(result) {
                            alert('An error occurred trying to create the TODO list (status: ' + result.status + ' - ' + result.text + ')');
                        });
                    }
                }, function(result) {
                    alert('An error occurred trying to read the TODO list (status: ' + result.status + ' - ' + result.text + ')');
                });
            }
        " /&gt;
        &lt;input id="tododelete" style="display: none;" type="button" value="Delete" /&gt;
    &nbsp;&nbsp;&nbsp; &lt;/div&gt;
    &lt;/form&gt;
    
    // todo list
    var todo = json.parse(page.properties["todo"].text ?? "") ?? [];
    let todo = [ item .. { index: __index } foreach var item in todo ];
    let todo = list.sort(todo, _, true, "date.compare($left.when, $right.when)");
    &lt;table id="todolist" cellspacing="0" cellpadding="0"&gt;
    &nbsp;&nbsp;&nbsp; &lt;colgroup&gt;
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;col width="20" /&gt;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;col width="20%" /&gt;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;col /&gt;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;col width="15%" /&gt;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;col width="75" /&gt;
    &nbsp;&nbsp;&nbsp; &lt;/colgroup&gt;
        &lt;tr&gt;
            &lt;th&gt;string.nbsp&lt;/th&gt;
            &lt;th&gt;"When"&lt;/th&gt;
            &lt;th&gt;"What"&lt;/th&gt;
            &lt;th&gt;"Who"&lt;/th&gt;
            &lt;th&gt;string.nbsp&lt;/th&gt;
        &lt;/tr&gt;
        foreach(var entry in todo) {
            var class = "";
            if(entry.done) let class..= "completed ";
            if(date.issameday(date.now, entry.when)) let class ..= "due-today ";
            else if(date.isafter(date.now, entry.when)) let class ..= "due-past ";
            var title = "Created by " .. entry.author;
            &lt;tr class=(class)&gt;
                &lt;td&gt;&lt;input type="checkbox" name="done" value=(entry.index) checked=(entry.done ? 'checked' : nil) /&gt;&lt;/td&gt;
                &lt;td title=(title)&gt;&lt;span&gt;entry.when&lt;/span&gt;&lt;/td&gt;
                &lt;td title=(title)&gt;&lt;span&gt;entry.what&lt;/span&gt;&lt;/td&gt;
                &lt;td title=(title)&gt;&lt;span&gt;entry.who&lt;/span&gt;&lt;/td&gt;
                &lt;td class="todo-edit"&gt;&lt;a href="#" rel=(entry.index)&gt;"edit"&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt;
        }
    &lt;/table&gt;
    &lt;/div&gt;
    &lt;script type="text/jem"&gt;"
    function ToDoWireControls() {
        Deki.$('#todolist a').bind('click', function() {
            @todoedit({ index: Deki.$(this).attr('rel') }); 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  #todowhat.select();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;
        });
        Deki.$('#todolist input').bind('click', function() {
            var $this = Deki.$(this);
            @todoupdate({ index: $this.val(), entry: { done: this.checked } });
        });
    }
    ToDoWireControls();
    "&lt;/script&gt;
    </pre>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><style type="text/css">/*<![CDATA[*/
    
    #deki-todo {
        margin: 0;
        padding: 4px; 
        width: 98%;
    }
    #deki-todo table {
        width: 100%; 
        margin: 0;
    }
    #deki-todo table td {
        border-bottom: 1px solid #000;
        padding: 4px 2px;
    }
    #deki-todo tr td.todo-edit {
        text-align: right;
        padding-right: 8px;
    }
    #deki-todo tr.due-today td {
        background-color: #ff0;     
    }
    #deki-todo tr.completed td {
        background-color: #fff;
    }
    #deki-todo tr.completed td span {
        text-decoration: line-through;
    }
    #deki-todo tr.due-past td, 
    #deki-todo tr.due-past td.todo-edit a {
        color: #777;    
    }
    #deki-todo table th {
        font-size: 14px;
        font-weight: bold;
        text-align: left;
        border-bottom: 2px solid #000;
    }
    #deki-todo form {
        padding: 4px; 
        background-color: #000;
        color: #fff; 
        overflow: hidden;
        margin-bottom: 8px;
    }
    #deki-todo div.todo-assign {
        font-weight: bold;
    }
    #deki-todo form, 
    #deki-todo form input, 
    #deki-todo form select {
        font-size: 11px;
    }
    #deki-todo form div {
        padding-right: 8px;    
        float: left;
    }
    #deki-todo div.todo-submit {
        float: right; 
        padding-right: 0px;
    }
    #deki-todo div.todo-submit input {
        margin-right: 4px;
    }
    #deki-todo table tr td.todo-edit a {
        background: url(/skins/common/icons/silk/page_white_edit.png) no-repeat center left;
        color: #000;
        text-decoration: none;
        padding: 3px 3px 3px 21px;
        font-size: 11px;
    }
    #deki-todo table tr td.todo-edit a:hover {
        text-decoration: underline;
    }
    /*]]>*/</style></p>
    <p>&nbsp;</p>
    Last edited by blakeh; 06-15-2009 at 01:28 PM.

  6. #46
    Join Date
    May 2009
    Location
    Houston, Tx
    Posts
    237

    Default Extension?

    Would it be possible to make an extension out of this? That way you don't have to have UNSAFECONTENT rights to add a todo list.
    I tried popping it into an xml extension file but I got a "message body with content type 'text/xml' is not well-formed xml" error. I'm guessing this would be a lot of trouble?

  7. #47
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    The biggest issue is that it's built on top of another extension, namely dekiapi.xml. Extension can't invoke other extensions.

    The good news is that we're working on an easy way to publish templates to mindtouch sites. This will take away the whole hassle of copying, pasting, and then debugging what went wrong in the process.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  8. #48
    Join Date
    May 2009
    Location
    Houston, Tx
    Posts
    237

    Default

    OOOooooh that will be nice. This means that you can publish templates from external wikis?

  9. #49
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    First iteration will be a 2 step process: a template author can *export" a set of pages/templates/files and create a package. The package can be uploaded anywhere or attached to a page on developer.mindtouch.com. Anyone who wants to install it, then downloads it, and *imports* the package into their site. No error prone copy pasting involved! And multi-template solutions become a breeze to install... at least, that's the idea!
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  10. #50
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    I've added Template:TODO to the community portal. The code has some modifications that make it unnecessary to use source mode. Everything needed is visible in plain sight. Also, I updated the code for MindTouch.Deki.Reload() in the dekiapi.xml extension to always add the "nocache" query parameter.

    Lastly, I made one minor change to the TODO template. Now it detects if there are more than a certain number of users on the site. If so, it won't attempt to populate the "Who" box with all of them but will instead become a textbox. I have *NOT* fully tested this change yet, though it seemed to work at first brush.
    Last edited by SteveB; 06-20-2009 at 10:05 AM. Reason: oops... forgot an essential word
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts