Commit c9faec61 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Add Improvements made in crib editor:

* crib-enable: Add Back comments on methods
* crib-enable: Add getScope to the interface
* Crib-enable: Add possible improvement in XXX
parent 025e4a14
......@@ -7,6 +7,9 @@
<h1>Crib Enable Interface</h1>
<h3>Interface Needed to edit with CribJS</h3>
<dl>
<dt>getScope</dt>
<dd>Return url in string format. get the Scope covered by the gadget</dd>
<dl></dl>
<dt>get</dt>
<dd>Return a data url. Cannot return a blob as the data is transmitted through an iFrame</dd>
<dl>
......
/*global window, rJS, jIO, FormData, navigator, RSVP */
/*global window, rJS, jIO, FormData, navigator, RSVP, URL */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, jIO) {
"use strict";
......@@ -42,6 +42,7 @@
path = path_list.join("/");
}
gadget.state_parameter_dict = {};
// XXX This should most likely be replaced by: new URL("./", window.location.href).href
gadget.state_parameter_dict.default_document = window.location.protocol +
"//" + window.location.host + path;
this.state_parameter_dict.jio_storage = jIO.createJIO({
......@@ -95,6 +96,22 @@
}
})
/*
* get the Scope covered by the gadget
*
* @return {url} Return the scope covered by this gadget
*/
.declareMethod('getScope', function () {
return this.state_parameter_dict.default_document;
})
/**
* get Return a data url. Cannot return a blob as the data
* is transmitted through an iFrame
*
* @url {string} url of the document to retrieve
* @return {data_url} Return the data url of the document
*/
.declareMethod('get', function (url) {
var storage = this.state_parameter_dict.jio_storage;
return storage.getAttachment(this.state_parameter_dict.default_document, url)
......@@ -105,6 +122,15 @@
return e.target.result;
});
})
/**
* put Return a data url. Cannot provide a blob as the data
* is transmitted through an iFrame
*
* @url {string} url of the document to update
* @parameter {data_url} data url of the document to put, it will be transformed in a blob
* @return {data_url} Return the data url of the document
*/
.declareMethod('put', function (url, data_uri) {
var storage = this.state_parameter_dict.jio_storage;
data_uri = jIO.util.dataURItoBlob(data_uri);
......@@ -114,6 +140,13 @@
data_uri
);
})
/**
* allDocs return the list of document in the cache
*
* @params {Object} Not taken into account
* @return {} Return the data url of the document
*/
.declareMethod('allDocs', function () {
var storage = this.state_parameter_dict.jio_storage;
return storage.allAttachments(this.state_parameter_dict.default_document)
......@@ -121,6 +154,13 @@
return result;
});
})
/**
* Remove an url from the cache
*
* @url {string} url of the document to remove
* @return {}
*/
.declareMethod('remove', function (url) {
var storage = this.state_parameter_dict.jio_storage;
return storage.removeAttachment(
......
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