User talk:Kudpung/vector.js

Latest comment: 9 years ago by Technical 13 in topic Legacy JavaScript

Legacy JavaScript edit

Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include addOnloadHook( ... ) needs to be replaced with $( ... ) or $( function() { ... } ) (depending on use); all wgGlobalVariables need to be properly gotten with mw.config.get( 'wgGlobalVariable' ); and addPortletLink needs to be called with mw.util.addPortletLink. Please see MW:ResourceLoader/Legacy JavaScript for details. Thank you. — {{U|Technical 13}} (etc) 21:39, 19 January 2015 (UTC)Reply

Technical 13, thank you for this. It may explain why many of the scripts , especially the ones specifically for the use of admins, aren't working any more. That's why, for example, I haven't been doingany AfD closures for months. Unfortunately, it presupposes that all Wikipedia editors and admins have an in-depth knowledge of computer programmes. We don't. If you have time and would like to do me a favour, please copy my entire .js page (I don't believe you are able to edit it yourself), make the changes, and send me acopy to paste in over the entire page. I would be extremeky grateful. Regards, --Kudpung กุดผึ้ง (talk) 12:35, 20 January 2015 (UTC)Reply
  • It may be part of the cause (it is certainly the cause if all of the warnings in the javascript console if you open it up). I actually expect most of the user's I posted to are unable to fix it themselves (and have been helping all that asks over the last couple days here, on meta, on commons...) Part of this was to create an index of pages that need to be fix (Category:JavaScripts using deprecated elements) so that if Meta:Steward requests/Global permissions#Global editinterface for Technical 13 goes through I'll have a list to work from of scripts I need to fix. I would be happy to copy your .js page and make fixes that should bring you up to date and post it back for you to apply. I normally do so in a collapsed section right in the discussion here, would that work for sending you a copy? Thanks! — {{U|Technical 13}} (etc) 14:44, 20 January 2015 (UTC)Reply
  • Okay, so I've gone through your code and cleaned it up the best I can. You were calling some scripts multiple times, I've trimmed those back to one call each (all sorted alphabetically at the top). I've commented out some that I know are now gadgets (like various Twinkle components you were loading manually) and I've removed the call to Twinkle since that should be done through the gadget page on preferences. I've also trimmed out the Twinkle prefs as those should be located on Special:MyPage/twinkleoptions.js. I'll note that a lot of the scripts you are calling still have deprecated elements themselves that need to be fixed. Below is the cleaned up code for you (I'll work on those other scripts as requests come in and time allows), which passed with no issues from JSLint and returned no errors or warnings in the console when testing.
New code
//<nowiki>
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) { importScript( 'user:js/watchlist.js' ); }// Backlink: [[user:js/watchlist.js]]
importScript( 'User:Ale_jrb/Scripts/csdcheck.js' ); var notifyByDefaultDel = true; importScript( 'User:Ale_jrb/Scripts/csdhelper.js' );// Backlink: [[User:Ale_jrb/Scripts/csdhelper.js]]//CSD Deleter and Decliner
importScript( 'User:Animum/easyblock.js' );// Backlink: [[User:Animum/easyblock.js]]/* Cribbed from  Wifione. Apparently  useful  for admins. */// EasyBlock - Allows to block users quickly using a drop-down menu with frequent lengths and reasons//Easyblock// EasyUnBlock - Allows to unblock users quickly using a drop-down menu with frequent lengths and reasons
importScript( 'User:Anomie/useridentifier.js' );// Backlink: [[User:Anomie/useridentifier.js]]// User Identifier - Adds a little button to the username when viewing the userpage, showing edit count, groups, registering date
// /* Part of Twinkle */ importScript( 'User:AWeenieMan/furme.js' );// Backlink: [[User:AWeenieMan/furme.js]]
// /* Part of Twinkle */ importScript( 'User:AzaToth/morebits.js' );// Backlink: [[User:AzaToth/morebits.js]]
importScript( 'User:Dr_pda/prosesize.js' );// Backlink: [[User:Dr_pda/prosesize.js]] //[[User:Dr_pda/prosesize.js]]
importScript( 'User:Fox Wilson/delsort.js' );// Backlink: [[User:Fox Wilson/delsort.js]] // Deletion sorting script [[WP:FWDS]]
importScript( 'User:Jnothman/afd_helper/script.js' );// Backlink: [[User:Jnothman/afd_helper/script.js]]
importScript( 'User:Lupin/recent2.js' );// Backlink: [[User:Lupin/recent2.js]]
importScript( 'User:Mr.Z-man/closeAFD.js' );// Backlink: [[User:Mr.Z-man/closeAFD.js]]
importScript( 'User:Quarl/wikipage.js' );// Backlink: [[User:Quarl/wikipage.js]]/* 22 Nov 2011: restored the ('User:Quarl/util.js') and User:Quarl/wikipage.js scripts that were casing  the 'grey box' syndrome that  happens all on  its own. The removal  had caused the status change buttons to  disappear, and the user rights notice to  disappear. */
importScript( 'User:Ryan Vesey/sidebar.js' );// Backlink: [[User:Ryan Vesey/sidebar.js]] //puts a link in the sidebar to NewPagesFeed
importScript( 'User:Splarka/sysopdectector.js' );// Backlink: [[User:Splarka/sysopdectector.js]]//List usergroups on User:USERNAME or User talk:USERNAME
importScript( 'User:Steven Zhang/DRW.js' );// Backlink: [[User:Steven Zhang/DRW.js]] //DR Wizard
importScript( 'User:TheJosh/Scripts/NewPagePatrol.js' );// Backlink: [[User:TheJosh/Scripts/NewPagePatrol.js]]
importScript( 'User:Theopolisme/whisperbackLink.js' );// Backlink: [[User:Theopolisme/whisperbackLink.js]]
importScript( 'User:Twinzor/wikimark.js' );// Backlink: [[User:Twinzor/wikimark.js]]/* Wiki bookmarks, stored in special user page, adds tabs */
//importScript( 'User:VoA/monobook.js' );// Backlink: [[User:VoA/monobook.js]]
//importScript( 'User:X!/userrights.js' );// Backlink: [[User:X!/userrights.js]]// UserRights Link - Adds a "User rights" links to user pages
importScript( 'Wikipedia:WikiProject Deletion sorting/delsort.js' );// Backlink: [[Wikipedia:WikiProject Deletion sorting/delsort.js]]/* Automates the addition  of the delsort notes to  AfD but doesn't always show in  Twinkle menu; doesn't  always do  a complete job */
importScript( 'Wikipedia:WikiProject User scripts/Scripts/Add LI menu' );// Backlink: [[Wikipedia:WikiProject User scripts/Scripts/Add LI menu]]
importScript( 'Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js' );// Backlink: [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]]
importScript( 'Wikipedia:WikiProject User scripts/Scripts/Watchlist since' );// Backlink: [[Wikipedia:WikiProject User scripts/Scripts/Watchlist since]]// Watchlist since should load only new changes to your watchlist since the last time you reloaded it
importScript( 'User:Zhaofeng Li/Reflinks.js' );//Backlink [[User:Zhaofeng Li/Reflinks.js]]
importStylesheet( 'Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css' );// Backlink: [[Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css]]
mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-markblocked.js&action=raw&ctype=text/javascript' );//Mark blocked users

/* [[User:Dispenser/Reflinks]] */// Add [[WP:Reflinks]] launcher in the toolbox on left
$( function () {
    mw.util.addPortletLink(
        'p-tb',   // toolbox portlet
        'http://dispenser.homenet.org/~dispenser/cgi-bin/webreflinks.py?page=' + mw.config.get( 'wgPageName' )
            + '&citeweb=on&overwrite=&limit=30&lang=' + mw.config.get( 'wgContentLanguage' ),
        'Reflinks'  // link label
    );
} );

//[[Category:Wikipedians who use RC script]]
 
/* Important tool for Good Article and Featured article reviewers and writers. Provides a complete analysis of the status of all external links */
/** Checklinks toolbox item ***************************************************
* 
*  Description: Adds an item in toolbox portlet that runs the checklinks tool 
*                     on the viewed page.
*  Maintainer(s): [[User:Dispenser]]
*  Installation:  Copy and paste following code into you /monobook.js
*                     {{subst:js|User:Dispenser/Link checker/toolbox.js}}
*/
function checklinks() {
    mw.util.addPortletLink(
        'p-tb',
        'http://dispenser.homenet.org/~dispenser/cgi-bin/webchecklinks.py?page=' + mw.config.get( 'wgContentLanguage' ) + ':' + mw.config.get( 'wgPageName' ),
        'Check external links',
        't-checklinks'
    );
}
if ( mw.config.get( ' wgIsArticle' ) ) {
    checklinks();
}

function addToToolbox() {
    if ( mw.config.get( 'wgCanonicalNamespace' ) !== 'Special' ) {
        var pTb = document.getElementById( 'p-tb' );
        var pRef = pTb.cloneNode( true );
        var pStats = pTb.cloneNode( true );
     
        pRef.id = 'p-refs';
        pRef.innerHTML = '<h5>Reference formatting</h5><div class="pBody"><ul></ul></div>';
        pStats.id = 'p-stats';
        pStats.innerHTML = '<h5>Statistics</h5><div class="pBody"><ul></ul></div>';
        pTb.parentNode.insertBefore( pRef, pTb.nextSibling );
        pTb.parentNode.insertBefore( pStats, pRef );
     
        var escPageName = escape( mw.config.get( 'wgPageName') ).replace( /\+/g, '%2B' ).replace( /%u2013/g, '%96' );
     
        mw.util.addPortletLink(
            'p-refs',
            'http://tools.wikimedia.de/~verisimilus/Bot/DOI_bot/doibot.php?edit=toolbar&turbo=1&user='
                + mw.config.get( 'wgUserName' ) + '&page=' + escPageName,
            'Automatic (fast)',
            '',
            'Add DOIs to citations and fix common formatting errors. Turbo mode!'
        );
        mw.util.addPortletLink(
            'p-refs',
            'http://tools.wikimedia.de/~verisimilus/Bot/DOI_bot/doibot.php?edit=toolbar&slow=1&user='
                + mw.config.get( 'wgUserName' ) + '&page=' + escPageName,
            'Automatic (thorough)',
            '',
            'Add DOIs to citations and fix common formatting errors'
        );
        /* mw.util.addPortletLink(
            'p-refs',
            'http://tools.wikimedia.de/~verisimilus/Scholar/RefTool.php?user='
                + mw.config.get( 'wgUserName' ) + '&wgPageName=' + escPageName,
            'Semi-automatic (experimental)',
            '',
            'Improve formatting of references – manually approve automatic improvements'
        ); */
     
        var now = new Date();
        var month = now.getMonth();
        var thisMonth = ( now.getDay() > 6 );
        if ( thisMonth ) month++;
        if ( month === 0 ) month = 12;
        else month = ( ( month < 10 ) ? '0' : '' ) + month;
        mw.util.addPortletLink(
            'p-stats',
            'http://stats.grok.se/en/' + now.getFullYear() + month + '/' + mw.config.get( 'wgPageName' ),
            'Traffic stats',
            '',
            'Traffic to this page ' + ( thisMonth ? 'this' : 'last' ) + ' month'
        );
        mw.util.addPortletLink(
            'p-stats',
            'http://wikidashboard.parc.com/wiki/' + mw.config.get( 'wgPageName' ),
            'Edit history stats',
            '',
            'Statistics about the edit history of this page'
        );
 
    }
}
$( addToToolbox );

/* Status changer puts a coloured blob in  the top  bar  of your user page and talk  pag to  notify  users of your online status */
//////////STATUS CHANGER
// Creator: Misza13
// Credits: Voyagerfan5761 for some minor improvements
// Modified by Xenocidic to simply use /Status as a one word indicator,
// Modified by Kraftlos to include Sleep status
// compatible with {{Statustop}} for display
 
$( function () {
    //Check if the config is defined
    if ( statusChangerConfig === undefined ) {
        var statusChangerConfig = {
			statusList: [ 'online', 'busy', 'around', 'offline', 'sleep' ],
			statusPage: 'User:' + mw.config.get( 'wgUserName' ) + '/Status'
		};
    }
    if ( statusChangerConfig.statusList === undefined ) {
        statusChangerConfig.statusList = [ 'online', 'busy', 'around', 'offline', 'sleep' ];
    }
    if ( statusChangerConfig.statusPage === undefined ) {
        statusChangerConfig.statusPage = 'User:' + mw.config.get( 'wgUserName' ) + '/Status';
    }
     
    //Add the links
    for ( var i = 0; i < statusChangerConfig.statusList.length; i++ ) {
        var stat = statusChangerConfig.statusList[ i ];
        var message = ( stat === 'sleep' ) ?  'asleep' : stat;
        mw.util.addPortletLink(
            'p-personal', //target tab - personal links
            mw.util.getUrl( statusChangerConfig.statusPage, { action: 'edit', newstatus: stat } ), //link URL
            stat, //link text
            'pt-status-' + stat, //id of new button
            'I\'m ' + message + '!', //hover text
            null,
            'pt-logout'
        ); //add before logout button
    }
     
    if ( location.href.indexOf( '&action=edit&newstatus=' ) === -1 ) return; //Are we here to auto-edit the status?
    //Get new status
    var status = mw.util.getParamValue( 'newstatus' );
    //Modify the form
    $( '#wpTextbox1' ).val( status );
    if ( status === 'sleep' ) { status = 'sleeping'; }
    $( '#wpSummary' ).val( mw.config.get( 'wgUserName' ) + ' is now ' + status + '.');
    $( '#wpMinoredit' ).attr( 'checked', true );
    //Submit it!
    $( '#editform' ).submit();
} );//[[Category:Wikipedia scripts|statusChanger]]
//</nowiki>
Let me know if you have any specific issues and I'll look deeper for you. Happy coding! — {{U|Technical 13}} (etc) 17:15, 20 January 2015 (UTC)Reply