version 1.4, 2010/01/31 02:31:47 |
version 1.10, 2010/02/17 02:16:28 |
|
|
<html><head> |
<html><head> |
<title>todo.txt - ajax client</title> |
<!-- $AFresh1: index.html,v 1.9 2010/02/16 03:45:17 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="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(id, list_url) { |
function getFiles() { |
var url = list_url + '/entry/' + id; |
dojo.byId('files').innerHTML = "Getting Files . . ."; |
|
dojo.xhrGet({ |
|
url: base_url, |
|
node: dojo.byId("files"), |
|
load: loadIntoNode |
|
}); |
|
|
|
} |
if (!editors[id]) { |
function getList(list) { |
editors[id] = { |
dojo.byId('list').innerHTML = "Getting List . . ."; |
list_url: list_url, |
dojo.xhrGet({ |
editor: new Ajax.InPlaceEditor( |
url: base_url + '/' + list + '.txt', |
id, url + '.json', { |
node: dojo.byId("list"), |
cols: 80, |
load: loadIntoNode |
rows: 1, |
}); |
onComplete: updateEntry, |
} |
} |
function getEntry(list, entry) { |
), |
document.getElementById('entry').innerHTML = "Getting Entry . . ."; |
}; |
dojo.xhrGet({ |
} |
url: base_url + '/' + list + '/entry/' + entry + '.md5', |
}, |
node: dojo.byId("entry"), |
|
load: loadIntoNode |
updateEntry = function(transport, element) { |
}); |
var list_url = editors[element.id].list_url, |
} |
entry; |
|
|
|
if (transport && transport.responseJSON) { |
|
entry = transport.responseJSON; |
|
|
|
element.update(entry.text); |
|
|
|
if (element.id !== entry.md5) { |
|
if (editors[element.id]) { |
|
editors[element.id].editor.dispose(); |
|
delete editors[element.id]; |
|
} |
|
|
|
element.id = entry.md5; |
|
|
|
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');getEntry('todo',5)"> |
|
|
|
<!-- $AFresh1: index.html,v 1.3 2010/01/19 03:33:13 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>Tags:</h1> <div id='tags'></div> |
<div id='entry'></div> |
<h1>List:</h1> <div id='list'></div> |
</body></html> |
</body></html> |