Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }
- function _html5Submit() {
- _html5Submit = _asyncToGenerator( _regeneratorRuntime().mark(function _callee56(form, submitter) {
- var needProgress,
- data,
- hasFiles,
- _iterator36,
- _step36,
- _step36$value,
- name,
- value,
- type,
- el,
- val,
- _el$obj,
- fileName,
- newFileName,
- mime,
- cleanData,
- ajaxParams,
- url,
- _args64 = arguments;
- return _regeneratorRuntime().wrap(function _callee56$(_context64) {
- while (1) switch (_context64.prev = _context64.next) {
- case 0:
- needProgress = _args64.length > 2 && _args64[2] !== undefined ? _args64[2] : false;
- data = new FormData();
- hasFiles = false;
- _iterator36 = _createForOfIteratorHelperLoose(getFormElements(form, submitter));
- case 4:
- if ((_step36 = _iterator36()).done) {
- _context64.next = 30;
- break;
- }
- _step36$value = _step36.value, name = _step36$value.name, value = _step36$value.value, type = _step36$value.type, el = _step36$value.el;
- val = value;
- if (!(name === 'de-file-txt')) {
- _context64.next = 9;
- break;
- }
- return _context64.abrupt("continue", 28);
- case 9:
- if (!(type === 'file')) {
- _context64.next = 27;
- break;
- }
- hasFiles = true;
- fileName = value.name;
- newFileName = !Cfg.removeFName || (_el$obj = el.obj) !== null && _el$obj !== void 0 && (_el$obj = _el$obj.imgFile) !== null && _el$obj !== void 0 && _el$obj.isCustomName ? fileName : (Cfg.removeFName === 1 ? '' :
- Cfg.removeFName === 2 ? (Date.now() - 0) : (() => {
- let result = '';
- let length = Math.floor(Math.random() * (15 - 10 + 1) + 10);
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- const charactersLength = characters.length;
- let counter = 0;
- while (counter < length) {
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
- counter += 1;
- }
- return result;
- })()) + '.' + getFileExt(fileName);
- mime = value.type;
- if (!((Cfg.postSameImg || Cfg.removeEXIF) && (mime === 'image/jpeg' || mime === 'image/png' || mime === 'image/gif' || mime === 'video/webm'))) {
- _context64.next = 26;
- break;
- }
- _context64.t0 = cleanFile;
- _context64.next = 18;
- return readFile(value);
- case 18:
- _context64.t1 = _context64.sent.data;
- _context64.t2 = el.obj ? el.obj.extraFile : null;
- cleanData = (0, _context64.t0)(_context64.t1, _context64.t2);
- if (cleanData) {
- _context64.next = 23;
- break;
- }
- return _context64.abrupt("return", Promise.reject(new Error(Lng.fileCorrupt[lang] + ': ' + fileName)));
- case 23:
- val = new File(cleanData, newFileName, {
- type: mime
- });
- _context64.next = 27;
- break;
- case 26:
- if (Cfg.removeFName) {
- val = new File([value], newFileName, {
- type: mime
- });
- }
- case 27:
- data.append(name, val);
- case 28:
- _context64.next = 4;
- break;
- case 30:
- if (!aib.sendHTML5Post) {
- _context64.next = 32;
- break;
- }
- return _context64.abrupt("return", aib.sendHTML5Post(form, data, needProgress, hasFiles));
- case 32:
- ajaxParams = {
- data: data,
- method: 'POST'
- };
- if (needProgress && hasFiles) {
- ajaxParams.onprogress = getUploadFunc();
- }
- url = form.action;
- return _context64.abrupt("return", $ajax(url, ajaxParams).then(function (_ref62) {
- var text = _ref62.responseText;
- return aib.jsonSubmit ? text : aib.stormWallFixSubmit ? aib.stormWallFixSubmit(url, text, ajaxParams) : $createDoc(text);
- })["catch"](function (err) {
- return Promise.reject(err);
- }));
- case 36:
- case "end":
- return _context64.stop();
- }
- }, _callee56);
- }));
- return _html5Submit.apply(this, arguments);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement