filer/dist/filer.min.js

5 lines
120 KiB
JavaScript
Raw Normal View History

/*! filer 2014-01-14 */
2014-01-14 16:38:44 +00:00
(function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Filer||(t.Filer=e())})(this,function(){var t,e,n;(function(r){function i(t,e){return b.call(t,e)}function o(t,e){var n,r,i,o,s,a,c,u,f,l,h=e&&e.split("/"),p=m.map,d=p&&p["*"]||{};if(t&&"."===t.charAt(0))if(e){for(h=h.slice(0,h.length-1),t=h.concat(t.split("/")),u=0;t.length>u;u+=1)if(l=t[u],"."===l)t.splice(u,1),u-=1;else if(".."===l){if(1===u&&(".."===t[2]||".."===t[0]))break;u>0&&(t.splice(u-1,2),u-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((h||d)&&p){for(n=t.split("/"),u=n.length;u>0;u-=1){if(r=n.slice(0,u).join("/"),h)for(f=h.length;f>0;f-=1)if(i=p[h.slice(0,f).join("/")],i&&(i=i[r])){o=i,s=u;break}if(o)break;!a&&d&&d[r]&&(a=d[r],c=u)}!o&&a&&(o=a,s=c),o&&(n.splice(0,s,o),t=n.join("/"))}return t}function s(t,e){return function(){return p.apply(r,w.call(arguments,0).concat([t,e]))}}function a(t){return function(e){return o(e,t)}}function c(t){return function(e){y[t]=e}}function u(t){if(i(v,t)){var e=v[t];delete v[t],_[t]=!0,h.apply(r,e)}if(!i(y,t)&&!i(_,t))throw Error("No "+t);return y[t]}function f(t){var e,n=t?t.indexOf("!"):-1;return n>-1&&(e=t.substring(0,n),t=t.substring(n+1,t.length)),[e,t]}function l(t){return function(){return m&&m.config&&m.config[t]||{}}}var h,p,d,g,y={},v={},m={},_={},b=Object.prototype.hasOwnProperty,w=[].slice;d=function(t,e){var n,r=f(t),i=r[0];return t=r[1],i&&(i=o(i,e),n=u(i)),i?t=n&&n.normalize?n.normalize(t,a(e)):o(t,e):(t=o(t,e),r=f(t),i=r[0],t=r[1],i&&(n=u(i))),{f:i?i+"!"+t:t,n:t,pr:i,p:n}},g={require:function(t){return s(t)},exports:function(t){var e=y[t];return e!==void 0?e:y[t]={}},module:function(t){return{id:t,uri:"",exports:y[t],config:l(t)}}},h=function(t,e,n,o){var a,f,l,h,p,m,b=[];if(o=o||t,"function"==typeof n){for(e=!e.length&&n.length?["require","exports","module"]:e,p=0;e.length>p;p+=1)if(h=d(e[p],o),f=h.f,"require"===f)b[p]=g.require(t);else if("exports"===f)b[p]=g.exports(t),m=!0;else if("module"===f)a=b[p]=g.module(t);else if(i(y,f)||i(v,f)||i(_,f))b[p]=u(f);else{if(!h.p)throw Error(t+" missing "+f);h.p.load(h.n,s(o,!0),c(f),{}),b[p]=y[f]}l=n.apply(y[t],b),t&&(a&&a.exports!==r&&a.exports!==y[t]?y[t]=a.exports:l===r&&m||(y[t]=l))}else t&&(y[t]=n)},t=e=p=function(t,e,n,i,o){return"string"==typeof t?g[t]?g[t](e):u(d(t,e).f):(t.splice||(m=t,e.splice?(t=e,e=n,n=null):t=r),e=e||function(){},"function"==typeof n&&(n=i,i=o),i?h(r,t,e,n):setTimeout(function(){h(r,t,e,n)},4),p)},p.config=function(t){return m=t,m.deps&&p(m.deps,m.callback),p},n=function(t,e,n){e.splice||(n=e,e=[]),i(y,t)||i(v,t)||(v[t]=[t,e,n])},n.amd={jQuery:!0}})(),n("build/almond",function(){}),n("nodash",["require"],function(){function t(t,e){return p.call(t,e)}function e(t){return null==t?0:t.length===+t.length?t.length:y(t).length}function n(t){return t}function r(t,e,n){var r,i;if(null!=t)if(u&&t.forEach===u)t.forEach(e,n);else if(t.length===+t.length){for(r=0,i=t.length;i>r;r++)if(e.call(n,t[r],r,t)===g)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(e.call(n,t[o[r]],o[r],t)===g)return}}function i(t,e,i){e||(e=n);var o=!1;return null==t?o:l&&t.some===l?t.some(e,i):(r(t,function(t,n,r){return o||(o=e.call(i,t,n,r))?g:void 0}),!!o)}function o(t,e){return null==t?!1:f&&t.indexOf===f?-1!=t.indexOf(e):i(t,function(t){return t===e})}function s(t){this.value=t}function a(t){return t&&"object"==typeof t&&!Array.isArray(t)&&p.call(t,"__wrapped__")?t:new s(t)}var c=Array.prototype,u=c.forEach,f=c.indexOf,l=c.some,h=Object.prototype,p=h.hasOwnProperty,d=Object.keys,g={},y=d||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var n=[];for(var r in e)t(e,r)&&n.push(r);return n};return s.prototype.has=function(e){return t(this.value,e)},s.prototype.contains=function(t){return o(this.value,t)},s.prototype.size=function(){return e(this.value)},a}),function(t){t["encoding-indexes"]=t["encoding-indexes"]||[]}(this),n("encoding-indexes-shim",function(){}),function(t){function e(t,e,n){return t>=e&&n>=t}function n(t,e){return Math.floor(t/e)}function r(t){var e=0;this.get
return e.prototype.clear=function(t){try{var e=this.objectStore.clear();e.onsuccess=function(){t()},e.onerror=function(e){t(e)}}catch(n){t(n)}},e.prototype.get=function(t,e){try{var n=this.objectStore.get(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},e.prototype.put=function(t,e,n){try{var r=this.objectStore.put(e,t);r.onsuccess=function(t){var e=t.target.result;n(null,e)},r.onerror=function(t){n(t)}}catch(i){n(i)}},e.prototype.delete=function(t,e){try{var n=this.objectStore.delete(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},n.isSupported=function(){return!!o},n.prototype.open=function(t){var e=this;if(e.db)return t(null,!1),void 0;var n=!1,r=o.open(e.name);r.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(i)&&e.deleteObjectStore(i),e.createObjectStore(i),n=!0},r.onsuccess=function(r){e.db=r.target.result,t(null,n)},r.onerror=function(e){t(e)}},n.prototype.getReadOnlyContext=function(){return new e(this.db,a)},n.prototype.getReadWriteContext=function(){return new e(this.db,s)},n}),n("src/providers/websql",["require","src/constants","src/constants","src/constants","src/constants","src/constants"],function(t){function e(t,e){var n=this;this.getTransaction=function(r){return n.transaction?(r(n.transaction),void 0):(t[e?"readTransaction":"transaction"](function(t){n.transaction=t,r(t)}),void 0)}}function n(t){this.name=t||r,this.db=null}var r=t("src/constants").FILE_SYSTEM_NAME,i=t("src/constants").FILE_STORE_NAME,o=t("src/constants").WSQL_VERSION,s=t("src/constants").WSQL_SIZE,a=t("src/constants").WSQL_DESC;return e.prototype.clear=function(t){function e(e,n){t(n)}function n(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+i,[],n,e)})},e.prototype.get=function(t,e){function n(t,n){var r=0===n.rows.length?null:n.rows.item(0).data;e(null,r)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("SELECT data FROM "+i+" WHERE id = ?",[t],n,r)})},e.prototype.put=function(t,e,n){function r(){n(null)}function o(t,e){n(e)}this.getTransaction(function(n){n.executeSql("INSERT OR REPLACE INTO "+i+" (id, data) VALUES (?, ?)",[t,e],r,o)})},e.prototype.delete=function(t,e){function n(){e(null)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+i+" WHERE id = ?",[t],n,r)})},n.isSupported=function(){return!!window.openDatabase},n.prototype.open=function(t){function e(e,n){t(n)}function n(e){function n(e,n){var r=0===n.rows.item(0).count;t(null,r)}function o(e,n){t(n)}r.db=c,e.executeSql("SELECT COUNT(id) AS count FROM "+i+";",[],n,o)}var r=this;if(r.db)return t(null,!1),void 0;var c=window.openDatabase(r.name,o,a,s);return c?(c.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS "+i+" (id unique, data)",[],n,e)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},n.prototype.getReadOnlyContext=function(){return new e(this.db,!0)},n.prototype.getReadWriteContext=function(){return new e(this.db,!1)},n}),n("src/providers/memory",["require","src/constants"],function(t){function e(t,e){this.readOnly=e,this.objectStore=t}function n(t){this.name=t||r,this.db={}}var r=t("src/constants").FILE_SYSTEM_NAME;return e.prototype.clear=function(t){if(this.readOnly)return t("[MemoryContext] Error: write operation on read only context");var e=this.objectStore;Object.keys(e).forEach(function(t){delete e[t]}),t(null)},e.prototype.get=function(t,e){e(null,this.objectStore[t])},e.prototype.put=function(t,e,n){return this.readOnly?n("[MemoryContext] Error: write operation on read only context"):(this.objectStore[t]=e,n(null),void 0)},e.prototype.delete=function(t,e){return this.readOnly?e("[MemoryContext] Error: write operation on read only context"):(delete this.objectStore[t],e(null),void 0)},n.isSupported=function(){return!0},n.prototype.open=function(t){t(null,!0)},n.prototype.getReadOnlyContext=function(){return new e(this.db,!0)},n.prototype.getReadWriteContext=function(){return new e(this.db,!1)},n}),n("src/providers/providers",[
e[n]=1&t[r>>>5]>>>31-r%32}for(t=this._subKeys=[],r=0;16>r;r++){for(var i=t[r]=[],o=u[r],n=0;24>n;n++)i[0|n/6]|=e[(c[n]-1+o)%28]<<31-n%6,i[4+(0|n/6)]|=e[28+(c[n+24]-1+o)%28]<<31-n%6;for(i[0]=i[0]<<1|i[0]>>>31,n=1;7>n;n++)i[n]>>>=4*(n-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],n=0;16>n;n++)e[n]=t[15-n]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(n,r,i){this._lBlock=n[r],this._rBlock=n[r+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var o=0;16>o;o++){for(var s=i[o],a=this._lBlock,c=this._rBlock,u=0,h=0;8>h;h++)u|=f[h][((c^s[h])&l[h])>>>0];this._lBlock=c,this._rBlock=a^u}i=this._lBlock,this._lBlock=this._rBlock,this._rBlock=i,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),n[r]=this._lBlock,n[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});n.DES=i._createHelper(h),s=s.TripleDES=i.extend({_doReset:function(){var t=this._key.words;this._des1=h.createEncryptor(o.create(t.slice(0,2))),this._des2=h.createEncryptor(o.create(t.slice(2,4))),this._des3=h.createEncryptor(o.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),n.TripleDES=i._createHelper(s)}(),n("crypto-js/rollups/tripledes",function(){});var r=r||function(t,e){var n={},r=n.lib={},i=r.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var n=new t;return e&&n.mixIn(e),n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.$super.extend(this)}}}(),o=r.WordArray=i.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:4*t.length},toString:function(t){return(t||a).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,t=t.sigBytes;if(this.clamp(),r%4)for(var i=0;t>i;i++)e[r+i>>>2]|=(255&n[i>>>2]>>>24-8*(i%4))<<24-8*((r+i)%4);else if(n.length>65535)for(i=0;t>i;i+=4)e[r+i>>>2]=n[i>>>2];else e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-8*(n%4),e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;e>r;r+=4)n.push(0|4294967296*t.random());return o.create(n,e)}}),s=n.enc={},a=s.Hex={stringify:function(t){for(var e=t.words,t=t.sigBytes,n=[],r=0;t>r;r++){var i=255&e[r>>>2]>>>24-8*(r%4);n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;e>r;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-4*(r%8);return o.create(n,e/2)}},c=s.Latin1={stringify:function(t){for(var e=t.words,t=t.sigBytes,n=[],r=0;t>r;r++)n.push(String.fromCharCode(255&e[r>>>2]>>>24-8*(r%4)));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;e>r;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-8*(r%4);return o.create(n,e)}},u=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},f=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=o.create(),this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=u.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,s=this.blockSize,a=i/(4*s),a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0),e=a*s,i=t.min(4*e,i);if(e){for(var c=0;e>c;c+=s)this._doProcessBlock(r,c);c=r.splice(0,e),n.sigBytes-=i}return o.create(c,i)},clone:function(){var t=i.clone.call(th
},e("Zlib.Inflate",v),e("Zlib.Inflate.prototype.decompress",v.prototype.p),_("Zlib.Inflate.BufferType",{ADAPTIVE:N.C,BLOCK:N.D}),e("Zlib.Deflate",m),e("Zlib.Deflate.compress",function(t,e){return new m(t,e).j()}),e("Zlib.Deflate.prototype.compress",m.prototype.j),_("Zlib.Deflate.CompressionType",{NONE:ie.NONE,FIXED:ie.r,DYNAMIC:ie.k})}.call(this),n("zlib",function(){}),n("src/adapters/zlib",["require","zlib"],function(t){function e(t){return new o(t).decompress()}function n(t){return new s(t).compress()}function r(t){this.context=t}function i(t){this.provider=t}t("zlib");var o=Zlib.Inflate,s=Zlib.Deflate;return r.prototype.clear=function(t){this.context.clear(t)},r.prototype.get=function(t,n){this.context.get(t,function(t,r){return t?(n(t),void 0):(r&&(r=e(r)),n(null,r),void 0)})},r.prototype.put=function(t,e,r){e=n(e),this.context.put(t,e,r)},r.prototype.delete=function(t,e){this.context.delete(t,e)},i.isSupported=function(){return!0},i.prototype.open=function(t){this.provider.open(t)},i.prototype.getReadOnlyContext=function(){return new r(this.provider.getReadOnlyContext())},i.prototype.getReadWriteContext=function(){return new r(this.provider.getReadWriteContext())},i}),n("src/adapters/adapters",["require","src/adapters/crypto","src/adapters/zlib"],function(t){var e=t("src/adapters/crypto"),n=t("src/adapters/zlib");return{AES:e.AES,TripleDES:e.TripleDES,Rabbit:e.Rabbit,Zlib:n,Compression:n,Encryption:e.AES}}),n("src/fs",["require","nodash","encoding","src/path","src/path","src/path","src/shared","src/shared","src/shared","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/error","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/constants","src/providers/providers","src/adapters/adapters"],function(t){function e(t,e){this.id=t,this.type=e||Ce}function n(t,e,n){this.id=t,this.flags=e,this.position=n}function r(t,e,n){var r=Date.now();this.id=Te,this.mode=Me,this.atime=t||r,this.ctime=e||r,this.mtime=n||r,this.rnode=de()}function i(t,e,n,r,i,o,s,a,c,u){var f=Date.now();this.id=t||de(),this.mode=e||Ce,this.size=n||0,this.atime=r||f,this.ctime=i||f,this.mtime=o||f,this.flags=s||[],this.xattrs=a||{},this.nlinks=c||0,this.version=u||0,this.blksize=void 0,this.nblocks=1,this.data=de()}function o(t,e){this.node=t.id,this.dev=e,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}function s(t,e,n){function r(e,r){e?n(e):r&&r.mode===Me&&r.rnode?t.get(r.rnode,i):n(new Ae("missing super node"))}function i(t,e){t?n(t):e?n(null,e):n(new me("path does not exist"))}function o(e,r){e?n(e):r.mode===De&&r.data?t.get(r.data,a):n(new we("a component of the path prefix is not a directory"))}function a(e,r){if(e)n(e);else if(fe(r).has(f)){var i=r[f].id;t.get(i,c)}else n(new me("path does not exist"))}function c(t,e){t?n(t):e.mode==ze?(h++,h>Fe?n(new Se("too many symbolic links were encountered")):u(e.data)):n(null,e)}function u(e){e=le(e),l=he(e),f=pe(e),Ie==f?t.get(Te,r):s(t,l,o)}if(e=le(e),!e)return n(new me("path is an empty string"));var f=pe(e),l=he(e),h=0;Ie==f?t.get(Te,r):s(t,l,o)}function a(t,e,n,r,i,o){function a(e,s){s?s.xattrs[n]:null,e?o(e):i===Ke&&s.xattrs.hasOwnProperty(n)?o(new ye("attribute already exists")):i!==Ye||s.xattrs.hasOwnProperty(n)?(s.xattrs[n]=r,t.put(s.id,s,o)):o(new Be("attribute does not exist"))}"string"==typeof e?s(t,e,a):"object"==typeof e&&"string"==typeof e.id?t.get(e.id,a):o(new Ee("path or file descriptor of wrong type"))}function c(t,e){function n(n,i){!n&&i?e(new ye):n&&!n instanceof me?e(n):(a=new r,t.put(a.id,a,o))}function o(n){n?e(n):(c=new i(a.rnode,De),c.nlinks+=1,t.put(c.id,c,s))}function s(n){n?e(n):(u={},t.put(c.data,u,e))}var a,c,u;t.get(Te,n)}function u(t,