Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -76,10 +76,10 @@ |
77 | 77 | |
78 | 78 | // Build data from form values |
79 | 79 | var data = {}; |
80 | | - for ( key in context.options.ratings ) { |
| 80 | + for ( var key in context.options.ratings ) { |
81 | 81 | var id = context.options.ratings[key].id; |
82 | 82 | // 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; |
84 | 84 | } |
85 | 85 | $.ajax( { |
86 | 86 | 'url': mw.config.get( 'wgScriptPath' ) + '/api.php', |
— | — | @@ -117,11 +117,11 @@ |
118 | 118 | 'list': 'articlefeedback', |
119 | 119 | 'afpageid': mw.config.get( 'wgArticleId' ), |
120 | 120 | 'afanontoken': mw.user.id(), |
121 | | - 'afuserrating': mw.user.id() |
| 121 | + 'afuserrating': 1 |
122 | 122 | }, |
123 | 123 | 'success': function( data ) { |
124 | 124 | var context = this; |
125 | | - if ( typeof data.query.articlefeedback == undefined ) { |
| 125 | + if ( typeof data.query.articlefeedback == 'undefined' ) { |
126 | 126 | // TODO: Something more clever, and useful, about this error |
127 | 127 | mw.log( '<loadReport success with bad data />' ); |
128 | 128 | return; |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | var average = ratingData.total / ratingData.count; |
162 | 162 | $(this) |
163 | 163 | .find( '.articleFeedback-rating-average' ) |
164 | | - .text( ( average - ( average % 1 ) ) + '.' + |
| 164 | + .text( Math.floor( average ) + '.' + |
165 | 165 | Math.round( ( average % 1 ) * 10 ) ) |
166 | 166 | .end() |
167 | 167 | .find( '.articleFeedback-rating-meter div' ) |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | .append( $.articleFeedback.tpl.ui ) |
196 | 196 | .find( '.articleFeedback-ratings' ) |
197 | 197 | .each( function() { |
198 | | - for ( key in context.options.ratings ) { |
| 198 | + for ( var key in context.options.ratings ) { |
199 | 199 | $( $.articleFeedback.tpl.rating ) |
200 | 200 | .attr( 'rel', key ) |
201 | 201 | .find( '.articleFeedback-label' ) |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | } ) |
208 | 208 | .end() |
209 | 209 | .each( function() { |
210 | | - for ( key in context.options.pitches ) { |
| 210 | + for ( var key in context.options.pitches ) { |
211 | 211 | $( $.articleFeedback.tpl.pitch ) |
212 | 212 | .attr( 'rel', key ) |
213 | 213 | .find( '.articleFeedback-title' ) |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | .button() |
250 | 250 | .click( function() { |
251 | 251 | $.articleFeedback.fn.submit.call( context ); |
252 | | - for ( key in context.options.pitches ) { |
| 252 | + for ( var key in context.options.pitches ) { |
253 | 253 | if ( context.options.pitches[key].condition() ) { |
254 | 254 | context.$ui |
255 | 255 | .find( '.articleFeedback-pitch[rel="' + key + '"]' ) |
— | — | @@ -266,7 +266,7 @@ |
267 | 267 | .find( '.articleFeedback-rating' ) |
268 | 268 | .each( function( rating ) { |
269 | 269 | var rel = $(this).attr( 'rel' ); |
270 | | - var id = 'articleFeedback-rating-field-' + $(this).attr( 'rel' ) + '-'; |
| 270 | + var id = 'articleFeedback-rating-field-' + rel + '-'; |
271 | 271 | $(this) |
272 | 272 | .find( '.articleFeedback-rating-fields input' ) |
273 | 273 | .attr( 'name', rel ) |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -30,11 +30,11 @@ |
31 | 31 | 'pitches': { |
32 | 32 | 'takesurvey': { |
33 | 33 | 'condition': function() { |
34 | | - // If already taken survey, return false |
| 34 | + // TODO: If already taken survey, return false |
35 | 35 | return true; |
36 | 36 | }, |
37 | 37 | 'action': function() { |
38 | | - // Do something |
| 38 | + // TODO: Do something |
39 | 39 | }, |
40 | 40 | 'title': 'articlefeedback-pitch-takesurvey-title', |
41 | 41 | 'message': 'articlefeedback-pitch-takesurvey-message', |
— | — | @@ -44,13 +44,10 @@ |
45 | 45 | 'createaccount': { |
46 | 46 | 'condition': function() { |
47 | 47 | // If user is logged in, return false |
48 | | - if ( !mediaWiki.user.anonymous() ) { |
49 | | - return false; |
50 | | - } |
51 | | - return true; |
| 48 | + return mediaWiki.user.anonymous(); |
52 | 49 | }, |
53 | 50 | 'action': function() { |
54 | | - // Do something |
| 51 | + // TODO: Do something |
55 | 52 | }, |
56 | 53 | 'title': 'articlefeedback-pitch-createaccount-title', |
57 | 54 | 'message': 'articlefeedback-pitch-createaccount-message', |
— | — | @@ -60,13 +57,10 @@ |
61 | 58 | 'makefirstedit': { |
62 | 59 | 'condition': function() { |
63 | 60 | // 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(); |
68 | 62 | }, |
69 | 63 | 'action': function() { |
70 | | - // Do something |
| 64 | + // TODO: Do something |
71 | 65 | }, |
72 | 66 | 'title': 'articlefeedback-pitch-makefirstedit-title', |
73 | 67 | 'message': 'articlefeedback-pitch-makefirstedit-message', |