Edit File by line
/home/barbar84/public_h.../wp-inclu.../js/plupload
File: moxie.js
;var MXI_DEBUG = false;
[0] Fix | Delete
/**
[1] Fix | Delete
* mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
[2] Fix | Delete
* v1.3.5
[3] Fix | Delete
*
[4] Fix | Delete
* Copyright 2013, Moxiecode Systems AB
[5] Fix | Delete
* Released under GPL License.
[6] Fix | Delete
*
[7] Fix | Delete
* License: http://www.plupload.com/license
[8] Fix | Delete
* Contributing: http://www.plupload.com/contributing
[9] Fix | Delete
*
[10] Fix | Delete
* Date: 2016-05-15
[11] Fix | Delete
*/
[12] Fix | Delete
/**
[13] Fix | Delete
* Compiled inline version. (Library mode)
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Modified for WordPress, Silverlight and Flash runtimes support was removed.
[18] Fix | Delete
* See https://core.trac.wordpress.org/ticket/41755.
[19] Fix | Delete
*/
[20] Fix | Delete
[21] Fix | Delete
/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
[22] Fix | Delete
/*globals $code */
[23] Fix | Delete
[24] Fix | Delete
(function(exports, undefined) {
[25] Fix | Delete
"use strict";
[26] Fix | Delete
[27] Fix | Delete
var modules = {};
[28] Fix | Delete
[29] Fix | Delete
function require(ids, callback) {
[30] Fix | Delete
var module, defs = [];
[31] Fix | Delete
[32] Fix | Delete
for (var i = 0; i < ids.length; ++i) {
[33] Fix | Delete
module = modules[ids[i]] || resolve(ids[i]);
[34] Fix | Delete
if (!module) {
[35] Fix | Delete
throw 'module definition dependecy not found: ' + ids[i];
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
defs.push(module);
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
callback.apply(null, defs);
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
function define(id, dependencies, definition) {
[45] Fix | Delete
if (typeof id !== 'string') {
[46] Fix | Delete
throw 'invalid module definition, module id must be defined and be a string';
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
if (dependencies === undefined) {
[50] Fix | Delete
throw 'invalid module definition, dependencies must be specified';
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
if (definition === undefined) {
[54] Fix | Delete
throw 'invalid module definition, definition function must be specified';
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
require(dependencies, function() {
[58] Fix | Delete
modules[id] = definition.apply(null, arguments);
[59] Fix | Delete
});
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
function defined(id) {
[63] Fix | Delete
return !!modules[id];
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
function resolve(id) {
[67] Fix | Delete
var target = exports;
[68] Fix | Delete
var fragments = id.split(/[.\/]/);
[69] Fix | Delete
[70] Fix | Delete
for (var fi = 0; fi < fragments.length; ++fi) {
[71] Fix | Delete
if (!target[fragments[fi]]) {
[72] Fix | Delete
return;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
target = target[fragments[fi]];
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
return target;
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
function expose(ids) {
[82] Fix | Delete
for (var i = 0; i < ids.length; i++) {
[83] Fix | Delete
var target = exports;
[84] Fix | Delete
var id = ids[i];
[85] Fix | Delete
var fragments = id.split(/[.\/]/);
[86] Fix | Delete
[87] Fix | Delete
for (var fi = 0; fi < fragments.length - 1; ++fi) {
[88] Fix | Delete
if (target[fragments[fi]] === undefined) {
[89] Fix | Delete
target[fragments[fi]] = {};
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
target = target[fragments[fi]];
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
target[fragments[fragments.length - 1]] = modules[id];
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
// Included from: src/javascript/core/utils/Basic.js
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Basic.js
[103] Fix | Delete
*
[104] Fix | Delete
* Copyright 2013, Moxiecode Systems AB
[105] Fix | Delete
* Released under GPL License.
[106] Fix | Delete
*
[107] Fix | Delete
* License: http://www.plupload.com/license
[108] Fix | Delete
* Contributing: http://www.plupload.com/contributing
[109] Fix | Delete
*/
[110] Fix | Delete
[111] Fix | Delete
define('moxie/core/utils/Basic', [], function() {
[112] Fix | Delete
/**
[113] Fix | Delete
Gets the true type of the built-in object (better version of typeof).
[114] Fix | Delete
@author Angus Croll (http://javascriptweblog.wordpress.com/)
[115] Fix | Delete
[116] Fix | Delete
@method typeOf
[117] Fix | Delete
@for Utils
[118] Fix | Delete
@static
[119] Fix | Delete
@param {Object} o Object to check.
[120] Fix | Delete
@return {String} Object [[Class]]
[121] Fix | Delete
*/
[122] Fix | Delete
var typeOf = function(o) {
[123] Fix | Delete
var undef;
[124] Fix | Delete
[125] Fix | Delete
if (o === undef) {
[126] Fix | Delete
return 'undefined';
[127] Fix | Delete
} else if (o === null) {
[128] Fix | Delete
return 'null';
[129] Fix | Delete
} else if (o.nodeType) {
[130] Fix | Delete
return 'node';
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
// the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8
[134] Fix | Delete
return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
[135] Fix | Delete
};
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
Extends the specified object with another object.
[139] Fix | Delete
[140] Fix | Delete
@method extend
[141] Fix | Delete
@static
[142] Fix | Delete
@param {Object} target Object to extend.
[143] Fix | Delete
@param {Object} [obj]* Multiple objects to extend with.
[144] Fix | Delete
@return {Object} Same as target, the extended object.
[145] Fix | Delete
*/
[146] Fix | Delete
var extend = function(target) {
[147] Fix | Delete
var undef;
[148] Fix | Delete
[149] Fix | Delete
each(arguments, function(arg, i) {
[150] Fix | Delete
if (i > 0) {
[151] Fix | Delete
each(arg, function(value, key) {
[152] Fix | Delete
if (value !== undef) {
[153] Fix | Delete
if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) {
[154] Fix | Delete
extend(target[key], value);
[155] Fix | Delete
} else {
[156] Fix | Delete
target[key] = value;
[157] Fix | Delete
}
[158] Fix | Delete
}
[159] Fix | Delete
});
[160] Fix | Delete
}
[161] Fix | Delete
});
[162] Fix | Delete
return target;
[163] Fix | Delete
};
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
Executes the callback function for each item in array/object. If you return false in the
[167] Fix | Delete
callback it will break the loop.
[168] Fix | Delete
[169] Fix | Delete
@method each
[170] Fix | Delete
@static
[171] Fix | Delete
@param {Object} obj Object to iterate.
[172] Fix | Delete
@param {function} callback Callback function to execute for each item.
[173] Fix | Delete
*/
[174] Fix | Delete
var each = function(obj, callback) {
[175] Fix | Delete
var length, key, i, undef;
[176] Fix | Delete
[177] Fix | Delete
if (obj) {
[178] Fix | Delete
if (typeOf(obj.length) === 'number') { // it might be Array, FileList or even arguments object
[179] Fix | Delete
// Loop array items
[180] Fix | Delete
for (i = 0, length = obj.length; i < length; i++) {
[181] Fix | Delete
if (callback(obj[i], i) === false) {
[182] Fix | Delete
return;
[183] Fix | Delete
}
[184] Fix | Delete
}
[185] Fix | Delete
} else if (typeOf(obj) === 'object') {
[186] Fix | Delete
// Loop object items
[187] Fix | Delete
for (key in obj) {
[188] Fix | Delete
if (obj.hasOwnProperty(key)) {
[189] Fix | Delete
if (callback(obj[key], key) === false) {
[190] Fix | Delete
return;
[191] Fix | Delete
}
[192] Fix | Delete
}
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
};
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
Checks if object is empty.
[200] Fix | Delete
[201] Fix | Delete
@method isEmptyObj
[202] Fix | Delete
@static
[203] Fix | Delete
@param {Object} o Object to check.
[204] Fix | Delete
@return {Boolean}
[205] Fix | Delete
*/
[206] Fix | Delete
var isEmptyObj = function(obj) {
[207] Fix | Delete
var prop;
[208] Fix | Delete
[209] Fix | Delete
if (!obj || typeOf(obj) !== 'object') {
[210] Fix | Delete
return true;
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
for (prop in obj) {
[214] Fix | Delete
return false;
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
return true;
[218] Fix | Delete
};
[219] Fix | Delete
[220] Fix | Delete
/**
[221] Fix | Delete
Recieve an array of functions (usually async) to call in sequence, each function
[222] Fix | Delete
receives a callback as first argument that it should call, when it completes. Finally,
[223] Fix | Delete
after everything is complete, main callback is called. Passing truthy value to the
[224] Fix | Delete
callback as a first argument will interrupt the sequence and invoke main callback
[225] Fix | Delete
immediately.
[226] Fix | Delete
[227] Fix | Delete
@method inSeries
[228] Fix | Delete
@static
[229] Fix | Delete
@param {Array} queue Array of functions to call in sequence
[230] Fix | Delete
@param {Function} cb Main callback that is called in the end, or in case of error
[231] Fix | Delete
*/
[232] Fix | Delete
var inSeries = function(queue, cb) {
[233] Fix | Delete
var i = 0, length = queue.length;
[234] Fix | Delete
[235] Fix | Delete
if (typeOf(cb) !== 'function') {
[236] Fix | Delete
cb = function() {};
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
if (!queue || !queue.length) {
[240] Fix | Delete
cb();
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
function callNext(i) {
[244] Fix | Delete
if (typeOf(queue[i]) === 'function') {
[245] Fix | Delete
queue[i](function(error) {
[246] Fix | Delete
/*jshint expr:true */
[247] Fix | Delete
++i < length && !error ? callNext(i) : cb(error);
[248] Fix | Delete
});
[249] Fix | Delete
}
[250] Fix | Delete
}
[251] Fix | Delete
callNext(i);
[252] Fix | Delete
};
[253] Fix | Delete
[254] Fix | Delete
[255] Fix | Delete
/**
[256] Fix | Delete
Recieve an array of functions (usually async) to call in parallel, each function
[257] Fix | Delete
receives a callback as first argument that it should call, when it completes. After
[258] Fix | Delete
everything is complete, main callback is called. Passing truthy value to the
[259] Fix | Delete
callback as a first argument will interrupt the process and invoke main callback
[260] Fix | Delete
immediately.
[261] Fix | Delete
[262] Fix | Delete
@method inParallel
[263] Fix | Delete
@static
[264] Fix | Delete
@param {Array} queue Array of functions to call in sequence
[265] Fix | Delete
@param {Function} cb Main callback that is called in the end, or in case of error
[266] Fix | Delete
*/
[267] Fix | Delete
var inParallel = function(queue, cb) {
[268] Fix | Delete
var count = 0, num = queue.length, cbArgs = new Array(num);
[269] Fix | Delete
[270] Fix | Delete
each(queue, function(fn, i) {
[271] Fix | Delete
fn(function(error) {
[272] Fix | Delete
if (error) {
[273] Fix | Delete
return cb(error);
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
var args = [].slice.call(arguments);
[277] Fix | Delete
args.shift(); // strip error - undefined or not
[278] Fix | Delete
[279] Fix | Delete
cbArgs[i] = args;
[280] Fix | Delete
count++;
[281] Fix | Delete
[282] Fix | Delete
if (count === num) {
[283] Fix | Delete
cbArgs.unshift(null);
[284] Fix | Delete
cb.apply(this, cbArgs);
[285] Fix | Delete
}
[286] Fix | Delete
});
[287] Fix | Delete
});
[288] Fix | Delete
};
[289] Fix | Delete
[290] Fix | Delete
[291] Fix | Delete
/**
[292] Fix | Delete
Find an element in array and return it's index if present, otherwise return -1.
[293] Fix | Delete
[294] Fix | Delete
@method inArray
[295] Fix | Delete
@static
[296] Fix | Delete
@param {Mixed} needle Element to find
[297] Fix | Delete
@param {Array} array
[298] Fix | Delete
@return {Int} Index of the element, or -1 if not found
[299] Fix | Delete
*/
[300] Fix | Delete
var inArray = function(needle, array) {
[301] Fix | Delete
if (array) {
[302] Fix | Delete
if (Array.prototype.indexOf) {
[303] Fix | Delete
return Array.prototype.indexOf.call(array, needle);
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
for (var i = 0, length = array.length; i < length; i++) {
[307] Fix | Delete
if (array[i] === needle) {
[308] Fix | Delete
return i;
[309] Fix | Delete
}
[310] Fix | Delete
}
[311] Fix | Delete
}
[312] Fix | Delete
return -1;
[313] Fix | Delete
};
[314] Fix | Delete
[315] Fix | Delete
[316] Fix | Delete
/**
[317] Fix | Delete
Returns elements of first array if they are not present in second. And false - otherwise.
[318] Fix | Delete
[319] Fix | Delete
@private
[320] Fix | Delete
@method arrayDiff
[321] Fix | Delete
@param {Array} needles
[322] Fix | Delete
@param {Array} array
[323] Fix | Delete
@return {Array|Boolean}
[324] Fix | Delete
*/
[325] Fix | Delete
var arrayDiff = function(needles, array) {
[326] Fix | Delete
var diff = [];
[327] Fix | Delete
[328] Fix | Delete
if (typeOf(needles) !== 'array') {
[329] Fix | Delete
needles = [needles];
[330] Fix | Delete
}
[331] Fix | Delete
[332] Fix | Delete
if (typeOf(array) !== 'array') {
[333] Fix | Delete
array = [array];
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
for (var i in needles) {
[337] Fix | Delete
if (inArray(needles[i], array) === -1) {
[338] Fix | Delete
diff.push(needles[i]);
[339] Fix | Delete
}
[340] Fix | Delete
}
[341] Fix | Delete
return diff.length ? diff : false;
[342] Fix | Delete
};
[343] Fix | Delete
[344] Fix | Delete
[345] Fix | Delete
/**
[346] Fix | Delete
Find intersection of two arrays.
[347] Fix | Delete
[348] Fix | Delete
@private
[349] Fix | Delete
@method arrayIntersect
[350] Fix | Delete
@param {Array} array1
[351] Fix | Delete
@param {Array} array2
[352] Fix | Delete
@return {Array} Intersection of two arrays or null if there is none
[353] Fix | Delete
*/
[354] Fix | Delete
var arrayIntersect = function(array1, array2) {
[355] Fix | Delete
var result = [];
[356] Fix | Delete
each(array1, function(item) {
[357] Fix | Delete
if (inArray(item, array2) !== -1) {
[358] Fix | Delete
result.push(item);
[359] Fix | Delete
}
[360] Fix | Delete
});
[361] Fix | Delete
return result.length ? result : null;
[362] Fix | Delete
};
[363] Fix | Delete
[364] Fix | Delete
[365] Fix | Delete
/**
[366] Fix | Delete
Forces anything into an array.
[367] Fix | Delete
[368] Fix | Delete
@method toArray
[369] Fix | Delete
@static
[370] Fix | Delete
@param {Object} obj Object with length field.
[371] Fix | Delete
@return {Array} Array object containing all items.
[372] Fix | Delete
*/
[373] Fix | Delete
var toArray = function(obj) {
[374] Fix | Delete
var i, arr = [];
[375] Fix | Delete
[376] Fix | Delete
for (i = 0; i < obj.length; i++) {
[377] Fix | Delete
arr[i] = obj[i];
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
return arr;
[381] Fix | Delete
};
[382] Fix | Delete
[383] Fix | Delete
[384] Fix | Delete
/**
[385] Fix | Delete
Generates an unique ID. The only way a user would be able to get the same ID is if the two persons
[386] Fix | Delete
at the same exact millisecond manage to get the same 5 random numbers between 0-65535; it also uses
[387] Fix | Delete
a counter so each ID is guaranteed to be unique for the given page. It is more probable for the earth
[388] Fix | Delete
to be hit with an asteroid.
[389] Fix | Delete
[390] Fix | Delete
@method guid
[391] Fix | Delete
@static
[392] Fix | Delete
@param {String} prefix to prepend (by default 'o' will be prepended).
[393] Fix | Delete
@method guid
[394] Fix | Delete
@return {String} Virtually unique id.
[395] Fix | Delete
*/
[396] Fix | Delete
var guid = (function() {
[397] Fix | Delete
var counter = 0;
[398] Fix | Delete
[399] Fix | Delete
return function(prefix) {
[400] Fix | Delete
var guid = new Date().getTime().toString(32), i;
[401] Fix | Delete
[402] Fix | Delete
for (i = 0; i < 5; i++) {
[403] Fix | Delete
guid += Math.floor(Math.random() * 65535).toString(32);
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
return (prefix || 'o_') + guid + (counter++).toString(32);
[407] Fix | Delete
};
[408] Fix | Delete
}());
[409] Fix | Delete
[410] Fix | Delete
[411] Fix | Delete
/**
[412] Fix | Delete
Trims white spaces around the string
[413] Fix | Delete
[414] Fix | Delete
@method trim
[415] Fix | Delete
@static
[416] Fix | Delete
@param {String} str
[417] Fix | Delete
@return {String}
[418] Fix | Delete
*/
[419] Fix | Delete
var trim = function(str) {
[420] Fix | Delete
if (!str) {
[421] Fix | Delete
return str;
[422] Fix | Delete
}
[423] Fix | Delete
return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');
[424] Fix | Delete
};
[425] Fix | Delete
[426] Fix | Delete
[427] Fix | Delete
/**
[428] Fix | Delete
Parses the specified size string into a byte value. For example 10kb becomes 10240.
[429] Fix | Delete
[430] Fix | Delete
@method parseSizeStr
[431] Fix | Delete
@static
[432] Fix | Delete
@param {String/Number} size String to parse or number to just pass through.
[433] Fix | Delete
@return {Number} Size in bytes.
[434] Fix | Delete
*/
[435] Fix | Delete
var parseSizeStr = function(size) {
[436] Fix | Delete
if (typeof(size) !== 'string') {
[437] Fix | Delete
return size;
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
var muls = {
[441] Fix | Delete
t: 1099511627776,
[442] Fix | Delete
g: 1073741824,
[443] Fix | Delete
m: 1048576,
[444] Fix | Delete
k: 1024
[445] Fix | Delete
},
[446] Fix | Delete
mul;
[447] Fix | Delete
[448] Fix | Delete
[449] Fix | Delete
size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, ''));
[450] Fix | Delete
mul = size[2];
[451] Fix | Delete
size = +size[1];
[452] Fix | Delete
[453] Fix | Delete
if (muls.hasOwnProperty(mul)) {
[454] Fix | Delete
size *= muls[mul];
[455] Fix | Delete
}
[456] Fix | Delete
return Math.floor(size);
[457] Fix | Delete
};
[458] Fix | Delete
[459] Fix | Delete
[460] Fix | Delete
/**
[461] Fix | Delete
* Pseudo sprintf implementation - simple way to replace tokens with specified values.
[462] Fix | Delete
*
[463] Fix | Delete
* @param {String} str String with tokens
[464] Fix | Delete
* @return {String} String with replaced tokens
[465] Fix | Delete
*/
[466] Fix | Delete
var sprintf = function(str) {
[467] Fix | Delete
var args = [].slice.call(arguments, 1);
[468] Fix | Delete
[469] Fix | Delete
return str.replace(/%[a-z]/g, function() {
[470] Fix | Delete
var value = args.shift();
[471] Fix | Delete
return typeOf(value) !== 'undefined' ? value : '';
[472] Fix | Delete
});
[473] Fix | Delete
};
[474] Fix | Delete
[475] Fix | Delete
[476] Fix | Delete
return {
[477] Fix | Delete
guid: guid,
[478] Fix | Delete
typeOf: typeOf,
[479] Fix | Delete
extend: extend,
[480] Fix | Delete
each: each,
[481] Fix | Delete
isEmptyObj: isEmptyObj,
[482] Fix | Delete
inSeries: inSeries,
[483] Fix | Delete
inParallel: inParallel,
[484] Fix | Delete
inArray: inArray,
[485] Fix | Delete
arrayDiff: arrayDiff,
[486] Fix | Delete
arrayIntersect: arrayIntersect,
[487] Fix | Delete
toArray: toArray,
[488] Fix | Delete
trim: trim,
[489] Fix | Delete
sprintf: sprintf,
[490] Fix | Delete
parseSizeStr: parseSizeStr
[491] Fix | Delete
};
[492] Fix | Delete
});
[493] Fix | Delete
[494] Fix | Delete
// Included from: src/javascript/core/utils/Env.js
[495] Fix | Delete
[496] Fix | Delete
/**
[497] Fix | Delete
* Env.js
[498] Fix | Delete
*
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function