r81053 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81052‎ | r81053 | r81054 >
Date:21:54, 26 January 2011
Author:catrope
Status:deferred
Tags:
Comment:
ArticleFeedback: Various JS style thingies
Modified paths:
  • /trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -76,10 +76,10 @@
7777
7878 // Build data from form values
7979 var data = {};
80 - for ( key in context.options.ratings ) {
 80+ for ( var key in context.options.ratings ) {
8181 var id = context.options.ratings[key].id;
8282 // Default to 0 if the radio set doesn't contain a checked element
83 - data['r' + id] = context.$ui.find( 'input[name=r' + id + ']:checked' ).val() | 0;
 83+ data['r' + id] = context.$ui.find( 'input[name=r' + id + ']:checked' ).val() || 0;
8484 }
8585 $.ajax( {
8686 'url': mw.config.get( 'wgScriptPath' ) + '/api.php',
@@ -117,11 +117,11 @@
118118 'list': 'articlefeedback',
119119 'afpageid': mw.config.get( 'wgArticleId' ),
120120 'afanontoken': mw.user.id(),
121 - 'afuserrating': mw.user.id()
 121+ 'afuserrating': 1
122122 },
123123 'success': function( data ) {
124124 var context = this;
125 - if ( typeof data.query.articlefeedback == undefined ) {
 125+ if ( typeof data.query.articlefeedback == 'undefined' ) {
126126 // TODO: Something more clever, and useful, about this error
127127 mw.log( '<loadReport success with bad data />' );
128128 return;
@@ -160,7 +160,7 @@
161161 var average = ratingData.total / ratingData.count;
162162 $(this)
163163 .find( '.articleFeedback-rating-average' )
164 - .text( ( average - ( average % 1 ) ) + '.' +
 164+ .text( Math.floor( average ) + '.' +
165165 Math.round( ( average % 1 ) * 10 ) )
166166 .end()
167167 .find( '.articleFeedback-rating-meter div' )
@@ -194,7 +194,7 @@
195195 .append( $.articleFeedback.tpl.ui )
196196 .find( '.articleFeedback-ratings' )
197197 .each( function() {
198 - for ( key in context.options.ratings ) {
 198+ for ( var key in context.options.ratings ) {
199199 $( $.articleFeedback.tpl.rating )
200200 .attr( 'rel', key )
201201 .find( '.articleFeedback-label' )
@@ -206,7 +206,7 @@
207207 } )
208208 .end()
209209 .each( function() {
210 - for ( key in context.options.pitches ) {
 210+ for ( var key in context.options.pitches ) {
211211 $( $.articleFeedback.tpl.pitch )
212212 .attr( 'rel', key )
213213 .find( '.articleFeedback-title' )
@@ -248,7 +248,7 @@
249249 .button()
250250 .click( function() {
251251 $.articleFeedback.fn.submit.call( context );
252 - for ( key in context.options.pitches ) {
 252+ for ( var key in context.options.pitches ) {
253253 if ( context.options.pitches[key].condition() ) {
254254 context.$ui
255255 .find( '.articleFeedback-pitch[rel="' + key + '"]' )
@@ -266,7 +266,7 @@
267267 .find( '.articleFeedback-rating' )
268268 .each( function( rating ) {
269269 var rel = $(this).attr( 'rel' );
270 - var id = 'articleFeedback-rating-field-' + $(this).attr( 'rel' ) + '-';
 270+ var id = 'articleFeedback-rating-field-' + rel + '-';
271271 $(this)
272272 .find( '.articleFeedback-rating-fields input' )
273273 .attr( 'name', rel )
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
@@ -30,11 +30,11 @@
3131 'pitches': {
3232 'takesurvey': {
3333 'condition': function() {
34 - // If already taken survey, return false
 34+ // TODO: If already taken survey, return false
3535 return true;
3636 },
3737 'action': function() {
38 - // Do something
 38+ // TODO: Do something
3939 },
4040 'title': 'articlefeedback-pitch-takesurvey-title',
4141 'message': 'articlefeedback-pitch-takesurvey-message',
@@ -44,13 +44,10 @@
4545 'createaccount': {
4646 'condition': function() {
4747 // If user is logged in, return false
48 - if ( !mediaWiki.user.anonymous() ) {
49 - return false;
50 - }
51 - return true;
 48+ return mediaWiki.user.anonymous();
5249 },
5350 'action': function() {
54 - // Do something
 51+ // TODO: Do something
5552 },
5653 'title': 'articlefeedback-pitch-createaccount-title',
5754 'message': 'articlefeedback-pitch-createaccount-message',
@@ -60,13 +57,10 @@
6158 'makefirstedit': {
6259 'condition': function() {
6360 // If user is not logged in, return false
64 - if ( mediaWiki.user.anonymous() ) {
65 - return false;
66 - }
67 - return true;
 61+ return !mediaWiki.user.anonymous();
6862 },
6963 'action': function() {
70 - // Do something
 64+ // TODO: Do something
7165 },
7266 'title': 'articlefeedback-pitch-makefirstedit-title',
7367 'message': 'articlefeedback-pitch-makefirstedit-message',

Status & tagging log