Commit ad4a0869 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Improve Replicate storage

parent eb1e3767
...@@ -13,13 +13,16 @@ ...@@ -13,13 +13,16 @@
<script type="text/javascript" src="unhosted/base64.js"></script> <script type="text/javascript" src="unhosted/base64.js"></script>
<script type="text/javascript" src="unhosted/jio.storage.js"></script> <script type="text/javascript" src="unhosted/jio.storage.js"></script>
<script type="text/javascript" > <script type="text/javascript" >
var getXML = function (lol) { $.ajax ({
var tmp = ''; url: 'responsexml/davsave',
$.ajax({url: lol,async:false, dataType: 'text',
dataType:'text',success:function(xml){tmp=xml}}); success:function () {
return tmp; console.log ('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
} }
alert(getXML('responsexml/davlist')); });
for (var i = 0; i < 300; i++) {
console.log ('a');
}
</script> </script>
</body> </body>
</html> </html>
...@@ -282,7 +282,8 @@ ...@@ -282,7 +282,8 @@
// Create a storage object and use it to save,load,...! // Create a storage object and use it to save,load,...!
var t = this; var t = this;
createStorageObject( createStorageObject(
{'storage':job.storage, {'queue':this,
'storage':job.storage,
'applicant':jioGlobalObj.applicant})[job.method]( 'applicant':jioGlobalObj.applicant})[job.method](
job,function (endedjob){ job,function (endedjob){
t.ended(endedjob); t.ended(endedjob);
......
// Adds 3 storages for Jio
// type:
// - local
// - dav
// - replicate
;(function ( Jio ) { ;(function ( Jio ) {
// check dependencies // check dependencies
...@@ -698,4 +703,52 @@ ...@@ -698,4 +703,52 @@
// end DAVStorage // end DAVStorage
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// ReplicateStorage
var ReplicateStorage = function ( options ) {
this.queue = options.queue;
this.id = null;
this.length = options.storage.list.length;
this.returnsValuesArray = [];
};
ReplicateStorage.prototype = {
checkNameAvailability: function ( job, jobendcallback ) {
var t = this;
for (var i in job.storage.list) {
var newjob = $.extend({},job);
newjob.storage = job.storage.list[i];
newjob.callback = function (result){
t.returnsValuesArray.push(result);
};
this.queue.addJob( newjob );
}
//// callback listener
this.id = setInterval(function() {
if (t.returnsValuesArray.length >= t.length) {
var res = {};
// TODO
jobendcallback(job);
job.callback(res);
clearInterval(t.id);
}
},100);
//// end call back listener
},
saveDocument: function ( job, jobendcallback ) {
},
loadDocument: function ( job, jobendcallback ) {
},
getDocumentList: function ( job, jobendcallback ) {
},
removeDocument: function ( job, jobendcallback ) {
}
};
// add key to storageObject
Jio.addStorageType('replicate', function (options) {
return new ReplicateStorage(options);
});
// end ReplicateStorage
////////////////////////////////////////////////////////////////////////////
})( JIO ); })( JIO );
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