@@ -411,150 +411,7 @@ notifyAboutGGGReplays = _.once(function() {
411411
412412$ ( function ( ) {
413413
414- fuconfig = {
415- url : 'https://' + gon . global . replays_bucket + '.s3.amazonaws.com' ,
416- type : 'POST' ,
417- autoUpload : true ,
418- dataType : 'xml' ,
419- add : function ( e , data ) {
420- // console.log("add!", data.files.length);
421-
422- if ( gg . state . iecompat ) {
423- alert ( "Our apologies, but this browser can't upload replays to GGTracker. To upload replays, you can use Internet Explorer 10, Google Chrome, Firefox or Safari." ) ;
424- return false ;
425- }
426-
427- uploadScope = angular . element ( $ ( '.uploads' ) ) . scope ( ) ;
428-
429- if ( _ . isUndefined ( rootScope . creplays ) || rootScope . creplays . length == 0 ) {
430- // creplays are the replays that are still being uploaded/processed.
431- // allreplays has all of the replays that were uploaded for this upload, regardless of their state
432- uploadScope . creplays = [ ]
433- uploadScope . allreplays = [ ]
434- // console.log("clearing arrays!");
435-
436- $ ( '#uploads' )
437- . dialog ( {
438- modal : true ,
439- draggable : false ,
440- resizable : false ,
441- dialogClass : 'dialog-uploads' ,
442- width : 'auto' ,
443- position : { my : 'top' , at : 'top+75' } ,
444- collision : 'none' ,
445- show : 'slide'
446- } ) .
447- addClass ( 'uploads-expanded' ) ;
448-
449- $ ( window ) . bind ( 'beforeunload' , function ( ) {
450- // console.log("beforeunload!", $('.button-upload input'), $('.button-upload input').data('fileupload'), uploadScope);
451- // return 'Foo!';
452- if ( $ ( '.button-upload input' ) . data ( 'fileupload' ) . _active > 0 &&
453- uploadScope . creplays . length > 0 ) {
454-
455- // console.log("Not leaving yet", $('#upload input').data('fileupload'), $('#upload input').data('fileupload')._active);
456- return 'Leaving now will cancel your uploads in progress.' ;
457- }
458- } ) ;
459- }
460-
461- if ( uploadScope . allreplays . length >= uploadLimit ( ) ) {
462- notifyAboutUploadLimit ( ) ;
463- return false ;
464- } else if ( blockForShutdown ( ) ) {
465- notifyAboutGGGReplays ( ) ;
466- return false ;
467- } else {
468-
469-
470- replay = {
471- progress : 0 ,
472- status : '-' ,
473- state : '-' ,
474- replay_file_name : data . files [ 0 ] . name
475- } ;
476- uploadScope . creplays . push ( replay ) ;
477- uploadScope . allreplays . push ( replay ) ;
478- throttledUploadDigest ( ) ;
479-
480- $ . ajax ( {
481- url : "/signed_urls" ,
482- type : 'GET' ,
483- dataType : 'json' ,
484- data : { doc : { title : data . files [ 0 ] . name } } , // send the file name to the server so it can generate the key param
485- async : false ,
486- success : function ( ajaxdata ) {
487- data . formData = {
488- key : ajaxdata . key ,
489- AWSAccessKeyId : gon . global . replays_access_key ,
490- acl : 'public-read' ,
491- policy : ajaxdata . policy ,
492- signature : ajaxdata . signature ,
493- success_action_status : '201'
494- } ;
495- data . submit ( ) ;
496- }
497- } ) ;
498- }
499- } ,
500-
501- send : function ( e , data ) {
502- uploadScope = angular . element ( $ ( '.uploads' ) ) . scope ( ) ;
503- $ . each ( data . files , function ( i , file ) {
504- replay = _ . find ( uploadScope . creplays , function ( rep ) { return rep . replay_file_name == file . name } )
505- if ( ! _ . isUndefined ( replay ) ) {
506- replay . status = 'Uploading' ;
507- setState ( replay , 'Uploading' ) ;
508- }
509- } ) ;
510- throttledUploadDigest ( ) ;
511- } ,
512-
513- drop : function ( e , data ) {
514- } ,
515-
516- change : function ( e , data ) {
517- } ,
518-
519- progress : function ( e , data ) {
520- // console.log("progress");
521-
522- var progress = parseInt ( data . loaded / data . total * 100 , 10 ) ;
523-
524- uploadScope = angular . element ( $ ( '.uploads' ) ) . scope ( ) ;
525- replay = _ . find ( uploadScope . creplays , function ( rep ) { return rep . replay_file_name == data . files [ 0 ] . name } )
526-
527- if ( ! _ . isUndefined ( replay ) ) {
528- replay . progress = progress ;
529- if ( progress == 100 ) {
530- replay . status = 'Waiting to be processed' ;
531- setState ( replay , 'processing' ) ;
532- }
533- } else {
534- // console.log('NNAYITS1238', data.files[0].name, rootScope.creplays, replay);
535- }
536-
537- throttledUploadDigest ( ) ;
538- } ,
539-
540- done : function ( e , data ) {
541- // console.log("done! ", $(data.result.getElementsByTagName("Location")[0]).text(), data.files[0].name);
542-
543- $ . ajax ( {
544- url : '/replays/s3_drop' ,
545- type : 'POST' ,
546- data : {
547- file_name : data . files [ 0 ] . name ,
548- s3_key : $ ( data . result . getElementsByTagName ( "Key" ) [ 0 ] ) . text ( ) ,
549- channel : gg . settings . replay_channel
550- } ,
551- async : true ,
552- } ) ;
553- }
554- } ; // fuconfig
555-
556- $ ( '.button-upload input[name="file"]' ) . fileupload ( fuconfig ) ;
557- $ ( '.button-upload input[name="differentname"]' ) . fileupload ( fuconfig ) ;
414+ $ ( '.button-upload' ) . click ( notifyAboutGGGReplays ) ;
558415
559416 join = function ( which_one ) {
560417
0 commit comments