Commit c040c3ae authored by Xiaowu Zhang's avatar Xiaowu Zhang

add audioplayer I/O gadget

parent 2f84b110
...@@ -109,10 +109,12 @@ module.exports = function (grunt) { ...@@ -109,10 +109,12 @@ module.exports = function (grunt) {
src: [ src: [
'node_modules/jio/src/sha1.amd.js', 'node_modules/jio/src/sha1.amd.js',
'node_modules/jio/src/sha2.amd.js', 'node_modules/jio/src/sha2.amd.js',
'node_modules/jio/src/sha256.amd.js', //xxx
'node_modules/jio/jio.js', 'node_modules/jio/jio.js',
'node_modules/jio/complex_queries.js', 'node_modules/jio/complex_queries.js',
'node_modules/jio/src/jio.storage/localstorage.js', 'node_modules/jio/src/jio.storage/localstorage.js',
'node_modules/jio/src/jio.storage/erp5storage.js' 'node_modules/jio/src/jio.storage/erp5storage.js',
'node_modules/jio/src/jio.storage/indexeddbstorage.js' //xxx
], ],
relative_dest: "lib/jio.js", relative_dest: "lib/jio.js",
dest: "<%= global_config.dest %>/<%= concat.jio.relative_dest %>" dest: "<%= global_config.dest %>/<%= concat.jio.relative_dest %>"
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>audioplayer io</title>
<!-- renderjs -->
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<!-- jio core dependencies -->
<script src="../<%= copy.uri.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.uritemplate.relative_dest %>" type="text/javascript"></script>
<script src="../<%= concat.jio.relative_dest %>" type="text/javascript"></script>
<!-- custom script -->
<script src="./io.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
/*global window, rJS, RSVP, jIO, JSON */
(function (window, jIO, rJS) {
"use strict";
var gk = rJS(window);
gk.declareMethod('createIO', function (description, key) {
this.jio = jIO.createJIO(description);
this.key = key;
this.jio.put({
"_id" : key
}).then(function () {
description = JSON.stringify(description, null, " ");
return ("JIO created: " + description + "\nwith key: " + key);
}).catch(function (e) {
return "jio created error: " + e.target.result;
});
})
.declareMethod('getIO', function (attachment) {
var gadget = this;
return gadget.jio.getAttachment({
"_id": gadget.key,
"_attachment": attachment
}).then(function (response) {
return response.data;
}).fail(function (response) {
return "jio getIO error : " + response.target.result;
});
})
.declareMethod('setIO', function (attachment, file) {
var gadget = this;
return gadget.jio.putAttachment({
"_id": gadget.key,
"_attachment": attachment,
"_blob": file
});
})
.declareMethod('showAllIO', function () {
var gadget = this;
return gadget.jio.allDoc({
"include_docs": "m"
});
});
}(window, jIO, rJS));
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