84 lines
2.0 KiB
HTML
84 lines
2.0 KiB
HTML
$def with (torrent_list, organize_filters)
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
$:render.header(_("AJAX index"), 'home')
|
|
|
|
<!--
|
|
Using this lib because it was linked from http://json-rpc.org/wiki/implementations
|
|
http://code.google.com/p/json-xml-rpc/wiki/DocumentationForJavaScript
|
|
-->
|
|
<script language="javascript" src="/template/static/js/rpc.js"></script>
|
|
|
|
<div class="info">Just a demo template for damoxc
|
|
(or anyone else who wants to make an ajax template)</div>
|
|
|
|
<script language="javascript">
|
|
|
|
var service = new rpc.ServiceProxy("$base/json/rpc", {/*options*/});
|
|
|
|
function get_session_state( ) {
|
|
service.get_session_state({params:[],
|
|
onSuccess:function(result){
|
|
alert("session_state: " + result);
|
|
},
|
|
onException:function(errorObj){
|
|
alert("Error: " + errorObj);
|
|
}
|
|
});
|
|
};
|
|
|
|
function get_torrents_status(torrent_ids) {
|
|
//alert("start status:");
|
|
service.get_torrents_status({
|
|
params:[torrent_ids,["name","progress"]],
|
|
onSuccess:function(torrent_list){
|
|
for (var torrent_id in torrent_list){
|
|
torrent = torrent_list[torrent_id]
|
|
//alert(torrent);
|
|
alert(torrent.name + " " + torrent.progress + "%");
|
|
}
|
|
},
|
|
onException:function(errorObj){
|
|
alert("Error: " + errorObj);
|
|
}
|
|
});
|
|
};
|
|
|
|
|
|
function list_torrents(torrent_ids) {
|
|
//This code will send a data object via a GET request and alert the retrieved data.
|
|
service.get_session_state({params:[],
|
|
onSuccess:function(torrent_ids){
|
|
get_torrents_status(torrent_ids)
|
|
},
|
|
onException:function(errorObj){
|
|
alert("Error: " + errorObj);
|
|
}
|
|
});
|
|
};
|
|
|
|
|
|
function update_torrent(torrent) {
|
|
alert(torrent.name);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<button onclick="get_session_state()">get_session_state()</button>
|
|
|
|
<button onclick="list_torrents()">List torrents</button>
|
|
|
|
|
|
<div id="torrent_list">
|
|
|
|
</div>
|
|
|
|
$:render.footer()
|
|
|
|
|