r108258 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108257‎ | r108258 | r108259 >
Date:17:33, 6 January 2012
Author:rsterbin
Status:ok (Comments)
Tags:
Comment:
Added documentation and fold markers to the special page js
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -1,14 +1,76 @@
 2+/**
 3+ * ArticleFeedback special page
 4+ *
 5+ * This file handles the display of feedback responses and moderation tools for
 6+ * privileged users. The flow goes like this:
 7+ *
 8+ * User arrives at special page -> basic markup is created without data -> ajax
 9+ * request is sent to pull most recent feedback
 10+ *
 11+ * For each change to the selected filter or sort method, or when more feedback
 12+ * is requested, another ajax request is sent.
 13+ *
 14+ * This file is long, so it's commented with manual fold markers. To use folds
 15+ * this way in vim:
 16+ * set foldmethod=marker
 17+ * set foldlevel=0
 18+ * set foldcolumn=0
 19+ *
 20+ * @package ArticleFeedback
 21+ * @subpackage Resources
 22+ * @author Greg Chiasson <gchiasson@omniti.com>
 23+ * @version $Id$
 24+ */
 25+
226 ( function ( $ ) {
 27+
 28+// {{{ articleFeedbackv5 definition
 29+
330 $.articleFeedbackv5special = {};
431
5 - $.articleFeedbackv5special.page = undefined;
6 - $.articleFeedbackv5special.filter = 'visible';
7 - $.articleFeedbackv5special.sort = 'newest';
8 - $.articleFeedbackv5special.limit = 25;
9 - $.articleFeedbackv5special.offset = 0;
 32+ // {{{ Properties
 33+
 34+ /**
 35+ * What page is this?
 36+ */
 37+ $.articleFeedbackv5special.page = undefined;
 38+
 39+ /**
 40+ * The name of the filter used to select feedback
 41+ */
 42+ $.articleFeedbackv5special.filter = 'visible';
 43+
 44+ /**
 45+ * The name of the sorting method used
 46+ */
 47+ $.articleFeedbackv5special.sort = 'newest';
 48+
 49+ /**
 50+ * The number of responses to display per data pull
 51+ */
 52+ $.articleFeedbackv5special.limit = 25;
 53+
 54+ /**
 55+ * The index at which to start the pull
 56+ */
 57+ $.articleFeedbackv5special.offset = 0;
 58+
 59+ /**
 60+ * ???
 61+ */
1062 $.articleFeedbackv5special.showing = 0;
11 - $.articleFeedbackv5special.apiUrl = undefined;
1263
 64+ /**
 65+ * The url to which to send the request
 66+ */
 67+ $.articleFeedbackv5special.apiUrl = undefined;
 68+
 69+ // }}}
 70+ // {{{ Init methods
 71+
 72+ /**
 73+ * Binds events for each of the controls
 74+ */
1375 $.articleFeedbackv5special.setBinds = function() {
1476 $( '#aft5-filter' ).bind( 'change', function(e) {
1577 $.articleFeedbackv5special.filter = $(this).val();
@@ -38,14 +100,41 @@
39101 } );
40102 }
41103
 104+ // }}}
 105+ // {{{ Moderation methods
 106+
 107+ // {{{ hideFeedback
 108+
 109+ /**
 110+ * Hides a response
 111+ *
 112+ * @param id int the feedback id
 113+ */
42114 $.articleFeedbackv5special.hideFeedback = function ( id ) {
43115 $.articleFeedbackv5special.flagFeedback( id, 'hide' );
44116 }
45117
 118+ // }}}
 119+ // {{{ abuseFeedback
 120+
 121+ /**
 122+ * Flags a response as abuse
 123+ *
 124+ * @param id int the feedback id
 125+ */
46126 $.articleFeedbackv5special.abuseFeedback = function ( id ) {
47127 $.articleFeedbackv5special.flagFeedback( id, 'abuse' );
48128 }
49129
 130+ // }}}
 131+ // {{{ flagFeedback
 132+
 133+ /**
 134+ * Sends the request to mark a response
 135+ *
 136+ * @param id int the feedback id
 137+ * @param type string the type of mark ('hide' or 'abuse')
 138+ */
50139 $.articleFeedbackv5special.flagFeedback = function ( id, type ) {
51140 $.ajax( {
52141 'url' : $.articleFeedbackv5special.apiUrl,
@@ -77,8 +166,20 @@
78167 return false;
79168 }
80169
81 - // ie, on loading next page, don't reset the view, but on sort/filter
82 - // remove what was there and start over.
 170+ // }}}
 171+
 172+ // }}}
 173+ // {{{ Process methods
 174+
 175+ // {{{ loadFeedback
 176+
 177+ /**
 178+ * Pulls in a set of responses.
 179+ *
 180+ * When a next-page load is requested, it appends the new responses; on a
 181+ * sort or filter change, the existing responses are removed from the view
 182+ * and replaced.
 183+ */
83184 $.articleFeedbackv5special.loadFeedback = function ( resetContents ) {
84185 $.ajax( {
85186 'url' : $.articleFeedbackv5special.apiUrl,
@@ -121,9 +222,19 @@
122223
123224 return false;
124225 }
 226+
 227+ // }}}
 228+
 229+ // }}}
 230+
 231+// }}}
 232+
125233 } )( jQuery );
126234
127235 $( document ).ready( function() {
 236+
 237+// {{{ Kick off when ready
 238+
128239 // This was failing sometimes when it was in the function above.
129240 // I think it maky have been a race condition.
130241 $.articleFeedbackv5special.apiUrl = mw.util.wikiScript('api');
@@ -132,4 +243,8 @@
133244 // Set up event binds and do initial data fetch.
134245 $.articleFeedbackv5special.setBinds();
135246 $.articleFeedbackv5special.loadFeedback( true );
 247+
 248+// }}}
 249+
136250 } );
 251+

Comments

#Comment by Nikerabbit (talk | contribs)   10:10, 7 January 2012

You need to set svn:keywords to have that $Id$ work.

#Comment by Rsterbin (talk | contribs)   18:32, 10 January 2012

Blargh. It's set in my subversion config autoprops, it just doesn't seem to be working. Guess I'll have to poke at it some more and see if I can get it working again.

Status & tagging log