| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- /**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or http://ckeditor.com/license
- */
-
- 'use strict';
-
- // Slow down the upload process.
- // This trick works only on Chrome.
-
- ( function() {
- XMLHttpRequest.prototype.baseSend = XMLHttpRequest.prototype.send;
-
- XMLHttpRequest.prototype.send = function( data ) {
- var baseOnProgress = this.onprogress,
- baseOnLoad = this.onload;
-
- this.onprogress = function() {};
-
- this.onload = function( evt ) {
- // Total file size.
- var total = 1163,
- step = Math.round( total / 10 ),
- loaded = 0,
- xhr = this;
-
- function progress() {
- setTimeout( function() {
- if ( xhr.aborted ) {
- return;
- }
-
- loaded += step;
- if ( loaded > total ) {
- loaded = total;
- }
-
- if ( loaded > step * 4 && xhr.responseText.indexOf( 'incorrectFile' ) > 0 ) {
- xhr.aborted = true;
- xhr.onerror();
- } else if ( loaded < total ) {
- evt.loaded = loaded;
- baseOnProgress( { loaded: loaded } );
- progress();
- } else {
- baseOnLoad( evt );
- }
- }, 300 );
- }
-
- progress();
- };
-
- this.abort = function() {
- this.aborted = true;
- this.onabort();
- };
-
- this.baseSend( data );
- };
- } )();
|