version 1.2, 2010/01/18 04:51:15 |
version 1.7, 2010/02/02 06:11:31 |
|
|
<html><head> |
<html><head> |
<title>todo.txt - javascript client</title> |
<!-- $AFresh1: index.html,v 1.6 2010/01/31 03:40:21 andrew Exp $ --> |
<script src="prototype.js" type="text/javascript"></script> |
<title>todo.txt - ajax client</title> |
|
<link rel="stylesheet" href="todo.css"> |
|
<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 getFiles() { |
function getFiles() { |
document.getElementById('files').innerHTML = "Getting Files . . ."; |
$('files').update("Getting Files . . ."); |
new Ajax.Request('/~andrew/user-bin/todo.cgi/andrew.txt', { |
new Ajax.Updater('files', base_url, { |
method: 'get', |
method: 'get', |
onSuccess: function(response) { |
//insertion: Insertion.Top |
document.getElementById('files').innerHTML = response.responseText; |
}); |
} |
|
}); |
|
} |
} |
|
|
|
function updateList(list, transport) { |
|
var todo = transport.responseJSON; |
|
|
|
$('list').update(''); |
|
for (var i=0; i <= todo.length; i++) { |
|
$('list').insert({ bottom: new Element('div', { id: todo[i].md5 }) }); |
|
$(todo[i].md5).update(todo[i].text); |
|
|
|
var entry_url = base_url + '/' + list + '/' + todo[i].md5; |
|
|
|
new Ajax.InPlaceEditor(todo[i].md5, entry_url + '.txt', { |
|
loadTextURL: entry_url + '.txt', |
|
}); |
|
} |
|
} |
|
|
function getList(list) { |
function getList(list) { |
document.getElementById('list').innerHTML = "Getting List . . ."; |
$('list').update("Getting List . . ."); |
new Ajax.Request('/~andrew/user-bin/todo.cgi/andrew/' + list + '.txt', { |
var list_url = base_url + '/' + list; |
method: 'get', |
|
onSuccess: function(response) { |
new Ajax.Request(list_url + '.json', { |
document.getElementById('list').innerHTML = |
method: 'get', |
'<pre>' + response.responseText + '</pre>'; |
onSuccess: function(transport) { updateList(list, transport) }, |
} |
}); |
}); |
|
} |
} |
function getEntry(list, entry) { |
|
document.getElementById('entry').innerHTML = "Getting Entry . . ."; |
|
new Ajax.Request('/~andrew/user-bin/todo.cgi/andrew/' + list + '/entry/' + entry + '.md5', { |
|
method: 'get', |
|
onSuccess: function(response) { |
|
document.getElementById('entry').innerHTML = |
|
'<pre>' + response.responseText + '</pre>'; |
|
} |
|
}); |
|
} |
|
</script> |
</script> |
</head> |
</head> |
<body onLoad="getFiles();getList('todo');getEntry('todo',5)"> |
|
<!-- $AFresh1$ --> |
<body onLoad="getFiles();getList('todo')"> |
<div id='files'></div> |
<h1>Files:</h1><div id='files'></div> |
<div id='list'></div> |
<h1>List:</h1> <div id='list'></div> |
<div id='entry'></div> |
|
</body></html> |
</body></html> |