1
0
mirror of https://github.com/IceWhaleTech/CasaOS.git synced 2025-07-06 23:37:26 +02:00
Files
CasaOS/web/js/5.js

21 lines
47 KiB
JavaScript
Raw Normal View History

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[5],{"./node_modules/simple-uploader.js/src/chunk.js":
/*!******************************************************!*\
!*** ./node_modules/simple-uploader.js/src/chunk.js ***!
\******************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval("var utils = __webpack_require__(/*! ./utils */ \"./node_modules/simple-uploader.js/src/utils.js\")\n\nfunction Chunk (uploader, file, offset) {\n utils.defineNonEnumerable(this, 'uploader', uploader)\n utils.defineNonEnumerable(this, 'file', file)\n utils.defineNonEnumerable(this, 'bytes', null)\n this.offset = offset\n this.tested = false\n this.retries = 0\n this.pendingRetry = false\n this.preprocessState = 0\n this.readState = 0\n this.loaded = 0\n this.total = 0\n this.chunkSize = this.uploader.opts.chunkSize\n this.startByte = this.offset * this.chunkSize\n this.endByte = this.computeEndByte()\n this.xhr = null\n}\n\nvar STATUS = Chunk.STATUS = {\n PENDING: 'pending',\n UPLOADING: 'uploading',\n READING: 'reading',\n SUCCESS: 'success',\n ERROR: 'error',\n COMPLETE: 'complete',\n PROGRESS: 'progress',\n RETRY: 'retry'\n}\n\nutils.extend(Chunk.prototype, {\n\n _event: function (evt, args) {\n args = utils.toArray(arguments)\n args.unshift(this)\n this.file._chunkEvent.apply(this.file, args)\n },\n\n computeEndByte: function () {\n var endByte = Math.min(this.file.size, (this.offset + 1) * this.chunkSize)\n if (this.file.size - endByte < this.chunkSize && !this.uploader.opts.forceChunkSize) {\n // The last chunk will be bigger than the chunk size,\n // but less than 2 * this.chunkSize\n endByte = this.file.size\n }\n return endByte\n },\n\n getParams: function () {\n return {\n chunkNumber: this.offset + 1,\n chunkSize: this.uploader.opts.chunkSize,\n currentChunkSize: this.endByte - this.startByte,\n totalSize: this.file.size,\n identifier: this.file.uniqueIdentifier,\n filename: this.file.name,\n relativePath: this.file.relativePath,\n totalChunks: this.file.chunks.length\n }\n },\n\n getTarget: function (target, params) {\n if (!params.length) {\n return target\n }\n if (target.indexOf('?') < 0) {\n target += '?'\n } else {\n target += '&'\n }\n return target + params.join('&')\n },\n\n test: function () {\n this.xhr = new XMLHttpRequest()\n this.xhr.addEventListener('load', testHandler, false)\n this.xhr.addEventListener('error', testHandler, false)\n var testMethod = utils.evalOpts(this.uploader.opts.testMethod, this.file, this)\n var data = this.prepareXhrRequest(testMethod, true)\n this.xhr.send(data)\n\n var $ = this\n function testHandler (event) {\n var status = $.status(true)\n if (status === STATUS.ERROR) {\n $._event(status, $.message())\n $.uploader.uploadNextChunk()\n } else if (status === STATUS.SUCCESS) {\n $._event(status, $.message())\n $.tested = true\n } else if (!$.file.paused) {\n // Error might be caused by file pause method\n // Chunks does not exist on the server side\n $.tested = true\n $.send()\n }\n }\n },\n\n preprocessFinished: function () {\n // Compute the endByte after the preprocess function to allow an\n // implementer of preprocess to set the fileObj size\n this.endByte = this.computeEndByte()\n this.preprocessState = 2\n this.send()\n },\n\n readFinished: function (bytes) {\n this.readState = 2\n this.bytes = bytes\n this.send()\n },\n\n send: function () {\n var preprocess = this.uploader.opts.preprocess\n var read = this.uploader.opts.readFileFn\n if (utils.isFunction(preprocess)) {\n switch (this.preprocessState) {\n case 0:\n this.preprocessState = 1\n preprocess(this)\n return\n case 1:\n return\n }\n }\n switch (this.readState) {\n case 0:\n this.readState = 1\n read(this.file, this.file.fileType, this.startByte, this.endByte, this)\n return\n case 1:\n return\n }\n if (this.uploader.opts.testChunks && !this.tested) {\n this.test()\n return\n }\n\n this.loaded = 0\n this.total =
/*!******************************************************!*\
!*** ./node_modules/simple-uploader.js/src/event.js ***!
\******************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval('var each = __webpack_require__(/*! ./utils */ "./node_modules/simple-uploader.js/src/utils.js").each\n\nvar event = {\n\n _eventData: null,\n\n on: function (name, func) {\n if (!this._eventData) this._eventData = {}\n if (!this._eventData[name]) this._eventData[name] = []\n var listened = false\n each(this._eventData[name], function (fuc) {\n if (fuc === func) {\n listened = true\n return false\n }\n })\n if (!listened) {\n this._eventData[name].push(func)\n }\n },\n\n off: function (name, func) {\n if (!this._eventData) this._eventData = {}\n if (!this._eventData[name] || !this._eventData[name].length) return\n if (func) {\n each(this._eventData[name], function (fuc, i) {\n if (fuc === func) {\n this._eventData[name].splice(i, 1)\n return false\n }\n }, this)\n } else {\n this._eventData[name] = []\n }\n },\n\n trigger: function (name) {\n if (!this._eventData) this._eventData = {}\n if (!this._eventData[name]) return true\n var args = this._eventData[name].slice.call(arguments, 1)\n var preventDefault = false\n each(this._eventData[name], function (fuc) {\n preventDefault = fuc.apply(this, args) === false || preventDefault\n }, this)\n return !preventDefault\n }\n}\n\nmodule.exports = event\n\n\n//# sourceURL=webpack:///./node_modules/simple-uploader.js/src/event.js?')},"./node_modules/simple-uploader.js/src/file.js":
/*!*****************************************************!*\
!*** ./node_modules/simple-uploader.js/src/file.js ***!
\*****************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval("var utils = __webpack_require__(/*! ./utils */ \"./node_modules/simple-uploader.js/src/utils.js\")\nvar Chunk = __webpack_require__(/*! ./chunk */ \"./node_modules/simple-uploader.js/src/chunk.js\")\n\nfunction File (uploader, file, parent) {\n utils.defineNonEnumerable(this, 'uploader', uploader)\n this.isRoot = this.isFolder = uploader === this\n utils.defineNonEnumerable(this, 'parent', parent || null)\n utils.defineNonEnumerable(this, 'files', [])\n utils.defineNonEnumerable(this, 'fileList', [])\n utils.defineNonEnumerable(this, 'chunks', [])\n utils.defineNonEnumerable(this, '_errorFiles', [])\n utils.defineNonEnumerable(this, 'file', null)\n this.id = utils.uid()\n\n if (this.isRoot || !file) {\n this.file = null\n } else {\n if (utils.isString(file)) {\n // folder\n this.isFolder = true\n this.file = null\n this.path = file\n if (this.parent.path) {\n file = file.substr(this.parent.path.length)\n }\n this.name = file.charAt(file.length - 1) === '/' ? file.substr(0, file.length - 1) : file\n } else {\n this.file = file\n this.fileType = this.file.type\n this.name = file.fileName || file.name\n this.size = file.size\n this.relativePath = file.relativePath || file.webkitRelativePath || this.name\n this._parseFile()\n }\n }\n\n this.paused = uploader.opts.initialPaused\n this.error = false\n this.allError = false\n this.aborted = false\n this.completed = false\n this.averageSpeed = 0\n this.currentSpeed = 0\n this._lastProgressCallback = Date.now()\n this._prevUploadedSize = 0\n this._prevProgress = 0\n\n this.bootstrap()\n}\n\nutils.extend(File.prototype, {\n\n _parseFile: function () {\n var ppaths = parsePaths(this.relativePath)\n if (ppaths.length) {\n var filePaths = this.uploader.filePaths\n utils.each(ppaths, function (path, i) {\n var folderFile = filePaths[path]\n if (!folderFile) {\n folderFile = new File(this.uploader, path, this.parent)\n filePaths[path] = folderFile\n this._updateParentFileList(folderFile)\n }\n this.parent = folderFile\n folderFile.files.push(this)\n if (!ppaths[i + 1]) {\n folderFile.fileList.push(this)\n }\n }, this)\n } else {\n this._updateParentFileList()\n }\n },\n\n _updateParentFileList: function (file) {\n if (!file) {\n file = this\n }\n var p = this.parent\n if (p) {\n p.fileList.push(file)\n }\n },\n\n _eachAccess: function (eachFn, fileFn) {\n if (this.isFolder) {\n utils.each(this.files, function (f, i) {\n return eachFn.call(this, f, i)\n }, this)\n return\n }\n fileFn.call(this, this)\n },\n\n bootstrap: function () {\n if (this.isFolder) return\n var opts = this.uploader.opts\n if (utils.isFunction(opts.initFileFn)) {\n opts.initFileFn.call(this, this)\n }\n\n this.abort(true)\n this._resetError()\n // Rebuild stack of chunks from file\n this._prevProgress = 0\n var round = opts.forceChunkSize ? Math.ceil : Math.floor\n var chunks = Math.max(round(this.size / opts.chunkSize), 1)\n for (var offset = 0; offset < chunks; offset++) {\n this.chunks.push(new Chunk(this.uploader, this, offset))\n }\n },\n\n _measureSpeed: function () {\n var smoothingFactor = this.uploader.opts.speedSmoothingFactor\n var timeSpan = Date.now() - this._lastProgressCallback\n if (!timeSpan) {\n return\n }\n var uploaded = this.sizeUploaded()\n // Prevent negative upload speed after file upload resume\n this.currentSpeed = Math.max((uploaded - this._prevUploadedSize) / timeSpan * 1000, 0)\n this.averageSpeed = smoothingFactor * this.currentSpeed + (1 - smoothingFactor) * this.averageSpeed\n this._prevUploadedSize = uploaded\n if (this.parent && this.parent._checkProgress()) {\n this.parent._measureSpeed()\n }\n },\n\n _checkProgress: function (
/*!*********************************************************!*\
!*** ./node_modules/simple-uploader.js/src/uploader.js ***!
\*********************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval("var utils = __webpack_require__(/*! ./utils */ \"./node_modules/simple-uploader.js/src/utils.js\")\nvar event = __webpack_require__(/*! ./event */ \"./node_modules/simple-uploader.js/src/event.js\")\nvar File = __webpack_require__(/*! ./file */ \"./node_modules/simple-uploader.js/src/file.js\")\nvar Chunk = __webpack_require__(/*! ./chunk */ \"./node_modules/simple-uploader.js/src/chunk.js\")\n\nvar version = '__VERSION__'\n\nvar isServer = typeof window === 'undefined'\n\n// ie10+\nvar ie10plus = isServer ? false : window.navigator.msPointerEnabled\nvar support = (function () {\n if (isServer) {\n return false\n }\n var sliceName = 'slice'\n var _support = utils.isDefined(window.File) && utils.isDefined(window.Blob) &&\n utils.isDefined(window.FileList)\n var bproto = null\n if (_support) {\n bproto = window.Blob.prototype\n utils.each(['slice', 'webkitSlice', 'mozSlice'], function (n) {\n if (bproto[n]) {\n sliceName = n\n return false\n }\n })\n _support = !!bproto[sliceName]\n }\n if (_support) Uploader.sliceName = sliceName\n bproto = null\n return _support\n})()\n\nvar supportDirectory = (function () {\n if (isServer) {\n return false\n }\n var input = window.document.createElement('input')\n input.type = 'file'\n var sd = 'webkitdirectory' in input || 'directory' in input\n input = null\n return sd\n})()\n\nfunction Uploader (opts) {\n this.support = support\n /* istanbul ignore if */\n if (!this.support) {\n return\n }\n this.supportDirectory = supportDirectory\n utils.defineNonEnumerable(this, 'filePaths', {})\n this.opts = utils.extend({}, Uploader.defaults, opts || {})\n\n this.preventEvent = utils.bind(this._preventEvent, this)\n\n File.call(this, this)\n}\n\n/**\n * Default read function using the webAPI\n *\n * @function webAPIFileRead(fileObj, fileType, startByte, endByte, chunk)\n *\n */\nvar webAPIFileRead = function (fileObj, fileType, startByte, endByte, chunk) {\n chunk.readFinished(fileObj.file[Uploader.sliceName](startByte, endByte, fileType))\n}\n\nUploader.version = version\n\nUploader.defaults = {\n chunkSize: 1024 * 1024,\n forceChunkSize: false,\n simultaneousUploads: 3,\n singleFile: false,\n fileParameterName: 'file',\n progressCallbacksInterval: 500,\n speedSmoothingFactor: 0.1,\n query: {},\n headers: {},\n withCredentials: false,\n preprocess: null,\n method: 'multipart',\n testMethod: 'GET',\n uploadMethod: 'POST',\n prioritizeFirstAndLastChunk: false,\n allowDuplicateUploads: false,\n target: '/',\n testChunks: true,\n generateUniqueIdentifier: null,\n maxChunkRetries: 0,\n chunkRetryInterval: null,\n permanentErrors: [404, 415, 500, 501],\n successStatuses: [200, 201, 202],\n onDropStopPropagation: false,\n initFileFn: null,\n readFileFn: webAPIFileRead,\n checkChunkUploadedByResponse: null,\n initialPaused: false,\n processResponse: function (response, cb) {\n cb(null, response)\n },\n processParams: function (params) {\n return params\n }\n}\n\nUploader.utils = utils\nUploader.event = event\nUploader.File = File\nUploader.Chunk = Chunk\n\n// inherit file\nUploader.prototype = utils.extend({}, File.prototype)\n// inherit event\nutils.extend(Uploader.prototype, event)\nutils.extend(Uploader.prototype, {\n\n constructor: Uploader,\n\n _trigger: function (name) {\n var args = utils.toArray(arguments)\n var preventDefault = !this.trigger.apply(this, arguments)\n if (name !== 'catchAll') {\n args.unshift('catchAll')\n preventDefault = !this.trigger.apply(this, args) || preventDefault\n }\n return !preventDefault\n },\n\n _triggerAsync: function () {\n var args = arguments\n utils.nextTick(function () {\n this._trigger.apply(this, args)\n }, this)\n },\n\n addFiles: function (files, evt) {\n var _files = []\n var oldFileListLen = this.fileList.length\n utils.each(files, function (file) {\n // Uploading empty file IE10/IE11 hangs i
/*!******************************************************!*\
!*** ./node_modules/simple-uploader.js/src/utils.js ***!
\******************************************************/
/*! no static exports found */function(module,exports){eval("var oproto = Object.prototype\nvar aproto = Array.prototype\nvar serialize = oproto.toString\n\nvar isFunction = function (fn) {\n return serialize.call(fn) === '[object Function]'\n}\n\nvar isArray = Array.isArray || /* istanbul ignore next */ function (ary) {\n return serialize.call(ary) === '[object Array]'\n}\n\nvar isPlainObject = function (obj) {\n return serialize.call(obj) === '[object Object]' && Object.getPrototypeOf(obj) === oproto\n}\n\nvar i = 0\nvar utils = {\n uid: function () {\n return ++i\n },\n noop: function () {},\n bind: function (fn, context) {\n return function () {\n return fn.apply(context, arguments)\n }\n },\n preventEvent: function (evt) {\n evt.preventDefault()\n },\n stop: function (evt) {\n evt.preventDefault()\n evt.stopPropagation()\n },\n nextTick: function (fn, context) {\n setTimeout(utils.bind(fn, context), 0)\n },\n toArray: function (ary, start, end) {\n if (start === undefined) start = 0\n if (end === undefined) end = ary.length\n return aproto.slice.call(ary, start, end)\n },\n\n isPlainObject: isPlainObject,\n isFunction: isFunction,\n isArray: isArray,\n isObject: function (obj) {\n return Object(obj) === obj\n },\n isString: function (s) {\n return typeof s === 'string'\n },\n isUndefined: function (a) {\n return typeof a === 'undefined'\n },\n isDefined: function (a) {\n return typeof a !== 'undefined'\n },\n\n each: function (ary, func, context) {\n if (utils.isDefined(ary.length)) {\n for (var i = 0, len = ary.length; i < len; i++) {\n if (func.call(context, ary[i], i, ary) === false) {\n break\n }\n }\n } else {\n for (var k in ary) {\n if (func.call(context, ary[k], k, ary) === false) {\n break\n }\n }\n }\n },\n\n /**\n * If option is a function, evaluate it with given params\n * @param {*} data\n * @param {...} args arguments of a callback\n * @returns {*}\n */\n evalOpts: function (data, args) {\n if (utils.isFunction(data)) {\n // `arguments` is an object, not array, in FF, so:\n args = utils.toArray(arguments)\n data = data.apply(null, args.slice(1))\n }\n return data\n },\n\n extend: function () {\n var options\n var name\n var src\n var copy\n var copyIsArray\n var clone\n var target = arguments[0] || {}\n var i = 1\n var length = arguments.length\n var force = false\n\n // 如果第一个参数为布尔,判定是否深拷贝\n if (typeof target === 'boolean') {\n force = target\n target = arguments[1] || {}\n i++\n }\n\n // 确保接受方为一个复杂的数据类型\n if (typeof target !== 'object' && !isFunction(target)) {\n target = {}\n }\n\n // 如果只有一个参数,那么新成员添加于 extend 所在的对象上\n if (i === length) {\n target = this\n i--\n }\n\n for (; i < length; i++) {\n // 只处理非空参数\n if ((options = arguments[i]) != null) {\n for (name in options) {\n src = target[name]\n copy = options[name]\n\n // 防止环引用\n if (target === copy) {\n continue\n }\n if (force && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {\n if (copyIsArray) {\n copyIsArray = false\n clone = src && isArray(src) ? src : []\n } else {\n clone = src && isPlainObject(src) ? src : {}\n }\n target[name] = utils.extend(force, clone, copy)\n } else if (copy !== undefined) {\n target[name] = copy\n }\n }\n }\n }\n return target\n },\n\n formatSize: function (size) {\n if (size < 1024) {\n return size.toFixed(0) + ' bytes'\n } else if (size < 1024 * 1024) {\n return (size / 1024.0).toFixed(0) + ' KB'\n } else if (size < 1024 * 1024 * 1024) {\n return (size / 1024.