| version 1.8, 2010/02/13 22:32:18 |
version 1.10, 2010/02/17 02:16:28 |
|
|
| <html><head> |
<html><head> |
| <!-- $AFresh1: index.html,v 1.7 2010/02/02 06:11:31 andrew Exp $ --> |
<!-- $AFresh1: index.html,v 1.9 2010/02/16 03:45:17 andrew Exp $ --> |
| <title>todo.txt - ajax client</title> |
<title>todo.txt - ajax client</title> |
| <link rel="stylesheet" href="todo.css"> |
<link rel="stylesheet" href="todo.css"> |
| |
|
| <script src="scriptaculous/lib/prototype.js"></script> |
<script src="scriptaculous/lib/prototype.js"></script> |
| <script src="scriptaculous/src/scriptaculous.js?load=effects,controls"></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 getFiles() { |
var TODO = function () { |
| $('files').update("Getting Files . . ."); |
var base_url = '/~andrew/user-bin/todo.cgi', |
| new Ajax.Updater('files', base_url, { |
editors = {}, |
| method: 'get', |
|
| //insertion: Insertion.Top |
makeEntryEditor = function(id, list_url) { |
| }); |
var url = list_url + '/entry/' + id; |
| } |
|
| |
|
| function updateList(list, transport) { |
if (!editors[id]) { |
| var todo = transport.responseJSON; |
editors[id] = { |
| |
list_url: list_url, |
| |
editor: new Ajax.InPlaceEditor( |
| |
id, url + '.json', { |
| |
cols: 80, |
| |
rows: 1, |
| |
onComplete: updateEntry, |
| |
} |
| |
), |
| |
}; |
| |
} |
| |
}, |
| |
|
| $('list').update(''); |
updateEntry = function(transport, element) { |
| for (var i=0; i <= todo.length; i++) { |
var list_url = editors[element.id].list_url, |
| $('list').insert({ bottom: new Element('div', { id: todo[i].md5 }) }); |
entry; |
| $(todo[i].md5).update(todo[i].text); |
|
| |
|
| var entry_url = base_url + '/' + list + '/entry/' + todo[i].md5; |
if (transport && transport.responseJSON) { |
| |
entry = transport.responseJSON; |
| |
|
| new Ajax.InPlaceEditor(todo[i].md5, entry_url + '.txt', { |
element.update(entry.text); |
| cols: 80, |
|
| //loadTextURL: entry_url + '.txt', |
|
| }); |
|
| } |
|
| } |
|
| |
|
| function getList(list) { |
if (element.id !== entry.md5) { |
| $('list').update("Getting List . . ."); |
if (editors[element.id]) { |
| var list_url = base_url + '/' + list; |
editors[element.id].editor.dispose(); |
| |
delete editors[element.id]; |
| |
} |
| |
|
| new Ajax.Request(list_url + '.json', { |
element.id = entry.md5; |
| method: 'get', |
|
| onSuccess: function(transport) { updateList(list, transport) }, |
|
| }); |
|
| } |
|
| |
|
| |
makeEntryEditor(element.id, list_url); |
| |
} |
| |
} |
| |
}, |
| |
|
| |
updateList = function (list_url, transport) { |
| |
var i, |
| |
todo = transport.responseJSON, |
| |
url = ''; |
| |
|
| |
$("list").update(); |
| |
|
| |
for (i=0; i <= todo.length; i++) { |
| |
$('list').insert({ |
| |
bottom: new Element('div', |
| |
{ id: todo[i].md5 } |
| |
).update(todo[i].text) |
| |
} |
| |
); |
| |
|
| |
makeEntryEditor(todo[i].md5, list_url); |
| |
} |
| |
}; |
| |
|
| |
return { |
| |
getFiles: function () { |
| |
$('files').update("Getting Files . . ."); |
| |
|
| |
new Ajax.Updater('files', base_url, { |
| |
method: 'get', |
| |
}); |
| |
}, |
| |
|
| |
getTags: function (list) { |
| |
var url = base_url + '/' + list + '/tags'; |
| |
$('tags').update("Getting Tags. . ."); |
| |
|
| |
new Ajax.Request(url + '.json', { |
| |
method: 'get', |
| |
onSuccess: function (transport) { |
| |
var data = transport.responseJSON, |
| |
k, |
| |
html = ''; |
| |
for (k in data) { |
| |
if (data.hasOwnProperty(k)) { |
| |
html += k + ": " + data[k] + "<br/>\n"; |
| |
} |
| |
} |
| |
$("tags").innerHTML = html; |
| |
}, |
| |
}); |
| |
}, |
| |
|
| |
getList: function (list) { |
| |
var url = base_url + '/' + list; |
| |
$('list').update("Getting List . . ."); |
| |
|
| |
new Ajax.Request(url + '.json', { |
| |
method: 'get', |
| |
onSuccess: function (transport) { updateList(url, transport) }, |
| |
}); |
| |
|
| |
}, |
| |
}; |
| |
}(); |
| |
|
| </script> |
</script> |
| </head> |
</head> |
| |
|
| <body onLoad="getFiles();getList('todo')"> |
<body onLoad="TODO.getList('todo');TODO.getTags('todo');TODO.getFiles()"> |
| <h1>Files:</h1><div id='files'></div> |
<h1>Files:</h1><div id='files'></div> |
| |
<h1>Tags:</h1> <div id='tags'></div> |
| <h1>List:</h1> <div id='list'></div> |
<h1>List:</h1> <div id='list'></div> |
| </body></html> |
</body></html> |