[BACK]Return to index.html CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo-REST-API / example / htdocs

Diff for /todotxt/Text-Todo-REST-API/example/htdocs/index.html between version 1.5 and 1.12

version 1.5, 2010/01/31 03:12:02 version 1.12, 2010/02/18 06:25:31
Line 1 
Line 1 
 <html><head>  <html><head>
 <title>todo.txt - ajax client</title>          <!-- $AFresh1: index.html,v 1.11 2010/02/18 05:35:04 andrew Exp $ -->
 <link rel="stylesheet" href="todo.css">          <title>todo.txt - ajax client</title>
 <!-- <script src="http://o.aolcdn.com/dojo/1.4/dojo/dojo.xd.js"></script> -->          <link rel="stylesheet" href="todo.css">
 <script src="dojo/1.4/dojo/dojo.xd.js"></script>  
           <script src="scriptaculous/lib/prototype.js"></script>
           <script src="scriptaculous/src/scriptaculous.js?load=effects,controls"></script>
 <script type='text/javascript'>  <script type='text/javascript'>
 var base_url = '/~andrew/user-bin/todo.cgi';  
   
   function loadIntoNode(data, xhr){  var TODO = function () {
     if(xhr.args.node){      var base_url = '/~andrew/user-bin/todo.cgi',
       xhr.args.node.innerHTML = data;          editors  = {},
     }  
   }      makeEntryEditor  = function(list, entry) {
 function getFiles() {          var url = base_url + '/' + list + '/entry/' + entry.line,
   dojo.byId('files').innerHTML = "Getting Files . . .";              id  = entry.id;
   dojo.xhrGet({  
     url: base_url,  
     node: dojo.byId("files"),  
     load: loadIntoNode  
   });  
   
 }          if (!id) {
 function getList(list) {              id = 'entry_' + entry.line;
   dojo.byId('list').innerHTML = "Getting List . . .";          }
   dojo.xhrGet({  
     url: base_url + '/' + list + '.txt',          if (editors[id]) {
     node: dojo.byId("list"),                  editors[id].dispose();
     load: loadIntoNode                  delete editors[id];
   });          }
 }  
 function getEntry(list, entry) {          editors[id] = new Ajax.InPlaceEditor( id, url + '.json', {
         document.getElementById('entry').innerHTML = "Getting Entry . . .";                  cols: 80,
   dojo.xhrGet({                  rows: 1,
     url: base_url + '/' + list + '/entry/' + entry + '.md5',                  callback: function(form, value) {
     node: dojo.byId("entry"),                      entry.oldText = entry.text;
     load: loadIntoNode                      entry.text = value;
   });                      return entry;
 }                  },
                   onComplete: function (transport, element) {
                       if (transport && transport.responseJSON) {
                           updateEntry( list, transport.responseJSON, element);
                       }
                   }
               }
           );
       },
   
       updateEntry = function(list, entry, element) {
           if (!entry.id) {
               entry.id = 'entry_' + entry.line;
           }
           var liId = 'li_' + entry.id;
   
           if (parseInt(entry.line) !== $(liId).value) {
               for (k in editors) {
                   if (editors.hasOwnProperty(k)) {
                       editors[k].dispose();
                       delete editors[k];
                   }
               }
               return getList(list);
           }
   
           $(liId).update(
               new Element('span', { id: entry.id }). update(entry.text)
           ).insert({
               top: new Element('input', {
                   type: 'checkbox' ,
                   id:   'do_' + entry.line,
                   checked: entry.done,
                   disabled: true,
               })
           });
   
           makeEntryEditor(list, entry);
       },
   
       updateList = function (list, transport) {
           var i,
             todo = transport.responseJSON,
             element = new Element('ol'),
             entryElement;
   
           $("list").update( element );
   
           for (i=0; i <= todo.length; i++) {
               todo[i].id = 'entry_' + todo[i].line;
   
               entryElement = new Element('li', {
                   id: 'li_' + todo[i].id,
                   value: todo[i].line
               });
   
               element.insert(entryElement);
   
               updateEntry(list, todo[i], entryElement);
           }
       },
   
       getFiles = function () {
           $('files').update("Getting Files . . .");
   
           new Ajax.Updater('files', base_url, {
               method: 'get',
           });
       },
   
       getTags = function (list) {
               $('tags').update("Getting Tags. . .");
   
               var url = base_url + '/' + list + '/tags';
   
               new Ajax.Request(url + '.json', {
               method: 'get',
               onSuccess: function (transport) {
                   var k,
                       data = transport.responseJSON,
                       element = new Element('ul');
   
                   $("tags").update(element);
                   for (k in data) {
                       if (data.hasOwnProperty(k)) {
                       element.insert(
                           new Element('li', {
                               id: 'tag_' + k,
                               }).update( k + ": " + data[k]  )
                       );
                       getTag(list, k);
                       }
                   }
               },
           });
       },
   
       getTag = function( list, tag ) {
           new Ajax.Request(base_url + '/' + list + '/tags/' + tag + '.json', {
               method: 'get',
               onSuccess: function (transport) {
                   if (transport && transport.responseJSON) {
                       var i,
                           myTags = transport.responseJSON,
                           element = new Element('ul');
   
                       if (myTags.length) {
                           $('tag_' + tag).insert(element);
   
                           for (i=0; i<myTags.length; i++) {
                               element.insert( new Element('li').
                                   update( myTags[i] ));
                           }
                       }
                   }
               }
           });
       },
   
       getList = function (list) {
           $('list').update("Getting List . . .");
   
           new Ajax.Request(base_url + '/' + list + '.json', {
               method:    'get',
               onSuccess: function (transport) { updateList(list, transport) },
           });
   
       };
   
       return {
           getList:  getList,
           getFiles: getFiles,
           getTags:  getTags,
       };
   }();
   
 </script>  </script>
 </head>  </head>
 <body onLoad="getFiles();getList('todo');getEntry('todo',5)">  
   
 <!-- $AFresh1: index.html,v 1.4 2010/01/31 02:31:47 andrew Exp $ -->  <body onLoad="TODO.getList('todo');TODO.getTags('todo');TODO.getFiles()">
 <div id='files'></div>      <h1>Files:</h1><div id='files'></div>
 <pre><div id='list'></div></pre>      <h1>List:</h1> <div id='list'></div>
 <div id='entry'></div>      <h1>Tags:</h1> <div id='tags'></div>
 </body></html>  </body></html>

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.12

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>