Commit 72133321 authored by Tristan Cavelier's avatar Tristan Cavelier

example.html updated

parent 935d3e28
......@@ -21,58 +21,74 @@ var log = function (o) {
<script type="text/javascript" src="../src/jio.storage/localstorage.js">
</script>
<script type="text/javascript" src="../lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../lib/base64/base64.js"></script>
<script type="text/javascript" src="../src/jio.storage/davstorage.js">
</script>
<script type="text/javascript" src="../lib/jsSha2/sha2.js"></script>
<script type="text/javascript" src="../src/jio.storage/revisionstorage.js">
</script>
<script type="text/javascript" src="../lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript">
<!--
var my_jio = null;
var jio_instance = null;
log ('Welcome to the jIO example.html!')
log ('-> Create jIO instance');
log('Welcome to the jIO example.html!')
log('-> Create jIO instance');
my_jio = jIO.newJio({
type: 'local', username: 'jIOtest', applicationname: 'example'
jio_instance = jIO.newJio({
"type": 'local',
"username": 'jIOtest',
"applicationname": 'example'
});
// careful ! asynchronous methods
log ('-> post "video" document metadata to localStorage');
my_jio.post({_id:'video', title:'My Video Title', codec:'vorbis', language:'en', description: 'Image compilation'}, function (val) {
// Careful! These are asynchronous methods!
log('-> post "video" document metadata to localStorage');
jio_instance.post({
"_id": 'video',
"title": 'My Video Title',
"codec": 'vorbis',
"language": 'en',
"description": 'Image compilation'
}, function (response) {
log('-> put "thumbnail" attachment to localStorage');
log ('-> put "thumbnail" attachment to localStorage');
my_jio.putAttachment({id:"video/thumb.jpg", data:"BASE64DATA", mimetype:'image/jpeg'}, function (val) {
jio_instance.putAttachment({
"_id": "video",
"_attachment": "thumb.jpg",
"_data": "BASE64DATA",
"_mimetype": 'image/jpeg'
}, function (response) {
log ('-> put "video" attachment to localStorage');
my_jio.putAttachment({id:"video/myvideo.ogg", data:"BASE64DATATOO", mimetype:'video/ogg'}, function (val) {
log ('Done! Refresh the page to see get and remove command.');
log('-> put "video" attachment to localStorage');
jio_instance.putAttachment({
"_id":"video",
"_attachment": "myvideo.ogg",
"_data": "BASE64DATATOO",
"_mimetype":'video/ogg'
}, function (val) {
log('Done! Refresh the page to see get and remove command.');
}, function (err) {
log ('Error! '+ err.reason);
log('Error! '+ err.reason);
});
}, function (err) {
log ('Error! ' + err.reason);
log('Error! ' + err.reason);
});
}, function (err) {
log ('Error! ' + err.reason);
log ('-> get "video" document metadata from localStorage');
my_jio.get('video', function (val) {
log ('Title is: "' + val["title"] + '"');
log('Error! ' + err.reason);
log('-> get "video" document metadata from localStorage');
jio_instance.get('video', function (val) {
log('Title is: "' + val["title"] + '"');
log('-> remove "video" document from localStorage');
log ('-> remove "video" document from localStorage');
my_jio.remove({_id:'video'}, function (val) {
log ('Done! Refresh the page to see post and putAttachment command.');
jio_instance.remove({"_id":'video'}, function (val) {
log('Done! Refresh the page to see post and putAttachment command.');
}, function (err) {
log ('Error! ' + err.reason);
log('Error! ' + err.reason);
});
}, function (err) {
log ('Error! ' + err.reason);
log('Error! ' + err.reason);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment