Jump to content

User:Pyrospirit/metadata/lowestfirst.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Optional component for metadata script ([[User:Pyrospirit/metadata]]). This script modifies the 
* behavior of the metadata script so that the lowest rating found is displayed, rather than the 
* highest.
*
* As an optional addition to the script, the code here may be less thoroughly tested or less up-to-
* date than the main script. Also, note that since this significantly changes the order in which 
* assessments are detected, the results displayed may not be an accurate reflection of the article's 
* quality.
*/

assessment.getRating = function (text) {
    if ( text.match(/\bclass *= *stub/i) ) rating = 'stub';
    else if ( text.match(/\bclass *= *start/i) ) rating = 'start';
    else if ( text.match(/\bclass *= *c\b/i) ) rating = 'c';
    else if ( text.match(/\bclass *= *bplus\b/i) ) rating = 'bplus';
    else if ( text.match(/\bclass *= *b\b/i) ) rating = 'b';
    else if ( text.match(/\bclass *= *ga\b|\bcurrentstatus *= *(ffa\/)?ga\b|\{\{ *ga *\|/i)
               && !text.match(/\bcurrentstatus *= *dga\b/i) ) rating = 'ga';
    else if ( text.match(/\bclass *= *a\b/i) ) {
        if ( text.match(/\bclass *= *ga\b|\bcurrentstatus *= *(ffa\/)?ga\b/i) )
            rating = 'a/ga';
        else rating = 'a';
    } else if ( text.match(/\b(class|currentstatus) *= *fl\b/i) ) rating = 'fl';
    else if ( text.match(/\b(class|currentstatus) *= *fa\b/i) ) rating = 'fa';
    else if ( text.match(/\bclass *= *list/i) ) rating = 'list';
    else if ( text.match(/\bclass *= *(dab|disambig)/i) ) rating = 'dab';
    else if ( text.match(/\bclass *= *cur(rent)?/i) ) rating = 'cur';
    else if ( text.match(/\bclass *= *future/i) ) rating = 'future';
    else rating = 'none';
    return rating;
}