w/extensions/FlaggedRevs/frontend/modules/ext.flaggedRevs.review.js
/*
	 * Update form elements after AJAX review.
	 */
Update form elements after AJAX review.
Update form elements after AJAX review .
function postSubmitRevisionReview( form, response ) {
		var changeTime, $asubmit, $usubmit, $rsubmit, $diffNotice, $tagBox, $diffUIParams,
			requestArgs, urlParams, i, l,
			msg = response.substr( 6 ), 
			m = msg.match( /^<lct#(\d*)>(.*)/m );
		if ( m ) {
			msg = m[ 2 ]; 
		}
		changeTime = m ? m[ 1 ] : null; 
		$asubmit = $( '#mw-fr-submit-accept' ); 
		$usubmit = $( '#mw-fr-submit-unaccept' ); 
		$rsubmit = $( '#mw-fr-submit-reject' ); 
		$diffNotice = $( '#mw-fr-difftostable' );
		$tagBox = $( '#mw-fr-revisiontag' );
		$diffUIParams = $( '#mw-fr-diff-dataform' );
		if ( response.indexOf( '<suc#>' ) === 0 ) {
			if ( $asubmit.length && $usubmit.length ) {
				if ( $asubmit.val() === mw.msg( 'revreview-submitting' ) ) {
					$asubmit.val( mw.msg( 'revreview-submit-reviewed' ) ); 
					$asubmit.css( 'fontWeight', 'bold' );
					$usubmit.val( mw.msg( 'revreview-submit-unreview' ) );
					$usubmit.css( 'fontWeight', '' ); 
					$usubmit.show(); 
					$usubmit.prop( 'disabled', false ); 
					$rsubmit.prop( 'disabled', true ); 
				} else if ( $usubmit.val() === mw.msg( 'revreview-submitting' ) ) {
					$usubmit.val( mw.msg( 'revreview-submit-unreviewed' ) ); 
					$usubmit.css( 'fontWeight', 'bold' );
					$asubmit.val( mw.msg( 'revreview-submit-review' ) );
					$asubmit.css( 'fontWeight', '' ); 
					$asubmit.prop( 'disabled', false ); 
					$rsubmit.prop( 'disabled', false );  if present
				}
			}
			$tagBox.css( 'display', 'none' );
			if ( $diffUIParams.length ) {
				$diffNotice.hide();
				requestArgs = []; 
				requestArgs.push( $diffUIParams.find( 'input' ).eq( 0 ).val() );
				requestArgs.push( $diffUIParams.find( 'input' ).eq( 1 ).val() );
				urlParams = '?action=ajax&rs=FlaggablePageView::AjaxBuildDiffHeaderItems';
				for ( i = 0, l = requestArgs.length; i < l; i++ ) {
					urlParams += '&rsargs[]=' + encodeURIComponent( requestArgs[ i ] );
				}
				$.ajax( {
					url: mw.util.wikiScript( 'index' ) + urlParams,
					type: 'GET',
					dataType: 'html', 
					success: function ( response ) {
						$( '#mw-fr-diff-headeritems' ).html( response );
					}
				} );
			}
		} else {
			if ( $asubmit.length && $usubmit.length ) {
				if ( $asubmit.val() === mw.msg( 'revreview-submitting' ) ) {
					$asubmit.val( mw.msg( 'revreview-submit-review' ) ); 
					$asubmit.prop( 'disabled', false ); 
				} else if ( $usubmit.val() === mw.msg( 'revreview-submitting' ) ) {
					$usubmit.val( mw.msg( 'revreview-submit-unreview' ) ); 
					$usubmit.prop( 'disabled', false ); 
				}
			}
			if ( response.indexOf( '<err#>' ) === 0 ) {
				mw.notify( $.parseHTML( msg ), { tag: 'review' } ); 
			} else {
				mw.notify( response, { tag: 'review' } ); 
			}
		}
		if ( changeTime !== null ) {
			$( '#mw-fr-input-changetime' ).val( changeTime );
		}
		unlockReviewForm( form );
	}
function postSubmitRevisionReview ( form , response ) { var changeTime , $asubmit , $usubmit , $rsubmit , $diffNotice , $tagBox , $diffUIParams , requestArgs , urlParams , i , l , msg = response . substr ( 6 ) , m = msg . match ( / ^<lct#(\d*)>(.*) / m ) ; if ( m ) { msg = m [ 2 ] ; } changeTime = m ? m [ 1 ] : null ; $asubmit = $ ( '#mw-fr-submit-accept' ) ; $usubmit = $ ( '#mw-fr-submit-unaccept' ) ; $rsubmit = $ ( '#mw-fr-submit-reject' ) ; $diffNotice = $ ( '#mw-fr-difftostable' ) ; $tagBox = $ ( '#mw-fr-revisiontag' ) ; $diffUIParams = $ ( '#mw-fr-diff-dataform' ) ; if ( response . indexOf ( '<suc#>' ) === 0 ) { if ( $asubmit . length && $usubmit . length ) { if ( $asubmit . val ( ) === mw . msg ( 'revreview-submitting' ) ) { $asubmit . val ( mw . msg ( 'revreview-submit-reviewed' ) ) ; $asubmit . css ( 'fontWeight' , 'bold' ) ; $usubmit . val ( mw . msg ( 'revreview-submit-unreview' ) ) ; $usubmit . css ( 'fontWeight' , '' ) ; $usubmit . show ( ) ; $usubmit . prop ( 'disabled' , false ) ; $rsubmit . prop ( 'disabled' , true ) ; } else if ( $usubmit . val ( ) === mw . msg ( 'revreview-submitting' ) ) { $usubmit . val ( mw . msg ( 'revreview-submit-unreviewed' ) ) ; $usubmit . css ( 'fontWeight' , 'bold' ) ; $asubmit . val ( mw . msg ( 'revreview-submit-review' ) ) ; $asubmit . css ( 'fontWeight' , '' ) ; $asubmit . prop ( 'disabled' , false ) ; $rsubmit . prop ( 'disabled' , false ) ; } } $tagBox . css ( 'display' , 'none' ) ; if ( $diffUIParams . length ) { $diffNotice . hide ( ) ; requestArgs = [ ] ; requestArgs . push ( $diffUIParams . find ( 'input' ) . eq ( 0 ) . val ( ) ) ; requestArgs . push ( $diffUIParams . find ( 'input' ) . eq ( 1 ) . val ( ) ) ; urlParams = '?action=ajax&rs=FlaggablePageView::AjaxBuildDiffHeaderItems' ; for ( i = 0 , l = requestArgs . length ; i < l ; i ++ ) { urlParams += '&rsargs[]=' + encodeURIComponent ( requestArgs [ i ] ) ; } $ . ajax ( { url : mw . util . wikiScript ( 'index' ) + urlParams , type : 'GET' , dataType : 'html' , success : function ( response ) { $ ( '#mw-fr-diff-headeritems' ) . html ( response ) ; } } ) ; } } else { if ( $asubmit . length && $usubmit . length ) { if ( $asubmit . val ( ) === mw . msg ( 'revreview-submitting' ) ) { $asubmit . val ( mw . msg ( 'revreview-submit-review' ) ) ; $asubmit . prop ( 'disabled' , false ) ; } else if ( $usubmit . val ( ) === mw . msg ( 'revreview-submitting' ) ) { $usubmit . val ( mw . msg ( 'revreview-submit-unreview' ) ) ; $usubmit . prop ( 'disabled' , false ) ; } } if ( response . indexOf ( '<err#>' ) === 0 ) { mw . notify ( $ . parseHTML ( msg ) , { tag : 'review' } ) ; } else { mw . notify ( response , { tag : 'review' } ) ; } } if ( changeTime !== null ) { $ ( '#mw-fr-input-changetime' ) . val ( changeTime ) ; } unlockReviewForm ( form ) ; }
Update form elements after AJAX review.
Update form elements after AJAX review .
// remove <err#> or <suc#> // Read new "last change time" timestamp for conflict handling // @TODO: pass last-chage-time data using JSON or something not retarded // remove tag from msg // MW TS // Review form elements // ACCEPT // UNACCEPT // REJECT // FlaggedRevs rating box // Diff parameters // On success... // (a) Update document title and form buttons... // Revision was flagged // done! // Unlock and reset *unflag* button // back to normal // now available // unlock // lock if present // Revision was unflagged // done! // Unlock and reset *flag* button // back to normal // unlock // unlock if present // (b) Remove review tag from drafts // (c) Update diff-related items... // Hide "review this" box on diffs // Update the contents of the mw-fr-diff-headeritems div // <oldid, newid> // Send encoded function plus all arguments... // Send GET request via AJAX! // response type // Update the contents of the mw-fr-diff-headeritems div // On failure... // (a) Update document title and form buttons... // Revision was flagged // back to normal // unlock // Revision was unflagged // back to normal // unlock // (b) Output any error response message // failure notice // fatal notice // Update changetime for conflict handling