Fix File
•
/
home
/
sportsfe...
/
httpdocs
/
wp-conte...
/
plugins
/
wp-file-...
/
lib
/
js
•
File:
elFinder.js
•
Content:
}, cache = function() { var dfd = jQuery.Deferred(), cnt = Object.keys(self.leafRoots).length; if (cnt > 0) { jQuery.each(self.leafRoots, function(hash) { checkPhash(hash).done(function() { --cnt; if (cnt < 1) { dfd.resolve(); } }); }); } else { dfd.resolve(); } return dfd; }; self.autoSync('stop'); cache().done(function() { var files = [], grps = {}, dfds = [], cache = [], singles = {}; jQuery.each(targets, function() { files.push.apply(files, getLeafRoots(self.file(this))); }); targets.push.apply(targets, files); jQuery.each(targets, function() { var root = self.root(this), file = self.file(this); if (file && (file.sizeInfo || file.mime !== 'directory')) { cache.push(jQuery.Deferred().resolve(file.sizeInfo? file.sizeInfo : {size: file.size, dirCnt: 0, fileCnt : 1})); } else { if (! grps[root]) { grps[root] = [ this.toString() ]; } else { grps[root].push(this.toString()); } } }); jQuery.each(grps, function() { var idx = dfds.length; if (this.length === 1) { singles[idx] = this[0]; } dfds.push(self.request({ data : {cmd : 'size', targets : this}, preventDefault : true })); }); reqs.push.apply(reqs, dfds); dfds.push.apply(dfds, cache); jQuery.when.apply($, dfds).fail(function() { dfrd.reject(); }).done(function() { var cache = function(h, data) { var file; if (file = self.file(h)) { file.sizeInfo = { isCache: true }; jQuery.each(['size', 'dirCnt', 'fileCnt'], function() { file.sizeInfo[this] = data[this] || 0; }); file.size = parseInt(file.sizeInfo.size); changed.push(file); } }, size = 0, fileCnt = 0, dirCnt = 0, argLen = arguments.length, cnts = [], cntsTxt = '', changed = [], i, file, data; for (i = 0; i < argLen; i++) { data = arguments[i]; file = null; if (!data.isCache) { if (singles[i] && (file = self.file(singles[i]))) { cache(singles[i], data); } else if (data.sizes && jQuery.isPlainObject(data.sizes)) { jQuery.each(data.sizes, function(h, sizeInfo) { cache(h, sizeInfo); }); } } size += parseInt(data.size); if (fileCnt !== false) { if (typeof data.fileCnt === 'undefined') { fileCnt = false; } else { fileCnt += parseInt(data.fileCnt || 0); } } if (dirCnt !== false) { if (typeof data.dirCnt === 'undefined') { dirCnt = false; } else { dirCnt += parseInt(data.dirCnt || 0); } } } changed.length && self.change({changed: changed}); if (dirCnt !== false){ cnts.push(self.i18n('folders') + ': ' + (dirCnt - (tgtlen > 1? 0 : 1))); } if (fileCnt !== false){ cnts.push(self.i18n('files') + ': ' + fileCnt); } if (cnts.length) { cntsTxt = '<br>' + cnts.join(', '); } dfrd.resolve({ size: size, fileCnt: fileCnt, dirCnt: dirCnt, formated: (size >= 0 ? self.formatSize(size) : self.i18n('unknown')) + cntsTxt }); }); self.autoSync(); }); return dfrd; }, /** * Worker Object URL for Blob URL of getWorker() */ wkObjUrl : null, /** * Gets the web worker. * * @param {Object} options The options * @return {Worker} The worker. */ getWorker : function(options){ // for to make blob URL function woker() { self.onmessage = function(e) { var d = e.data; try { self.data = d.data; if (d.scripts) { for(var i = 0; i < d.scripts.length; i++) { importScripts(d.scripts[i]); } } self.postMessage(self.res); } catch (e) { self.postMessage({error: e.toString()}); } }; } // get woker var wk; try { if (!this.wkObjUrl) { this.wkObjUrl = (window.URL || window.webkitURL).createObjectURL(new Blob( [woker.toString().replace(/\s+/g, ' ').replace(/ *([^\w]) */g, '$1').replace(/^function\b.+?\{|\}$/g, '')], { type:'text/javascript' } )); } wk = new Worker(this.wkObjUrl, options); } catch(e) { this.debug('error', e.toString()); } return wk; }, /** * Get worker absolute URL by filename * * @param {string} filename The filename * @return {<type>} The worker url. */ getWorkerUrl : function(filename) { return this.convAbsUrl(this.baseUrl + 'js/worker/' + filename); }, /** * Gets the theme object by settings of options.themes * * @param String themeid The themeid * @return Object jQuery.Deferred */ getTheme : function(themeid) { var self = this, dfd = jQuery.Deferred(), absUrl = function(url, base) { if (!base) { base = self.convAbsUrl(self.baseUrl); } if (Array.isArray(url)) { return jQuery.map(url, function(v) { return absUrl(v, base); }); } else { return url.match(/^(?:http|\/\/)/i)? url : base + url.replace(/^(?:\.\/|\/)/, ''); } }, themeObj, m; if (themeid && (themeObj = self.options.themes[themeid])) { if (typeof themeObj === 'string') { url = absUrl(themeObj); if (m = url.match(/^(.+\/)[^/]+\.json$/i)) { jQuery.getJSON(url).done(function(data) { themeObj = data; themeObj.id = themeid; if (themeObj.cssurls) { themeObj.cssurls = absUrl(themeObj.cssurls, m[1]); } dfd.resolve(themeObj); }).fail(function() { dfd.reject(); }); } else { dfd.resolve({ id: themeid, name: themeid, cssurls: [url] }); } } else if (jQuery.isPlainObject(themeObj) && themeObj.cssurls) { themeObj.id = themeid; themeObj.cssurls = absUrl(themeObj.cssurls); if (!Array.isArray(themeObj.cssurls)) { themeObj.cssurls = [themeObj.cssurls]; } if (!themeObj.name) { themeObj.name = themeid; } dfd.resolve(themeObj); } else { dfd.reject(); } } else { dfd.reject(); } return dfd; }, /** * Change current theme * * @param String themeid The themeid * @return Object this elFinder instance */ changeTheme : function(themeid) { var self = this; if (themeid) { if (self.options.themes[themeid] && (!self.theme || self.theme.id !== themeid)) { self.getTheme(themeid).done(function(themeObj) { if (themeObj.cssurls) { jQuery('head>link.elfinder-theme-ext').remove(); self.loadCss(themeObj.cssurls, { className: 'elfinder-theme-ext', dfd: jQuery.Deferred().done(function() { self.theme = themeObj; self.trigger && self.trigger('themechange'); }) }); } }); } else if (themeid === 'default' && self.theme && self.theme.id !== 'default') { jQuery('head>link.elfinder-theme-ext').remove(); self.theme = null; self.trigger && self.trigger('themechange'); } } return this; }, /** * Apply leaf root stats to target directory * * @param object dir object of target directory * @param boolean update is force update * * @return boolean dir object was chenged */ applyLeafRootStats : function(dir, update) { var self = this, prev = update? dir : (self.file(dir.hash) || dir), prevTs = prev.ts, change = false; // backup original stats if (update || !dir._realStats) { dir._realStats = { locked: dir.locked || 0, dirs: dir.dirs || 0, ts: dir.ts }; } // set lock dir.locked = 1; if (!prev.locked) { change = true; } // has leaf root to `dirs: 1` dir.dirs = 1; if (!prev.dirs) { change = true; } // set ts jQuery.each(self.leafRoots[dir.hash], function() { var f = self.file(this); if (f && f.ts && (dir.ts || 0) < f.ts) { dir.ts = f.ts; } }); if (prevTs !== dir.ts) { change = true; } return change; }, /** * To aborted XHR object * * @param Object xhr * @param Object opts * * @return void */ abortXHR : function(xhr, o) { var opts = o || {}; if (xhr) { opts.quiet && (xhr.quiet = true); if (opts.abort && xhr._requestId) { this.request({ data: { cmd: 'abort', id: xhr._requestId }, preventDefault: true }); } xhr.abort(); xhr = void 0; } }, /** * Sets the custom header by xhr response header with options.parrotHeaders * * @param Object xhr * * @return void */ setCustomHeaderByXhr : function(xhr) { var self = this; if (xhr.getResponseHeader && self.parrotHeaders && self.parrotHeaders.length) { jQuery.each(self.parrotHeaders, function(i, h) { var val = xhr.getResponseHeader(h); if (val) { self.customHeaders[h] = val; self.sessionStorage('core-ph:'+h, val); } else if (typeof val === 'string') { delete self.customHeaders[h]; self.sessionStorage('core-ph:'+h, null); } }); } }, /** * Determines if parrot headers. * * @return {boolean} True if parrot headers, False otherwise. */ hasParrotHeaders : function() { var res = false, phs = this.parrotHeaders; if (Object.keys(this.customHeaders).length) { for (var i = 0; i < phs.length; i++) { if (this.customHeaders[phs[i]]) { res = true; break; } } } return res; }, /** * Gets the request identifier * * @return String The request identifier. */ getRequestId : function() { return (+ new Date()).toString(16) + Math.floor(1000 * Math.random()).toString(16); }, /** * Flip key and value of array or object * * @param Array | Object { a: 1, b: 1, c: 2 } * @param Mixed Static value * @return Object { 1: "b", 2: "c" } */ arrayFlip : function (trans, val) { var key, tmpArr = {}, isArr = jQuery.isArray(trans); for (key in trans) { if (isArr || trans.hasOwnProperty(key)) { tmpArr[trans[key]] = val || key; } } return tmpArr; }, /** * Return array ["name without extention", "extention"] * * @param String name * * @return Array * */ splitFileExtention : function(name) { var m; if (m = name.match(/^(.+?)?\.((?:tar\.(?:gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(?:gz|bz2)|[a-z0-9]{1,10})$/i)) { if (typeof m[1] === 'undefined') { m[1] = ''; } return [m[1], m[2]]; } else { return [name, '']; } }, /** * Slice the ArrayBuffer by sliceSize * * @param arraybuffer arrayBuffer The array buffer * @param Number sliceSize The slice size * @return Array Array of sleced arraybuffer */ sliceArrayBuffer : function(arrayBuffer, sliceSize) { var segments= [], fi = 0; while(fi * sliceSize < arrayBuffer.byteLength){ segments.push(arrayBuffer.slice(fi * sliceSize, (fi + 1) * sliceSize)); fi++; } return segments; }, arrayBufferToBase64 : function(ab) { if (!window.btoa) { return ''; } var dView = new Uint8Array(ab), // Get a byte view arr = Array.prototype.slice.call(dView), // Create a normal array arr1 = arr.map(function(item) { return String.fromCharCode(item); // Convert }); return window.btoa(arr1.join('')); // Form a string }, log : function(m) { window.console && window.console.log && window.console.log(m); return this; }, debug : function(type, m) { var self = this, d = this.options.debug, tb = this.options.toastBackendWarn, tbOpts, showlog; if (type === 'backend-error') { if (! this.cwd().hash || (d && (d === 'all' || d['backend-error']))) { m = Array.isArray(m)? m : [ m ]; this.error(m); } } else if (type === 'backend-warning') { showlog = true; if (tb) { tbOpts = jQuery.isPlainObject(tb)? tb : {}; jQuery.each(Array.isArray(m)? m : [ m ], function(i, m) { self.toast(Object.assign({ mode : 'warning', msg: m }, tbOpts)); }); } } else if (type === 'backend-debug') { this.trigger('backenddebug', m); } if (showlog || (d && (d === 'all' || d[type]))) { window.console && window.console.log && window.console.log('elfinder debug: ['+type+'] ['+this.id+']', m); } return this; }, /** * Parse response.debug and trigger debug * * @param Object response The response */ responseDebug : function(response) { var rd = response.debug, d; if (rd) { // set options.debug d = this.options.debug; if (!d || d !== 'all') { if (!d) { d = this.options.debug = {}; } d['backend-error'] = true; d['warning'] = true; } if (rd.mountErrors && (typeof rd.mountErrors === 'string' || (Array.isArray(rd.mountErrors) && rd.mountErrors.length))) { this.debug('backend-error', rd.mountErrors); } if (rd.backendErrors && (typeof rd.backendErrors === 'string' || (Array.isArray(rd.backendErrors) && rd.backendErrors.length))) { this.debug('backend-warning', rd.backendErrors); } } }, time : function(l) { window.console && window.console.time && window.console.time(l); }, timeEnd : function(l) { window.console && window.console.timeEnd && window.console.timeEnd(l); } }; /** * for conpat ex. ie8... * * Object.keys() - JavaScript | MDN * https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/keys */ if (!Object.keys) { Object.keys = (function () { var hasOwnProperty = Object.prototype.hasOwnProperty, hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), dontEnums = [ 'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor' ], dontEnumsLength = dontEnums.length; return function (obj) { if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object'); var result = []; for (var prop in obj) { if (hasOwnProperty.call(obj, prop)) result.push(prop); } if (hasDontEnumBug) { for (var i=0; i < dontEnumsLength; i++) { if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]); } } return result; }; })(); } // Array.isArray if (!Array.isArray) { Array.isArray = function(arr) { return jQuery.isArray(arr); }; } // Object.assign if (!Object.assign) { Object.assign = function() { return jQuery.extend.apply(null, arguments); }; } // String.repeat if (!String.prototype.repeat) { String.prototype.repeat = function(count) { 'use strict'; if (this == null) { throw new TypeError('can\'t convert ' + this + ' to object'); } var str = '' + this; count = +count; if (count != count) { count = 0; } if (count < 0) { throw new RangeError('repeat count must be non-negative'); } if (count == Infinity) { throw new RangeError('repeat count must be less than infinity'); } count = Math.floor(count); if (str.length == 0 || count == 0) { return ''; } // Ensuring count is a 31-bit integer allows us to heavily optimize the // main part. But anyway, most current (August 2014) browsers can't handle // strings 1 << 28 chars or longer, so: if (str.length * count >= 1 << 28) { throw new RangeError('repeat count must not overflow maximum string size'); } var rpt = ''; for (var i = 0; i < count; i++) { rpt += str; } return rpt; }; } // String.trim if (!String.prototype.trim) { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; } // Array.apply (function () { try { Array.apply(null, {}); return; } catch (e) { } var toString = Object.prototype.toString, arrayType = '[object Array]', _apply = Function.prototype.apply, slice = /*@cc_on @if (@_jscript_version <= 5.8) function () { var a = [], i = this.length; while (i-- > 0) a[i] = this[i]; return a; }@else@*/Array.prototype.slice/*@end@*/; Function.prototype.apply = function apply(thisArg, argArray) { return _apply.call(this, thisArg, toString.call(argArray) === arrayType ? argArray : slice.call(argArray)); }; })(); // Array.from if (!Array.from) { Array.from = function(obj) { return obj.length === 1 ? [obj[0]] : Array.apply(null, obj); }; } // window.requestAnimationFrame and window.cancelAnimationFrame if (!window.cancelAnimationFrame) { // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel // MIT license (function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; }()); }
•
Search:
•
Replace:
1
2
Function
Edit by line
Download
Information
Rename
Copy
Move
Delete
Chmod
List