r100161 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100160‎ | r100161 | r100162 >
Date:21:06, 18 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Trim trailing whitespace
Modified paths:
  • /trunk/extensions/Contest/resources/contest.contestant.pager.js (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.contests.js (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.editcontest.js (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.signup.js (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.submission.js (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.welcome.js (modified) (history)
  • /trunk/extensions/Contest/resources/jquery.contestChallenges.js (modified) (history)
  • /trunk/extensions/Contest/resources/jquery.contestSubmission.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/resources/contest.special.submission.js
@@ -1,19 +1,19 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw ) {
11 -
 10+(function( $, mw ) {
 11+
1212 $( document ).ready( function() {
1313
1414 $( '.mw-htmlform-submit' ).button();
15 -
 15+
1616 $( '.contest-submission' ).contestSubmission();
17 -
 17+
1818 } );
1919
20 -})( window.jQuery, window.mediaWiki );
\ No newline at end of file
 20+})( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Contest/resources/contest.special.welcome.js
@@ -1,32 +1,32 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw ) {
11 -
 10+(function( $, mw ) {
 11+
1212 $( document ).ready( function() {
1313
1414 $( '#contest-challenges' ).contestChallenges(
1515 mw.config.get( 'ContestChallenges' ),
1616 mw.config.get( 'ContestConfig' )
1717 );
18 -
 18+
1919 $rules = $( '#contest-rules' );
20 -
 20+
2121 $div = $( '<div />' ).attr( {
2222 'style': 'display:none'
2323 } ).html( $( '<div />' ).attr( { 'id': 'contest-rules-div' } ).html( $rules.attr( 'data-rules' ) ) );
24 -
 24+
2525 // TODO: fix very ugly message construction.
2626 $a = $( '<a />' ).text( mw.msg( 'contest-welcome-rules-link' ) ).attr( { 'href': '#contest-rules-div' } );
2727 $p = $( '<p />' ).text( mw.msg( 'contest-welcome-rules' ) + ' ' ).append( $a ).append( '.' );
28 -
 28+
2929 $rules.html( $p ).append( $div );
30 -
 30+
3131 $a.fancybox( {
3232 'width' : '85%',
3333 'height' : '85%',
Index: trunk/extensions/Contest/resources/jquery.contestSubmission.js
@@ -1,13 +1,13 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
1010 (function( $, mw ) {
11 -
 11+
1212 /**
1313 * Regex text escaping function.
1414 * Borrowed from http://simonwillison.net/2006/Jan/20/escape/
@@ -15,42 +15,42 @@
1616 RegExp.escape = function( text ) {
1717 if ( !arguments.callee.sRE ) {
1818 var specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\' ];
19 - arguments.callee.sRE = new RegExp( '(\\' + specials.join('|\\') + ')', 'g' );
 19+ arguments.callee.sRE = new RegExp( '(\\' + specials.join('|\\') + ')', 'g' );
2020 }
2121 return text.replace(arguments.callee.sRE, '\\$1');
2222 }
23 -
 23+
2424 $.fn.contestSubmission = function() {
2525 var _this = this;
2626 var $this = $( this );
27 -
 27+
2828 this.config = {};
2929 this.status = {};
30 -
 30+
3131 this.input = null;
3232 this.label = null;
33 -
 33+
3434 this.getValue = function() {
3535 return this.input.val();
3636 }
37 -
 37+
3838 this.getDomains = function() {
3939 return this.config.domains;
4040 };
41 -
 41+
4242 this.validate = function() {
4343 var domains = _this.getDomains();
44 -
 44+
4545 for ( var i = domains.length - 1; i >= 0; i-- ) {
4646 var regex = new RegExp( "^https?://(([a-z0-9]+)\\.)?" + RegExp.escape( domains[i] ) + "/(.*)?$", "gi" );
4747 if ( regex.test( this.getValue() ) ) {
4848 return true;
4949 }
5050 }
51 -
 51+
5252 return false;
5353 };
54 -
 54+
5555 this.showStatus = function() {
5656 if ( _this.status.valid ) {
5757 _this.input.removeClass( 'error' );
@@ -59,16 +59,16 @@
6060 _this.input.addClass( 'error' );
6161 }
6262 };
63 -
 63+
6464 this.onValueChanged = function() {
6565 _this.status.valid = _this.validate();
6666 _this.showStatus();
6767 };
68 -
 68+
6969 this.setup = function() {
7070 var message = $this.attr( 'data-value' ) === '' ? 'contest-submission-new-submission' : 'contest-submission-current-submission';
7171 var domainLinks = [];
72 -
 72+
7373 for ( var i = this.config.domains.length - 1; i >= 0; i-- ) {
7474 var link = $( '<a />' ).text( this.config.domains[i] ).attr( {
7575 'href': 'http://' + this.config.domains[i],
@@ -76,16 +76,16 @@
7777 } );
7878 domainLinks.push( $( '<div />' ).html( link ).html() );
7979 }
80 -
 80+
8181 var links = $( '<span />' ).html( '' );
82 -
 82+
8383 this.label = $( '<label style="display:block" />' ).attr( {
8484 'for': this.config.name,
8585 } ).text( mw.msg( message ) ).append(
8686 $( '<br />' ),
8787 mw.msg( 'contest-submission-domains', domainLinks.join( ', ' ) )
8888 );
89 -
 89+
9090 this.input = $( '<input />' ).attr( {
9191 'type': 'text',
9292 'value': $this.attr( 'data-value' ),
@@ -93,23 +93,23 @@
9494 'size': 45,
9595 'id': this.config.name
9696 } );
97 -
 97+
9898 this.html( this.label );
9999 this.append( this.input );
100 -
 100+
101101 this.input.keyup( this.onValueChanged );
102102 };
103 -
 103+
104104 this.getConfig = function() {
105105 this.config.name = $this.attr( 'data-name' );
106106 this.config.domains = $this.attr( 'data-domains' ).split( '|' );
107107 };
108 -
 108+
109109 this.getConfig();
110110 this.setup();
111111 this.onValueChanged();
112 -
 112+
113113 return this;
114114 };
115 -
116 -})( window.jQuery, window.mediaWiki );
\ No newline at end of file
 115+
 116+})( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Contest/resources/contest.contestant.pager.js
@@ -1,19 +1,19 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw ) {
11 -
 10+(function( $, mw ) {
 11+
1212 $( document ).ready( function() {
1313
1414 $( '.contestant-row' ).click( function() {
1515 window.location = $( this ).attr( 'data-contestant-target' );
1616 } );
17 -
 17+
1818 } );
1919
20 -})( window.jQuery, window.mediaWiki );
\ No newline at end of file
 20+})( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Contest/resources/contest.special.contests.js
@@ -1,7 +1,7 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
@@ -24,12 +24,12 @@
2525 failCallback( mw.msg( 'contest-special-delete-failed' ) );
2626 }
2727 }
28 - );
 28+ );
2929 }
30 -
 30+
3131 $( '.contest-delete' ).click( function() {
3232 $this = $( this );
33 -
 33+
3434 if ( confirm( mw.msg( 'contest-special-confirm-delete' ) ) ) {
3535 deleteContest(
3636 {
@@ -39,7 +39,7 @@
4040 function() {
4141 $this.closest( 'tr' ).slideUp( 'slow', function() {
4242 $( this ).remove();
43 -
 43+
4444 if ( $( '.contests-table tr' ).length < 2 ) {
4545 $( '.contests-table' ).remove();
4646 $( '.contests-title' ).remove();
@@ -53,5 +53,5 @@
5454 }
5555 return false;
5656 } );
57 -
58 -} ); })( window.jQuery, window.mediaWiki );
\ No newline at end of file
 57+
 58+} ); })( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Contest/resources/contest.special.editcontest.js
@@ -1,85 +1,85 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
1010 (function( $, mw ) {
11 -
 11+
1212 function addChallengeToRemove( id ) {
1313 if ( !isNaN( id ) ) {
1414 var currentVal = $( '#delete-challenges' ).val();
15 -
 15+
1616 var currentIds = currentVal !== '' ? currentVal.split( '|' ) : [];
1717 currentIds.push( id );
18 -
 18+
1919 $( '#delete-challenges' ).val( currentIds.join( '|' ) );
2020 }
2121 }
22 -
 22+
2323 $.fn.mwChallenge = function( options ) {
24 -
 24+
2525 var _this = this;
2626 var $this = $( this );
2727 this.options = options;
28 -
 28+
2929 this.titleInput = null;
3030 this.textInput = null;
3131 this.deleteButton = null;
32 -
 32+
3333 this.remove = function() {
3434 addChallengeToRemove( $this.attr( 'data-challenge-id' ) );
35 -
 35+
3636 $tr = $this.closest( 'tr' );
3737 $tr.slideUp( 'fast', function() { $tr.remove(); } );
3838 };
39 -
 39+
4040 this.init = function() {
4141 $this.html( '' );
42 -
 42+
4343 this.titleInput = $( '<input />' ).attr( {
4444 'type': 'text',
4545 'name': 'contest-challenge-' + $this.attr( 'data-challenge-id' ),
4646 'size': 45
4747 } ).val( $this.attr( 'data-challenge-title' ) );
48 -
49 - $this.append(
 48+
 49+ $this.append(
5050 $( '<div />' ).html(
5151 $( '<label />' )
5252 .text( mw.msg( 'contest-edit-challenge-title' ) )
5353 .attr( 'for', 'contest-challenge-' + $this.attr( 'data-challenge-id' ) )
5454 ).append( '&#160;' ).append( this.titleInput )
5555 );
56 -
 56+
5757 this.onelineInput = $( '<input />' ).attr( {
5858 'type': 'text',
5959 'name': 'challenge-oneline-' + $this.attr( 'data-challenge-id' ),
6060 'size': 45,
6161 'style': 'margin-top: 3px'
6262 } ).val( $this.attr( 'data-challenge-oneline' ) );
63 -
64 - $this.append(
 63+
 64+ $this.append(
6565 $( '<div />' ).html(
6666 $( '<label />' )
6767 .text( mw.msg( 'contest-edit-challenge-oneline' ) )
6868 .attr( { 'for': 'contest-oneline-' + $this.attr( 'data-challenge-id' ) } )
6969 ).append( '&#160;' ).append( this.onelineInput )
7070 );
71 -
 71+
7272 this.textInput = $( '<textarea />' ).attr( {
7373 'name': 'challenge-text-' + $this.attr( 'data-challenge-id' )
7474 } ).val( $this.attr( 'data-challenge-text' ) );
75 -
76 - $this.append(
 75+
 76+ $this.append(
7777 $( '<div />' ).html(
7878 $( '<label />' )
7979 .text( mw.msg( 'contest-edit-challenge-text' ) )
8080 .attr( 'for', 'challenge-text-' + $this.attr( 'data-challenge-id' ) )
8181 ).append( '<br />' ).append( this.textInput )
8282 );
83 -
 83+
8484 this.deleteButton = $( '<button />' )
8585 .button( { 'label': mw.msg( 'contest-edit-delete' ) } )
8686 .click( function() {
@@ -88,23 +88,23 @@
8989 return false;
9090 }
9191 } );
92 -
 92+
9393 $this.append( this.deleteButton );
9494 };
95 -
 95+
9696 this.init();
97 -
 97+
9898 return this;
99 -
 99+
100100 };
101 -
 101+
102102 var newNr = 0;
103103 var $table = null;
104 -
 104+
105105 function getNewChallengeMessage() {
106106 return mw.msg( 'contest-edit-add-' + ( $( '.contest-challenge-input' ).size() === 0 ? 'first' : 'another' ) );
107107 }
108 -
 108+
109109 function addChallenge( challenge ) {
110110 $challenge = $( '<div />' ).attr( {
111111 'class': 'contest-challenge-input',
@@ -113,46 +113,46 @@
114114 'data-challenge-text': challenge.text,
115115 'data-challenge-oneline': challenge.oneline
116116 } );
117 -
 117+
118118 $tr = $( '<tr />' );
119 -
 119+
120120 $tr.append( $( '<td />' ) );
121 -
 121+
122122 $tr.append( $( '<td />' ).html( $challenge ).append( '<hr />' ) );
123 -
 123+
124124 $( '.add-new-challenge' ).before( $tr );
125 -
 125+
126126 $challenge.mwChallenge();
127127 }
128 -
 128+
129129 $( document ).ready( function() {
130130
131131 $( '#cancelEdit' ).click( function() {
132132 window.location = $( this ).attr( 'target-url' );
133133 } );
134 -
 134+
135135 $table = $( '#contest-name-field' ).closest( 'tbody' );
136 -
 136+
137137 $( '#bodyContent' ).find( '[type="submit"]' ).button();
138 -
 138+
139139 $table.append( '<tr><td colspan="2"><hr /></td></tr>' );
140 -
 140+
141141 $addNew = $( '<button />' ).button( { 'label': getNewChallengeMessage() } ).click( function() {
142142 addChallenge( {
143143 'id': 'new-' + newNr++ ,
144144 'title': '',
145145 'text': ''
146146 } );
147 -
 147+
148148 $( this ).button( { 'label': getNewChallengeMessage() } );
149 -
 149+
150150 return false;
151151 } );
152 -
 152+
153153 $table.append( $( '<tr />' ).attr( 'class', 'add-new-challenge' ).html( $( '<td />' ) ).append( $( '<td />' ).html( $addNew ) ) );
154 -
 154+
155155 $table.append( '<tr><td colspan="2"><hr /></td></tr>' );
156 -
 156+
157157 $( '.contest-challenge' ).each( function( index, domElement ) {
158158 $this = $( domElement );
159159 addChallenge( {
@@ -162,12 +162,12 @@
163163 'oneline': $this.attr( 'data-challenge-oneline' ),
164164 } );
165165 } );
166 -
 166+
167167 $( '#contest-edit-end' ).datetimepicker( {
168168 minDate: new Date(),
169169 dateFormat: 'yy-mm-dd'
170170 } );
171 -
 171+
172172 } );
173 -
 173+
174174 })( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Contest/resources/contest.special.signup.js
@@ -1,30 +1,30 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw ) {
11 -
 10+(function( $, mw ) {
 11+
1212 $( document ).ready( function() {
1313
1414 var contestConfig = mw.config.get( 'ContestConfig' );
15 -
 15+
1616 $( '.mw-htmlform-submit' ).button();
17 -
 17+
1818 $rules = $( '#contest-rules' );
19 -
 19+
2020 $div = $( '<div />' ).attr( {
2121 'style': 'display:none'
2222 } ).html( $( '<div />' ).attr( { 'id': 'contest-rules-div' } ).html( contestConfig['rules_page'] ) );
23 -
 23+
2424 $a = $( "label[for='contest-rules']" ).find( 'a' );
2525 $a.attr( { 'href': '#contest-rules-div' } );
26 -
 26+
2727 $rules.closest( 'td' ).append( $div );
28 -
 28+
2929 $a.fancybox( {
3030 'width' : '85%',
3131 'height' : '85%',
@@ -33,7 +33,7 @@
3434 'type' : 'inline',
3535 'autoDimensions': false
3636 } );
37 -
 37+
3838 } );
3939
4040 })( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Contest/resources/jquery.contestChallenges.js
@@ -1,21 +1,21 @@
22 /**
33 * JavasSript for the Contest MediaWiki extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Contest
5 - *
 5+ *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
1010 ( function ( $, mw ) { $.fn.contestChallenges = function( challenges, config ) {
11 -
 11+
1212 this.challenges = challenges;
1313 this.config = config;
14 -
 14+
1515 var _this = this;
1616 var $this = $( this );
17 -
 17+
1818 this.challengesList = null;
19 -
 19+
2020 this.addChallenge = function( challenge ) {
2121 this.challengesList
2222 .append(
@@ -76,25 +76,25 @@
7777 )
7878 );
7979 }
80 -
 80+
8181 this.initChallenges = function() {
8282 this.challengesList = $( '<ul />' ).attr( 'id', 'contest-challenges-list' );
83 -
 83+
8484 for ( var i in this.challenges ) {
8585 this.addChallenge( this.challenges[i] );
8686 }
8787 };
88 -
 88+
8989 this.init = function() {
9090 $this.html( $( '<h3 />' ).text( mw.msg( 'contest-welcome-select-header' ) ) );
91 -
 91+
9292 this.initChallenges();
93 -
 93+
9494 $this.append( this.challengesList );
9595 };
96 -
 96+
9797 this.init();
98 -
 98+
9999 return this;
100 -
 100+
101101 }; } )( window.jQuery, window.mediaWiki );

Status & tagging log