11var http_communication_locked = false ;
22var http_cmd_list = [ ] ;
33var processing_cmd = false ;
4+ var xmlhttpupload ;
45
56var max_cmd = 20 ;
67
@@ -217,26 +218,32 @@ function SendFileHttp(url, postdata, progress_fn, result_fn, error_fn) {
217218 process_cmd ( ) ;
218219}
219220
221+ function CancelCurrentUpload ( ) {
222+ xmlhttpupload . abort ( ) ;
223+ //http_communication_locked = false;
224+ console . log ( "Cancel Upload" ) ;
225+ }
226+
220227function ProcessFileHttp ( url , postdata , progressfn , resultfn , errorfn ) {
221228 if ( http_communication_locked ) {
222229 errorfn ( 503 , translate_text_item ( "Communication locked!" ) ) ;
223230 return ;
224231 }
225232 http_communication_locked = true ;
226- var xmlhttp = new XMLHttpRequest ( ) ;
227- xmlhttp . onreadystatechange = function ( ) {
228- if ( xmlhttp . readyState == 4 ) {
233+ xmlhttpupload = new XMLHttpRequest ( ) ;
234+ xmlhttpupload . onreadystatechange = function ( ) {
235+ if ( xmlhttpupload . readyState == 4 ) {
229236 http_communication_locked = false ;
230- if ( xmlhttp . status == 200 ) {
231- if ( typeof resultfn != 'undefined' && resultfn != null ) resultfn ( xmlhttp . responseText ) ;
237+ if ( xmlhttpupload . status == 200 ) {
238+ if ( typeof resultfn != 'undefined' && resultfn != null ) resultfn ( xmlhttpupload . responseText ) ;
232239 } else {
233- if ( xmlhttp . status == 401 ) GetIdentificationStatus ( ) ;
234- if ( typeof errorfn != 'undefined' && errorfn != null ) errorfn ( xmlhttp . status , xmlhttp . responseText ) ;
240+ if ( xmlhttpupload . status == 401 ) GetIdentificationStatus ( ) ;
241+ if ( typeof errorfn != 'undefined' && errorfn != null ) errorfn ( xmlhttpupload . status , xmlhttpupload . responseText ) ;
235242 }
236243 }
237244 }
238245 //console.log(url);
239- xmlhttp . open ( "POST" , url , true ) ;
240- if ( typeof progressfn != 'undefined' && progressfn != null ) xmlhttp . upload . addEventListener ( "progress" , progressfn , false ) ;
241- xmlhttp . send ( postdata ) ;
242- }
246+ xmlhttpupload . open ( "POST" , url , true ) ;
247+ if ( typeof progressfn != 'undefined' && progressfn != null ) xmlhttpupload . upload . addEventListener ( "progress" , progressfn , false ) ;
248+ xmlhttpupload . send ( postdata ) ;
249+ }
0 commit comments