r113896 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113895‎ | r113896 | r113897 >
Date:07:46, 15 March 2012
Author:wikinaut
Status:new
Tags:
Comment:
code cosmetics. jquery improvements.
Modified paths:
  • /trunk/extensions/AJAXPoll/AJAXPoll.php (modified) (history)
  • /trunk/extensions/AJAXPoll/AJAXPoll_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AJAXPoll/AJAXPoll_body.php
@@ -321,11 +321,14 @@
322322 for ( $i = 1; $i < count( $lines ); $i++ ) {
323323
324324 $vote = !( $canRevoke && ( $i == count( $lines ) - 1 ) );
325 - $voteValue = ( $vote ) ? $i : 0;
326325
327 - $ans_no = $i - 1;
328 - $xid = "$id-$ans_no";
 326+ // answers are counted from 1 ... n
 327+ // last answer is pseudo-answer for "I want to revoke vote"
 328+ // and becomes answer number 0
329329
 330+ $answer = ( $vote ) ? $i : 0;
 331+ $xid = $id . "-" . $answer;
 332+
330333 if ( $amountOfVotes == 0 ) {
331334 $percent = 0;
332335 } else {
@@ -341,7 +344,7 @@
342345 if ( $wgUser->isAllowed( 'ajaxpoll-vote' ) ) {
343346
344347 if ( $wgUseAjax ) {
345 - $submitJS = "sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $voteValue . "\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);";
 348+ $submitJS = "sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $answer . "\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);";
346349 } else {
347350 $submitJS = "$(\"#ajaxpoll-answer-id-" . $id . "\").submit();";
348351 }
@@ -352,13 +355,13 @@
353356
354357 if ( $vote ) {
355358 $ret .= "
356 -<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\");$(\"#ajaxpoll-ajax-" . $id . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true); " . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $voteValue . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) .
 359+<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $xid . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true);" . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $answer . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) .
357360 "</label></div><div class='ajaxpoll-answer-vote" . ( $our ? ' ajaxpoll-our-vote' : '' ) ."'><span title='" . wfMsg( 'ajaxpoll-percent-votes', sprintf( $percent ) ) . "'>" . ( ( isset( $poll_result ) && !empty( $poll_result[$i + 1] ) ) ? $poll_result[$i + 1] : 0 ) . "</span><div style='width: " . $percent . "%;" . ( $percent == 0 ? ' border:0;' : '' ) . "'></div></div>
358361 </div>
359362 ";
360363 } else {
361364 $ret .= "
362 -<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name ajaxpoll-answer-name-revoke'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\");$(\"#ajaxpoll-ajax-" . $id . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true); " . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $voteValue . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) .
 365+<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name ajaxpoll-answer-name-revoke'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $xid . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true);" . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $answer . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) .
363366 "</label></div>
364367 </div>
365368 ";
@@ -367,7 +370,7 @@
368371 } else {
369372
370373 $ret .= "
371 -<div id='ajaxpoll-answer-" . $id . "' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $id . "' onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg( 'ajaxpoll-vote-permission' ) . "\");$(\"#ajaxpoll-ajax-" . $id . "\").css(\"display\",\"block\");'><input disabled='disabled' type='radio' id='ajaxpoll-post-answer-" . $id . "' name='ajaxpoll-post-answer-" . $id . "' value='" . $voteValue . "'/>" . strip_tags( $lines[$i] ) .
 374+<div id='ajaxpoll-answer-" . $xid . "' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $xid . "' onclick='$(\"#ajaxpoll-ajax-" . $xid . "\").html(\"" . wfMsg( 'ajaxpoll-vote-permission' ) . "\").css(\"display\",\"block\");'><input disabled='disabled' type='radio' id='ajaxpoll-post-answer-" . $xid . "' name='ajaxpoll-post-answer-" . $xid . "' value='" . $answer . "'/>" . strip_tags( $lines[$i] ) .
372375 "</label></div><div class='ajaxpoll-answer-vote" . ( $our ? ' ajaxpoll-our-vote' : '' ) ."'><span title='" . wfMsg( 'ajaxpoll-percent-votes', sprintf( $percent ) ) . "'>" . ( ( isset( $poll_result ) && !empty( $poll_result[$i + 1] ) ) ? $poll_result[$i + 1] : 0 ) . "</span><div style='width: " . $percent . "%;" . ( $percent == 0 ? ' border:0;' : '' ) . "'></div></div>
373376 </div>
374377 ";
Index: trunk/extensions/AJAXPoll/AJAXPoll.php
@@ -19,7 +19,7 @@
2020 * @author Jack Phoenix <jack@countervandalism.net>
2121 * @author Thomas Gries
2222 * @maintainer Thomas Gries
23 - * @version 1.73
 23+ * @version 1.74
2424 * @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation
2525 */
2626
@@ -31,7 +31,7 @@
3232 $wgExtensionCredits['parserhook'][] = array(
3333 'path' => __FILE__,
3434 'name' => 'AJAX Poll',
35 - 'version' => '1.73 20120314',
 35+ 'version' => '1.74 20120315',
3636 'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries' ),
3737 'descriptionmsg' => 'ajaxpoll-desc',
3838 'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll',

Status & tagging log