OxFF/test/import.html

60 lines
1.7 KiB
HTML
Raw Normal View History

<!doctype html>
<html>
<head>
<script src="http://oxjs.org/js/jquery-1.4.2.min.js"></script>
2010-08-03 20:49:30 +00:00
<script>
2010-08-03 20:49:30 +00:00
var ox = new OxFF();
ox.access(true);
ox.login('username');
2010-08-03 20:49:30 +00:00
//ox.get('b2c8f0aa3a447d09', 'stills', function(result) { console.log(result);});
2010-08-03 20:49:30 +00:00
//ox.files(function(result) { console.log(result);});
function update() {
var updating = true;
ox.update(function(result) {
console.log('updating done', result);
updating = false });
var getFiles = function() {
ox.volumes(function(result) {
var volumes = JSON.parse(result);
for(volume in volumes) {
(function(volume) {
var volumeId = volume.replace(/[ \/]/g, '_');
var $volume = $('#'+volumeId);
if($volume.length==0)
$volume = $('<div>').attr('id', volumeId);
$volume.html('<h1>'+volume+'</h1>');
$('#files').append($volume);
ox.files(volume, function(result) {
var files = JSON.parse(result);
$.each(files, function(folder, f) {
$file = $('<div>').html(folder);
$volume.append($file);
});
});
}(volume));
}
if(updating) {
setTimeout(getFiles, 2000);
}
});
}
getFiles();
}
2010-08-03 20:49:30 +00:00
function addVolume() {
console.log(ox.addVolume())
}
2010-08-03 20:49:30 +00:00
</script>
</head>
<body>
<input type="button" onClick="addVolume()" value="Add Volume">
<input type="button" onClick="update()" value="Update">
<div id="files">
</div>
</body>
</html>