Commit dba374fb authored by Tristan Cavelier's avatar Tristan Cavelier

example.html updated

parent 3701d2c6
...@@ -16,11 +16,10 @@ var log = function (o) { ...@@ -16,11 +16,10 @@ var log = function (o) {
</script> </script>
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript" src="../lib/md5/md5.js"></script> <script src="../src/sha256.amd.js"></script>
<script type="text/javascript" src="../jio.js"></script> <script src="../jio.js"></script>
<script type="text/javascript" src="../src/jio.storage/localstorage.js"> <script src="../complex_queries.js"></script>
</script> <script src="../src/jio.storage/localstorage.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
var jio_instance = null; var jio_instance = null;
...@@ -28,7 +27,7 @@ var jio_instance = null; ...@@ -28,7 +27,7 @@ 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');
jio_instance = jIO.newJio({ jio_instance = jIO.createJIO({
"type": 'local', "type": 'local',
"username": 'jIOtest', "username": 'jIOtest',
"applicationname": 'example' "applicationname": 'example'
...@@ -43,52 +42,67 @@ jio_instance.post({ ...@@ -43,52 +42,67 @@ jio_instance.post({
"codec": 'vorbis', "codec": 'vorbis',
"language": 'en', "language": 'en',
"description": 'Image compilation' "description": 'Image compilation'
}, function (response) { }).then(function () {
log('-> put "thumbnail" attachment to localStorage'); log('-> put "thumbnail" attachment to localStorage');
jio_instance.putAttachment({ return jio_instance.putAttachment({
"_id": "video", "_id": "video",
"_attachment": "thumb.jpg", "_attachment": "thumb.jpg",
"_data": "BASE64DATA", "_data": "This is the thumbnail content",
"_mimetype": 'image/jpeg' "_mimetype": 'image/jpeg'
}, function (response) { });
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);
});
}, function (err) { }).then(function () {
log('Error! ' + err.reason);
log('-> put "video" attachment to localStorage');
return jio_instance.putAttachment({
"_id":"video",
"_attachment": "myvideo.ogg",
"_data": new Blob(["This is the video content"], {"type": "video/ogg"})
}); });
}).then(function (response) {
log('Done! Refresh the page to see get and remove command.');
}, function (err) { }, function (err) {
log('Error! ' + err.reason); log('Error! ' + err.statusText + ": " + err.reason + ", " + err.message);
log('-> get "video" document metadata from localStorage'); log('-> get "video" document metadata from localStorage');
jio_instance.get('video', function (val) { jio_instance.get({
"_id": "video"
}).then(function (response) {
log('Title is: "' + val["title"] + '"'); log('Title is: "' + response.data.title + '"');
log('-> remove "video" document from localStorage'); log('-> get "video" attachment content');
jio_instance.remove({"_id":'video'}, function (val) { return jio_instance.getAttachment({
log('Done! Refresh the page to see post and putAttachment command.'); "_id": "video",
}, function (err) { "_attachment": "myvideo.ogg"
log('Error! ' + err.reason);
}); });
}).then(function (response) {
return jIO.util.blobAsBinaryString(response.data);
}).then(function (binary_string) {
log('Video content is: ' + binary_string);
log('-> remove "video" document from localStorage');
return jio_instance.remove({"_id":'video'});
}).then(function (response) {
log('Done! Refresh the page to see post and putAttachment command.');
}, function (err) { }, function (err) {
log('Error! ' + err.reason);
log('Error! ' + err.statusText + ": " + err.reason + ", " + err.message);
}); });
}); });
......
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