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

lib jio generated by grunt

parent 79ac23a6
/*! JIO - v0.1.0 - 2012-05-15
/*! JIO - v0.1.0 - 2012-05-16
* Copyright (c) 2012 Nexedi; Licensed */
......
This diff is collapsed.
/*! JIO Storage - v0.1.0 - 2012-05-15
/*! JIO Storage - v0.1.0 - 2012-05-16
* Copyright (c) 2012 Nexedi; Licensed */
......
/*! JIO Storage - v0.1.0 - 2012-05-15
/*! JIO Storage - v0.1.0 - 2012-05-16
* Copyright (c) 2012 Nexedi; Licensed */
(function(){var a=function(a,b,c,d){var e=function(){var a=!0,c=function(b){console.error("Fail to load "+b),a=!1};try{b||c("Base64")}catch(d){c("Base64")}return a},f,g,h;f=function(b){var e=c.newBaseStorage(b),f={};return e.checkNameAvailability=function(){setTimeout(function(){var b=null;b=a.getAll();for(var c in b){var d=c.split("/");if(d[0]==="jio"&&d[1]==="local"&&d[2]===e.getUserName())return e.done(!1)}return e.done(!0)},100)},e.saveDocument=function(){setTimeout(function(){var b=null;return b=a.getItem("jio/local/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName()),b?(b.lastModified=Date.now(),b.fileContent=e.getFileContent()):b={fileName:e.getFileName(),fileContent:e.getFileContent(),creationDate:Date.now(),lastModified:Date.now()},a.setItem("jio/local/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName(),b),e.done()},100)},e.loadDocument=function(){setTimeout(function(){var b=null,c=d.extend({getContent:!0},e.cloneOptionObject());b=a.getItem("jio/local/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName()),b?(c.getContent||delete b.fileContent,e.done(b)):e.fail("Document not found.",404)},100)},e.getDocumentList=function(){setTimeout(function(){var b=[],c=null,d="key",f=["splitedkey"],g={};c=a.getAll();for(d in c)f=d.split("/"),f[0]==="jio"&&f[1]==="local"&&f[2]===e.getStorageUserName()&&f[3]===e.getApplicantID()&&(g=JSON.parse(c[d]),b.push({fileName:g.fileName,creationDate:g.creationDate,lastModified:g.lastModified}));e.done(b)},100)},e.removeDocument=function(){setTimeout(function(){return a.deleteItem("jio/local/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName()),e.done()},100)},e},g=function(a){var e=c.newBaseStorage(a);return e.mkcol=function(a){var c=d.extend({success:function(){},error:function(){}},a),f=["splitedpath"],g="temp/path";if(!c.pathsteps)c.pathsteps=1,e.mkcol(c);else{f=c.path.split("/");if(c.pathsteps>=f.length-1)return c.success();f.length=c.pathsteps+1,c.pathsteps++,g=f.join("/"),d.ajax({url:c.location+g,type:"MKCOL",async:!0,headers:{Authorization:"Basic "+b.encode(c.userName+":"+c.password),Depth:"1"},success:function(){e.mkcol(c)},error:function(a){c.error()}})}},e.checkNameAvailability=function(){d.ajax({url:e.getStorageLocation()+"/dav/"+e.getStorageUserName()+"/",async:!0,type:"PROPFIND",dataType:"xml",headers:{Authorization:"Basic "+b.encode(e.getStorageUserName()+":"+e.getStoragePassword()),Depth:"1"},success:function(a){e.done(!1)},error:function(a){a.status===404?e.done(!0):e.fail("Cannot check if "+e.getUserName()+" is available.",a.status)}})},e.saveDocument=function(){d.ajax({url:e.getStorageLocation()+"/dav/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName(),type:"PUT",data:e.getFileContent(),async:!0,dataType:"text",headers:{Authorization:"Basic "+b.encode(e.getStorageUserName()+":"+e.getStoragePassword())},success:function(){e.done()},error:function(a){e.fail("Cannot save document.",a.status)}})},e.loadDocument=function(){var a={},c=d.extend({getContent:!0},e.cloneOptionObject()),f=function(){d.ajax({url:e.getStorageLocation()+"/dav/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName(),type:"GET",async:!0,dataType:"text",headers:{Authorization:"Basic "+b.encode(e.getStorageUserName()+":"+e.getStoragePassword())},success:function(b){a.fileContent=b,e.done(a)},error:function(a){var b;a.status===404?b="Document not found.":b='Cannot load "'+e.getFileName()+'".',e.fail(b,a.status)}})};d.ajax({url:e.getStorageLocation()+"/dav/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName(),type:"PROPFIND",async:!0,dataType:"xml",headers:{Authorization:"Basic "+b.encode(e.getStorageUserName()+":"+e.getStoragePassword())},success:function(b){d(b).find("lp1\\:getlastmodified, getlastmodified").each(function(){a.lastModified=d(this).text()}),d(b).find("lp1\\:creationdate, creationdate").each(function(){a.creationDate=d(this).text()}),a.fileName=e.getFileName(),c.getContent?f():e.done(a)},error:function(a){e.fail("Cannot get document informations.",a.status)}})},e.getDocumentList=function(){var a=[],c={},f=[];d.ajax({url:e.getStorageLocation()+"/dav/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/",async:!0,type:"PROPFIND",dataType:"xml",headers:{Authorization:"Basic "+b.encode(e.getStorageUserName()+":"+e.getStoragePassword()),Depth:"1"},success:function(b){d(b).find("D\\:response, response").each(function(b,e){if(b>0){c={},d(e).find("D\\:href, href").each(function(){f=d(this).text().split("/"),c.fileName=f[f.length-1]?f[f.length-1]:f[f.length-2]+"/"});if(c.fileName===".htaccess"||c.fileName===".htpasswd")return;d(e).find("lp1\\:getlastmodified, getlastmodified").each(function(){c.lastModified=d(this).text()}),d(e).find("lp1\\:creationdate, creationdate").each(function(){c.creationDate=d(this).text()}),a.push(c)}}),e.done(a)},error:function(a){e.fail("Cannot get list.",a.status)}})},e.removeDocument=function(){d.ajax({url:e.getStorageLocation()+"/dav/"+e.getStorageUserName()+"/"+e.getApplicantID()+"/"+e.getFileName(),type:"DELETE",async:!0,headers:{Authorization:"Basic "+b.encode(e.getStorageUserName()+":"+e.getStoragePassword())},success:function(){e.done()},error:function(a){a.status===404?e.done():e.fail('Cannot remove "'+e.getFileName()+'".',a.status)}})},e},h=function(a){var b=c.newBaseStorage(a),e={};return e.storageArray=b.getStorageArray(),e.length=e.storageArray.length,e.returnsValuesArray=[],e.maxtries=b.getMaxTries(),b.setMaxTries(1),b.checkNameAvailability=function(){var a={},c=!0,d="id",f={status:"done"},g=function(a){e.returnsValuesArray.push(a),a.status==="fail"&&(f.status="fail"),a.isAvailable||(c=!1),e.returnsValuesArray.length===e.length&&b.done(c)};for(d in e.storageArray)a=b.cloneJob(),a.maxtries=e.maxtries,a.storage=e.storageArray[d],a.callback=g,b.addJob(a)},b.saveDocument=function(){var a={},c={status:"done"},d="id",f=function(a){e.returnsValuesArray.push(a),a.status==="fail"&&(c.status="fail"),e.returnsValuesArray.length===e.length&&(c.status==="fail"?b.fail("Unable to save all files.",0):b.done())};for(d in e.storageArray)a=b.cloneJob(),a.maxtries=e.maxtries,a.storage=e.storageArray[d],a.callback=f,b.addJob(a)},b.loadDocument=function(){var a={},c=!1,f={},g="id",h={status:"done"},i=function(a){e.returnsValuesArray.push(a),a.status==="fail"?h.status="fail":!f.fileContent&&!f.creationDate&&!f.lastModified?f=d.extend({},a.document):(f.fileContent!==a.document.fileContent&&(c=!0),f.creationDate>a.document.creationDate&&(f.creationDate=a.document.creationDate),f.lastModified<a.document.lastModified&&(f.fileContent=a.document.fileContent,f.lastModified=a.document.lastModified)),e.returnsValuesArray.length===e.length&&(h.status==="fail"?b.fail("Unable to load all files.",0):c?b.done(f):b.done(f))};for(g in e.storageArray)a=b.cloneJob(),a.maxtries=e.maxtries,a.storage=e.storageArray[g],a.callback=i,b.addJob(a)},b.getDocumentList=function(){var a={},c={status:"done"},d="id",f=function(a){e.returnsValuesArray.push(a),a.status==="fail"&&(c.status="fail"),e.returnsValuesArray.length===e.length&&(c.status==="fail"?b.fail("Unable retrieve all lists.",0):b.done(a.list))};for(d in e.storageArray)a=b.cloneJob(),a.maxtries=e.maxtries,a.storage=e.storageArray[d],a.callback=f,b.addJob(a)},b.removeDocument=function(){var a={},c={status:"done"},d="key",f=function(a){e.returnsValuesArray.push(a),a.status==="fail"&&(c.status="fail"),e.returnsValuesArray.length===e.length&&(c.status==="fail"?b.fail("Unable remove all files.",0):b.done())};for(d in e.storageArray)a=b.cloneJob(),a.maxtries=e.maxtries,a.storage=e.storageArray[d],a.callback=f,b.addJob(a)},b},c.addStorageType("local",function(a){return new f(a)}),c.addStorageType("dav",function(a){return new g(a)}),c.addStorageType("replicate",function(a){return new h(a)})};window.requirejs?define("JIOStorages",["LocalOrCookieStorage","Base64","JIO","jQuery"],a):a(LocalOrCookieStorage,Base64,JIO,jQuery)})();
\ No newline at end of file
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-15
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-16
* Copyright (c) 2012 Nexedi; Licensed */
var LocalOrCookieStorage =
......
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-15
/*! Local Or Cookie Storage - v0.1.0 - 2012-05-16
* Copyright (c) 2012 Nexedi; Licensed */
var LocalOrCookieStorage=function(){var a=function(){var a=function(){};a.prototype={getItem:function(a){return JSON.parse(localStorage.getItem(a))},setItem:function(a,b){if(a)return localStorage.setItem(a,JSON.stringify(b))},getAll:function(){return localStorage},deleteItem:function(a){a&&delete localStorage[a]}};var b=function(){};b.prototype={getItem:function(a){var b=document.cookie.split(";");for(var c in b){var d=b[c].substr(0,b[c].indexOf("=")),e=b[c].substr(b[c].indexOf("=")+1);d=d.replace(/^\s+|\s+$/g,"");if(d===a)return unescape(e)}return null},setItem:function(a,b){return b!==undefined?(document.cookie=a+"="+JSON.stringify(b)+";domain="+window.location.hostname+";path="+window.location.pathname,!0):!1},getAll:function(){var a={},b=document.cookie.split(":");for(var c in b){var d=b[c].substr(0,b[c].indexOf("=")),e=b[c].substr(b[c].indexOf("=")+1);d=d.replace(/^\s+|\s+$/g,""),a[d]=unescape(e)}return a},deleteItem:function(a){document.cookie=a+"=null;domain="+window.location.hostname+";path="+window.location.pathname+";expires=Thu, 01-Jan-1970 00:00:01 GMT"}};try{return localStorage.getItem?new a:new b}catch(c){return new b}};return window.requirejs?(define("LocalOrCookieStorage",[],a),undefined):a()}();
\ No newline at end of file
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