Commit 72133321 authored by Tristan Cavelier's avatar Tristan Cavelier

example.html updated

parent 935d3e28
...@@ -21,58 +21,74 @@ var log = function (o) { ...@@ -21,58 +21,74 @@ var log = function (o) {
<script type="text/javascript" src="../src/jio.storage/localstorage.js"> <script type="text/javascript" src="../src/jio.storage/localstorage.js">
</script> </script>
<script type="text/javascript" src="../lib/jquery/jquery.min.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"> <script type="text/javascript">
<!-- <!--
var my_jio = null; var jio_instance = null;
log ('Welcome to the jIO example.html!') log('Welcome to the jIO example.html!')
log ('-> Create jIO instance'); log('-> Create jIO instance');
my_jio = jIO.newJio({ jio_instance = jIO.newJio({
type: 'local', username: 'jIOtest', applicationname: 'example' "type": 'local',
"username": 'jIOtest',
"applicationname": 'example'
}); });
// careful ! asynchronous methods // Careful! These are asynchronous methods!
log ('-> post "video" document metadata to localStorage'); 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) {
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'); jio_instance.putAttachment({
my_jio.putAttachment({id:"video/thumb.jpg", data:"BASE64DATA", mimetype:'image/jpeg'}, function (val) { "_id": "video",
"_attachment": "thumb.jpg",
"_data": "BASE64DATA",
"_mimetype": 'image/jpeg'
}, function (response) {
log ('-> put "video" attachment to localStorage'); 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.'); 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) { }, function (err) {
log ('Error! '+ err.reason); log('Error! '+ err.reason);
}); });
}, function (err) { }, function (err) {
log ('Error! ' + err.reason); log('Error! ' + err.reason);
}); });
}, function (err) { }, function (err) {
log ('Error! ' + err.reason);
log ('-> get "video" document metadata from localStorage'); log('Error! ' + err.reason);
my_jio.get('video', function (val) { log('-> get "video" document metadata from localStorage');
log ('Title is: "' + val["title"] + '"');
jio_instance.get('video', function (val) {
log('Title is: "' + val["title"] + '"');
log('-> remove "video" document from localStorage');
log ('-> remove "video" document from localStorage'); jio_instance.remove({"_id":'video'}, function (val) {
my_jio.remove({_id:'video'}, function (val) { log('Done! Refresh the page to see post and putAttachment command.');
log ('Done! Refresh the page to see post and putAttachment command.');
}, function (err) { }, function (err) {
log ('Error! ' + err.reason); log('Error! ' + err.reason);
}); });
}, function (err) { }, 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