Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59387


Change subject: (bug 44827) Show amount of remaining characters for 
moderation-note
......................................................................

(bug 44827) Show amount of remaining characters for moderation-note

Feedback form had "countdown" function already. Pulled it out of there into
aftUtils and started using it for adding notes in the Special page (after
moderating feedback) too, to show that the field will not accept more than 250
characters.

Bug: 44827
Change-Id: I037efdb4ebf1bbb277cb675ff1d02ca05c9da2ea
---
M ArticleFeedbackv5.i18n.php
M ArticleFeedbackv5.php
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
6 files changed, 287 insertions(+), 265 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5 
refs/changes/87/59387/1

diff --git a/ArticleFeedbackv5.i18n.php b/ArticleFeedbackv5.i18n.php
index ab635a3..d7505da 100644
--- a/ArticleFeedbackv5.i18n.php
+++ b/ArticleFeedbackv5.i18n.php
@@ -559,7 +559,6 @@
        'articlefeedbackv5-bucket6-toggle-found-no' => 'No',
        'articlefeedbackv5-bucket6-toggle-found-yes-full' => 'Yes, I found what 
I was looking for.',
        'articlefeedbackv5-bucket6-toggle-found-no-full' => 'No, I did not find 
what I was looking for.',
-       'articlefeedbackv5-bucket6-feedback-countdown' => '{{PLURAL:$1|(1 
character remaining)|($1 characters remaining)}}',
        'articlefeedbackv5-bucket6-question-instructions-yes' => 'Great. Any 
suggestion for improvement?',
        'articlefeedbackv5-bucket6-question-placeholder-yes' => 'Write your 
suggestion here (e.g.: \'This page needs a picture\')',
        'articlefeedbackv5-bucket6-question-instructions-no' => 'Sorry about 
that. Any suggestion for improvement?',
@@ -705,6 +704,9 @@
        'articlefeedbackv5-disable-flyover-help-emphasis-text' => 'Article 
Feedback',
        'articlefeedbackv5-disable-flyover-help-location' => 'My preferences > 
Appearance',
        'articlefeedbackv5-disable-flyover-prefbutton' => 'Go to my 
preferences',
+
+       /* "X characters remaining" countdown message */
+       'articlefeedbackv5-countdown' => '{{PLURAL:$1|(1 character 
remaining)|($1 characters remaining)}}',
 
        /* Custom AbuseFilter actions */
        'abusefilter-edit-action-aftv5flagabuse' => '(Article Feedback) 
Auto-flag as abuse',
@@ -1583,7 +1585,6 @@
 {{Identical|No}}',
        'articlefeedbackv5-bucket6-toggle-found-yes-full' => 'This is the text 
that appears when you roll over the yes button in option 1 ("Did you find what 
you were looking for?"); it clarifies what "yes" means in this context.',
        'articlefeedbackv5-bucket6-toggle-found-no-full' => 'This is the text 
that appears when you roll over the no button in option 1 ("Did you find what 
you were looking for?"); it clarifies what "no" means in this context.',
-       'articlefeedbackv5-bucket6-feedback-countdown' => 'This displays a 
countdown of the amount of characters feedback that will be allowed. $1 
contains the amount of characters (number) remaining before none more are 
accepted.',
        'articlefeedbackv5-bucket6-question-instructions-yes' => 'This is the 
instructional text to be shown above the textarea where a user can leave 
feedback, to be shown when the user selected yes',
        'articlefeedbackv5-bucket6-question-placeholder-yes' => 'This is the 
grey default text that appears in the comment box when the yes button has been 
selected in option 1 {{msg-mw|Articlefeedbackv5-bucket1-question-toggle}}.',
        'articlefeedbackv5-bucket6-question-instructions-no' => 'This is the 
instructional text to be shown above the textarea where a user can leave 
feedback, to be shown when the user selected no',
@@ -2073,6 +2074,8 @@
 
 It must be: {{msg-mw|mypreferences}} > {{msg-mw|prefs-rendering}}',
        'articlefeedbackv5-disable-flyover-prefbutton' => 'The text of the big 
glossy button used to send the user to their preferences in the tooltip that 
pops up when you click the close button on a feedback trigger link, explaining 
how to remove the Article Feedback tool',
+       'articlefeedbackv5-countdown' => 'This displays a countdown of the 
amount of characters feedback that will be allowed. Parameters:
+* $1 contains the amount of characters (number) remaining before none more are 
accepted.',
        'abusefilter-edit-action-aftv5flagabuse' => 'The text for the checkbox 
used by Special:AbuseFilter to indicate that a rule should result in the 
feedback being auto-flagged as abuse',
        'articlefeedbackv5-abusefilter-note-aftv5flagabuse' => 'The note to add 
to the activity log when auto-flagging a new feedback post as abuse 
(<code>$1</code> is the name of the filter)',
        'abusefilter-edit-action-aftv5hide' => 'The text for the checkbox used 
by Special:AbuseFilter to indicate that a rule should result in the feedback 
being auto-hidden',
diff --git a/ArticleFeedbackv5.php b/ArticleFeedbackv5.php
index 069159c..ee98e40 100644
--- a/ArticleFeedbackv5.php
+++ b/ArticleFeedbackv5.php
@@ -512,6 +512,9 @@
 );
 $wgResourceModules['jquery.articleFeedbackv5.utils'] = array(
        'scripts' => 
'jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js',
+       'messages' => array(
+               'articlefeedbackv5-countdown',
+       ),
        'dependencies' => array(
                'mediawiki.util',
                'mediawiki.user',
@@ -657,7 +660,6 @@
                'articlefeedbackv5-bucket6-toggle-found-yes-full',
                'articlefeedbackv5-bucket6-toggle-found-no',
                'articlefeedbackv5-bucket6-toggle-found-no-full',
-               'articlefeedbackv5-bucket6-feedback-countdown',
                'articlefeedbackv5-bucket6-question-instructions-yes',
                'articlefeedbackv5-bucket6-question-placeholder-yes',
                'articlefeedbackv5-bucket6-question-instructions-no',
diff --git a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js 
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
index 91169e8..91e655b 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -765,7 +765,9 @@
                                $( document )
                                        .on( 'keyup', 
'.articleFeedbackv5-comment textarea', function () {
                                                
$.articleFeedbackv5.unlockForm();
-                                               
$.articleFeedbackv5.currentBucket().countdown( $( this ) );
+
+                                               var maxLength = mw.config.get( 
'wgArticleFeedbackv5MaxCommentLength' );
+                                               $.aftUtils.countdown( $( this 
), $( '#articlefeedbackv5-feedback-countdown' ), maxLength, 500 );
                                        } );
 
                                // clicking the back-link on step 2 should show 
step 1 again
@@ -869,45 +871,6 @@
                                $backLink.text( mw.msg( 
'articlefeedbackv5-bucket6-backlink-text' ) );
                                $backLink.attr( 'title', mw.msg( 
'articlefeedbackv5-bucket6-backlink-text' ) );
                                $( '.articleFeedbackv5-title' ).before( 
$backLink );
-                       },
-
-                       // }}}
-                       // {{{ countdown
-
-                       /**
-                        * Character countdown
-                        *
-                        * Note: will not do server-side check: this is only 
used to encourage people to keep their
-                        * feedback concise, there's no technical reason not to 
allow more
-                        *
-                        * @param $element the form element to count the 
characters down for
-                        */
-                       countdown: function ( $element ) {
-                               var displayLength = 500;
-                               var maxLength = mw.config.get( 
'wgArticleFeedbackv5MaxCommentLength' );
-                               if ( maxLength == 0 ) {
-                                       return;
-                               }
-
-                               var $countdown = $( 
'#articlefeedbackv5-feedback-countdown' );
-
-                               // grab the current length of the form element 
(or set to 0 if the current text is bogus placeholder)
-                               var length = maxLength - $element.val().length;
-
-                               // display the amount of characters
-                               var message = mw.msg( 
'articlefeedbackv5-bucket6-feedback-countdown', length );
-                               $countdown.text( message );
-
-                               // remove excessive characters
-                               if ( length < 0 ) {
-                                       $element.val( $element.val().substr( 0, 
maxLength ) );
-                               }
-
-                               // only display the countdown for the last X 
characters
-                               $countdown.hide();
-                               if ( length < displayLength ) {
-                                       $countdown.show();
-                               }
                        }
 
                        // }}}
diff --git 
a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css 
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
index 856f185..d2d34ce 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
@@ -608,6 +608,12 @@
 form.articleFeedbackv5-form-flyover {
        padding: 0 25px 0 0;
 }
+form.articleFeedbackv5-form-flyover #articleFeedbackv5-noteflyover-countdown {
+       float: right;
+       font-size: 0.8em;
+       margin-right: -15px;
+       margin-bottom: 0;
+}
 form.articleFeedbackv5-form-flyover label {
        display: block;
        margin: 5px 10px;
diff --git 
a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js 
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
index 653d877..3b95c21 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -123,6 +123,7 @@
                </div>\
                <form class="articleFeedbackv5-form-flyover" action="#">\
                        <div 
id="articleFeedbackv5-noteflyover-description"></div>\
+                       <p id="articleFeedbackv5-noteflyover-countdown"></p>\
                        <label id="articleFeedbackv5-noteflyover-label" 
for="articleFeedbackv5-noteflyover-note"></label>\
                        <input type="text" 
id="articleFeedbackv5-noteflyover-note" 
name="articleFeedbackv5-noteflyover-note" maxlength="255" />\
                        <div class="articleFeedbackv5-flyover-footer">\
@@ -435,6 +436,12 @@
                        $.articleFeedbackv5special.currentPanelHostId = 
undefined;
                } );
 
+               // bind character countdown on flyover panels' input field
+               $( document ).on( 'keyup', 
'#articleFeedbackv5-noteflyover-note', function () {
+                       var maxLength = mw.config.get( 
'wgArticleFeedbackv5MaxCommentLength' );
+                       $.aftUtils.countdown( $( this ), $( 
'#articleFeedbackv5-noteflyover-countdown' ), 250 );
+               } );
+
                // bind short/long version toggle
                $( document ).on( 'click touchstart', 
'.articleFeedbackv5-comment-toggle', function( e ) {
                        e.preventDefault();
diff --git a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js 
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
index 55b11c4..91969fd 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
@@ -12,237 +12,278 @@
 
 ( function ( $ ) {
 
-// {{{ aftUtils definition
+       // {{{ aftUtils definition
 
-       $.aftUtils = {};
+       $.aftUtils = {
 
-       // }}}
-       // {{{ verify
+               // }}}
+               // {{{ verify
 
-       /**
-        * Runs verification
-        *
-        * @param  location string  the place from which this is being called
-        * @return bool     whether AFTv5 is enabled for this page
-        */
-       $.aftUtils.verify = function ( location ) {
-               // remove obsolete cookies
-               $.aftUtils.removeLegacyCookies();
+               /**
+                * Runs verification
+                *
+                * @param  location string  the place from which this is being 
called
+                * @return bool     whether AFTv5 is enabled for this page
+                */
+               verify: function ( location ) {
+                       // remove obsolete cookies
+                       $.aftUtils.removeLegacyCookies();
 
-               var article = mw.config.get( 'aftv5Article' );
+                       var article = mw.config.get( 'aftv5Article' );
 
-               // fetch data, on article level, we can fetch these from other 
sources as well
-               if ( location == 'article' ) {
-                       article.id = mw.config.get( 'wgArticleId', -1 );
-                       article.namespace = mw.config.get( 'wgNamespaceNumber' 
);
-                       article.categories = mw.config.get( 'wgCategories', [] 
);
+                       // fetch data, on article level, we can fetch these 
from other sources as well
+                       if ( location == 'article' ) {
+                               article.id = mw.config.get( 'wgArticleId', -1 );
+                               article.namespace = mw.config.get( 
'wgNamespaceNumber' );
+                               article.categories = mw.config.get( 
'wgCategories', [] );
+                       }
+
+
+                       var enable = true;
+
+                       // supported browser
+                       enable &= $.aftUtils.useragent();
+
+                       // if AFTv5 is not enabled on any namespace, it does 
not make sense to display it at all
+                       enable &= mw.config.get( 
'wgArticleFeedbackv5Namespaces', [] ).length > 0;
+
+                       if ( location != 'special' || article.id != 0 ) {
+                               // only on pages in namespaces where it is 
enabled
+                               enable &= $.inArray( article.namespace, 
mw.config.get( 'wgArticleFeedbackv5Namespaces', [] ) ) > -1;
+
+                               // it does not make sense to display AFT when a 
page is being edited ...
+                               enable &= mw.config.get( 'wgAction' ) != 'edit';
+
+                               // ... or has just been edited
+                               enable &= !mw.config.get( 'wgPostEdit', false );
+                       }
+
+                       // for special page, it doesn't matter if the article 
has AFT applied
+                       if ( location != 'special' ) {
+                               // check if user has the required permissions
+                               enable &= $.aftUtils.permissions( article );
+
+                               // category is not blacklisted
+                               enable &= !$.aftUtils.blacklist( article );
+
+                               // category is whitelisted or article is in 
lottery
+                               enable &= ( $.aftUtils.whitelist( article ) || 
$.aftUtils.lottery( article ) );
+                       }
+
+                       // stricter validation for article: make sure we're at 
the right article view
+                       if ( location == 'article' ) {
+                               // not disabled via preferences
+                               enable &= !mw.user.options.get( 
'articlefeedback-disable' );
+
+                               // view pages
+                               enable &= ( mw.config.get( 'wgAction' ) == 
'view' || mw.config.get( 'wgAction' ) == 'purge' );
+
+                               // if user is logged in, showing on 
action=purge is OK,
+                               // but if user is logged out, action=purge 
shows a form instead of the article,
+                               // so return false in that case.
+                               enable &= !( mw.config.get( 'wgAction' ) == 
'purge' && mw.user.anonymous() );
+
+                               // current revision
+                               enable &= mw.util.getParamValue( 'diff' ) == 
null;
+                               enable &= mw.util.getParamValue( 'oldid' ) == 
null;
+
+                               // not viewing a redirect
+                               enable &= mw.util.getParamValue( 'redirect' ) 
!= 'no';
+
+                               // not viewing the printable version
+                               enable &= mw.util.getParamValue( 'printable' ) 
!= 'yes';
+                       }
+
+                       return enable;
+               },
+
+               // }}}
+               // {{{ permissions
+
+               /**
+                * Check if the user is permitted to see the AFT feedback form
+                * on this particular page, as defined by its protection level
+                *
+                * @param object article
+                * @return bool
+                */
+               permissions: function ( article ) {
+                       var permissions = mw.config.get( 
'wgArticleFeedbackv5Permissions' );
+                       return article.permissionLevel in permissions && 
permissions[article.permissionLevel];
+               },
+
+               // }}}
+               // {{{ blacklist
+
+               /**
+                * Check if the article is blacklisted by intersecting the
+                * article's categories with the blacklisted categories
+                *
+                * Note: the .replace() makes sure that when blacklist category
+                * names are underscored, those are converted to spaces (cfr. 
category)
+                *
+                * @param object article
+                * @return bool
+                */
+               blacklist: function ( article ) {
+                       var blacklistCategories = mw.config.get( 
'wgArticleFeedbackv5BlacklistCategories', [] );
+                       var intersect = $.map( blacklistCategories, function( 
category ) {
+                               return $.inArray( category.replace(/_/g, ' '), 
article.categories ) < 0 ? null : category;
+                       } );
+                       return intersect.length > 0;
+               },
+
+               // }}}
+               // {{{ whitelist
+
+               /**
+                * Check if the article is whitelisted by intersecting the
+                * article's categories with the whitelisted categories
+                *
+                * Note: the .replace() makes sure that when whitelist category
+                * names are underscored, those are converted to spaces (cfr. 
category)
+                *
+                * @param object article
+                * @return bool
+                */
+               whitelist: function ( article ) {
+                       var whitelistCategories = mw.config.get( 
'wgArticleFeedbackv5Categories', [] );
+                       var intersect = $.map( whitelistCategories, function( 
category ) {
+                               return $.inArray( category.replace(/_/g, ' '), 
article.categories ) < 0 ? null : category;
+                       } );
+                       return intersect.length > 0;
+               },
+
+               // }}}
+               // {{{ lottery
+
+               /**
+                * Check if an article is eligible for AFT through the lottery
+                *
+                * Note: odds can either be a plain integer (0-100), or be 
defined per namespace
+                * (0-100 per namespace key)
+                *
+                * @param object article
+                * @return bool
+                */
+               lottery: function ( article ) {
+                       var odds = mw.config.get( 
'wgArticleFeedbackv5LotteryOdds', 0 );
+                       if ( typeof odds === 'object' && article.namespace in 
odds ) {
+                               odds = odds[article.namespace];
+                       }
+
+                       return ( Number( article.id ) % 1000 ) >= ( 1000 - ( 
Number( odds ) * 10 ) );
+               },
+
+               // }}}
+               // {{{ useragent
+
+               /**
+                * Check if the browser is supported
+                *
+                * @return bool
+                */
+               useragent: function () {
+                       var ua = navigator.userAgent.toLowerCase();
+
+                       // Rule out MSIE 6, FF2, Android
+                       return !(
+                               ua.indexOf( 'msie 6' ) != -1 ||
+                                       ua.indexOf( 'firefox/2.') != -1 ||
+                                       ua.indexOf( 'firefox 2.') != -1 ||
+                                       ua.indexOf( 'android' ) != -1
+                               );
+               },
+
+               // }}}
+               // {{{ getCookieName
+
+               /**
+                * Get the full, prefixed, name that data is saved at in cookie.
+                * The cookie name is prefixed by the extension name and a 
version number,
+                * to avoid collisions with other extensions or code versions.
+                *
+                * @param string $suffix
+                * @return string
+                */
+               getCookieName: function ( suffix ) {
+                       return 'AFTv5-' + suffix;
+               },
+
+               // }}}
+               // {{{ removeLegacyCookies
+
+               /**
+                * Before the current getCookieName() function, cookie names 
were:
+                * * really long
+                * * incorrect using the tracking version number to 
differentiate JS/cookie versions
+                * * not being prefixed by wgCookiePrefix
+                *
+                * These issues have since been fixed, but this will make sure 
that lingering old
+                * cookie are cleaned up. This function will not merge the old 
cookies to the new
+                * cookie name though.
+                *
+                * @deprecated Function is only intended to bridge a temporary 
"gap" while old
+                *             data persists in cookie. After awhile, cookies 
have either expired
+                *             by themselves or this will have cleaned them up, 
so this function
+                *             (and where it's being called) can be cleaned up 
at will.
+                */
+               removeLegacyCookies: function () {
+                       // old cookie names
+                       var legacyCookieName = function( suffix ) {
+                               return 'ext.articleFeedbackv5@11-' + suffix;
+                       }
+
+                       // remove old cookie names
+                       $.cookie( legacyCookieName( 'activity' ), null, { 
expires: -1, path: '/' } );
+                       $.cookie( legacyCookieName( 'last-filter' ), null, { 
expires: -1, path: '/' } );
+                       $.cookie( legacyCookieName( 'submission_timestamps' ), 
null, { expires: -1, path: '/' } );
+                       $.cookie( legacyCookieName( 'feedback-ids' ), null, { 
expires: -1, path: '/' } );
+               },
+
+               // }}}
+               // {{{ countdown
+
+               /**
+                * Character countdown
+                *
+                * Note: will not do server-side check: this is only used to 
encourage people to keep their
+                * feedback concise, there's no technical reason not to allow 
more
+                *
+                * @param jQuery $element the form element to count the 
characters down for
+                * @param jQuery $text the dom element to insert the countdown 
text in
+                * @param int amount the amount of characters to count down from
+                * @param int[optional] displayLength the amount of remaining 
characters to start displaying
+                *        the countdown from (no value = always show)
+                */
+               countdown: function ( $element, $text, amount, displayLength ) {
+                       if ( !amount ) {
+                               return;
+                       }
+
+                       // grab the current length of the form element (or set 
to 0 if the current text is bogus placeholder)
+                       var length = amount - $element.val().length;
+
+                       // remove excessive characters
+                       if ( length < 0 ) {
+                               $element.val( $element.val().substr( 0, amount 
) );
+                               length = 0;
+                       }
+
+                       // display the amount of characters
+                       var message = mw.msg( 'articlefeedbackv5-countdown', 
length );
+                       $text.text( message );
+
+                       // only display the countdown for the last X characters
+                       $text.hide();
+                       if ( typeof displayLength == 'undefined' || length < 
displayLength ) {
+                               $text.show();
+                       }
                }
 
-
-               var enable = true;
-
-               // supported browser
-               enable &= $.aftUtils.useragent();
-
-               // if AFTv5 is not enabled on any namespace, it does not make 
sense to display it at all
-               enable &= mw.config.get( 'wgArticleFeedbackv5Namespaces', [] 
).length > 0;
-
-               if ( location != 'special' || article.id != 0 ) {
-                       // only on pages in namespaces where it is enabled
-                       enable &= $.inArray( article.namespace, mw.config.get( 
'wgArticleFeedbackv5Namespaces', [] ) ) > -1;
-
-                       // it does not make sense to display AFT when a page is 
being edited ...
-                       enable &= mw.config.get( 'wgAction' ) != 'edit';
-
-                       // ... or has just been edited
-                       enable &= !mw.config.get( 'wgPostEdit', false );
-               }
-
-               // for special page, it doesn't matter if the article has AFT 
applied
-               if ( location != 'special' ) {
-                       // check if user has the required permissions
-                       enable &= $.aftUtils.permissions( article );
-
-                       // category is not blacklisted
-                       enable &= !$.aftUtils.blacklist( article );
-
-                       // category is whitelisted or article is in lottery
-                       enable &= ( $.aftUtils.whitelist( article ) || 
$.aftUtils.lottery( article ) );
-               }
-
-               // stricter validation for article: make sure we're at the 
right article view
-               if ( location == 'article' ) {
-                       // not disabled via preferences
-                       enable &= !mw.user.options.get( 
'articlefeedback-disable' );
-
-                       // view pages
-                       enable &= ( mw.config.get( 'wgAction' ) == 'view' || 
mw.config.get( 'wgAction' ) == 'purge' );
-
-                       // if user is logged in, showing on action=purge is OK,
-                       // but if user is logged out, action=purge shows a form 
instead of the article,
-                       // so return false in that case.
-                       enable &= !( mw.config.get( 'wgAction' ) == 'purge' && 
mw.user.anonymous() );
-
-                       // current revision
-                       enable &= mw.util.getParamValue( 'diff' ) == null;
-                       enable &= mw.util.getParamValue( 'oldid' ) == null;
-
-                       // not viewing a redirect
-                       enable &= mw.util.getParamValue( 'redirect' ) != 'no';
-
-                       // not viewing the printable version
-                       enable &= mw.util.getParamValue( 'printable' ) != 'yes';
-               }
-
-               return enable;
+               // }}}
        };
 
        // }}}
-       // {{{ permissions
-
-       /**
-        * Check if the user is permitted to see the AFT feedback form
-        * on this particular page, as defined by its protection level
-        *
-        * @param object article
-        * @return bool
-        */
-       $.aftUtils.permissions = function ( article ) {
-               var permissions = mw.config.get( 
'wgArticleFeedbackv5Permissions' );
-               return article.permissionLevel in permissions && 
permissions[article.permissionLevel];
-       };
-
-       // }}}
-       // {{{ blacklist
-
-       /**
-        * Check if the article is blacklisted by intersecting the
-        * article's categories with the blacklisted categories
-        *
-        * Note: the .replace() makes sure that when blacklist category
-        * names are underscored, those are converted to spaces (cfr. category)
-        *
-        * @param object article
-        * @return bool
-        */
-       $.aftUtils.blacklist = function ( article ) {
-               var blacklistCategories = mw.config.get( 
'wgArticleFeedbackv5BlacklistCategories', [] );
-               var intersect = $.map( blacklistCategories, function( category 
) {
-                       return $.inArray( category.replace(/_/g, ' '), 
article.categories ) < 0 ? null : category;
-               } );
-               return intersect.length > 0;
-       };
-
-       // }}}
-       // {{{ whitelist
-
-       /**
-        * Check if the article is whitelisted by intersecting the
-        * article's categories with the whitelisted categories
-        *
-        * Note: the .replace() makes sure that when whitelist category
-        * names are underscored, those are converted to spaces (cfr. category)
-        *
-        * @param object article
-        * @return bool
-        */
-       $.aftUtils.whitelist = function ( article ) {
-               var whitelistCategories = mw.config.get( 
'wgArticleFeedbackv5Categories', [] );
-               var intersect = $.map( whitelistCategories, function( category 
) {
-                       return $.inArray( category.replace(/_/g, ' '), 
article.categories ) < 0 ? null : category;
-               } );
-               return intersect.length > 0;
-       };
-
-       // }}}
-       // {{{ lottery
-
-       /**
-        * Check if an article is eligible for AFT through the lottery
-        *
-        * Note: odds can either be a plain integer (0-100), or be defined per 
namespace
-        * (0-100 per namespace key)
-        *
-        * @param object article
-        * @return bool
-        */
-       $.aftUtils.lottery = function ( article ) {
-               var odds = mw.config.get( 'wgArticleFeedbackv5LotteryOdds', 0 );
-               if ( typeof odds === 'object' && article.namespace in odds ) {
-                       odds = odds[article.namespace];
-               }
-
-               return ( Number( article.id ) % 1000 ) >= ( 1000 - ( Number( 
odds ) * 10 ) );
-       };
-
-       // }}}
-       // {{{ useragent
-
-       /**
-        * Check if the browser is supported
-        *
-        * @return bool
-        */
-       $.aftUtils.useragent = function () {
-               var ua = navigator.userAgent.toLowerCase();
-
-               // Rule out MSIE 6, FF2, Android
-               return !(
-                       ua.indexOf( 'msie 6' ) != -1 ||
-                       ua.indexOf( 'firefox/2.') != -1 ||
-                       ua.indexOf( 'firefox 2.') != -1 ||
-                       ua.indexOf( 'android' ) != -1
-               );
-       };
-
-       // }}}
-       // {{{ getCookieName
-
-       /**
-        * Get the full, prefixed, name that data is saved at in cookie.
-        * The cookie name is prefixed by the extension name and a version 
number,
-        * to avoid collisions with other extensions or code versions.
-        *
-        * @param string $suffix
-        * @return string
-        */
-       $.aftUtils.getCookieName = function ( suffix ) {
-               return 'AFTv5-' + suffix;
-       };
-
-       // }}}
-       // {{{ removeLegacyCookies
-
-       /**
-        * Before the current getCookieName() function, cookie names were:
-        * * really long
-        * * incorrect using the tracking version number to differentiate 
JS/cookie versions
-        * * not being prefixed by wgCookiePrefix
-        *
-        * These issues have since been fixed, but this will make sure that 
lingering old
-        * cookie are cleaned up. This function will not merge the old cookies 
to the new
-        * cookie name though.
-        *
-        * @deprecated Function is only intended to bridge a temporary "gap" 
while old
-        *             data persists in cookie. After awhile, cookies have 
either expired
-        *             by themselves or this will have cleaned them up, so this 
function
-        *             (and where it's being called) can be cleaned up at will.
-        */
-       $.aftUtils.removeLegacyCookies = function() {
-               // old cookie names
-               var legacyCookieName = function( suffix ) {
-                       return 'ext.articleFeedbackv5@11-' + suffix;
-               }
-
-               // remove old cookie names
-               $.cookie( legacyCookieName( 'activity' ), null, { expires: -1, 
path: '/' } );
-               $.cookie( legacyCookieName( 'last-filter' ), null, { expires: 
-1, path: '/' } );
-               $.cookie( legacyCookieName( 'submission_timestamps' ), null, { 
expires: -1, path: '/' } );
-               $.cookie( legacyCookieName( 'feedback-ids' ), null, { expires: 
-1, path: '/' } );
-       }
-
-       // }}}
-
-// }}}
 
 } )( jQuery );

-- 
To view, visit https://gerrit.wikimedia.org/r/59387
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I037efdb4ebf1bbb277cb675ff1d02ca05c9da2ea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to