Jump to content

User:Speravir/global.js: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
No edit summary
No edit summary
Line 14: Line 14:
// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:TMg/filterContributions
// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:TMg/filterContributions
mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:TMg/filterContributions.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript');
mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:TMg/filterContributions.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript');

// siehe unter https://de.wikipedia.org/wiki/Benutzer:Nightfly85/js/historyCombine.js/doku
mw.loader.load("https://de.wikipedia.org/wiki/Benutzer:Nightfly85/js/historyCombine.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript", "text/javascript");


// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:PerfektesChaos/js/pageLinkHelper
// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:PerfektesChaos/js/pageLinkHelper
Line 24: Line 21:
// dt. Kurzbeschreibung unter https://de.wikipedia.org/wiki/Benutzer_Diskussion:lustiger_seth/unsigned.js#Benutzung
// dt. Kurzbeschreibung unter https://de.wikipedia.org/wiki/Benutzer_Diskussion:lustiger_seth/unsigned.js#Benutzung
mw.loader.load('//de.wikipedia.org/w/index.php?title=user:lustiger_seth/unsigned.js&action=raw&ctype=text/javascript&smaxage=2678400');
mw.loader.load('//de.wikipedia.org/w/index.php?title=user:lustiger_seth/unsigned.js&action=raw&ctype=text/javascript&smaxage=2678400');

// siehe unter https://de.wikipedia.org/wiki/Benutzer:Nightfly85/js/historyCombine.js/doku
/**
* historyCombine:
*
* fasst in der Versionsgeschichte Einträge zusammen, wenn sie
* aufeinanderfolgend vom gleichen Author stammen.
* Sinnvoll ist (m)eine angepasste common.css
*
* merges sequenced edits from the same author in
* the history list
* A modified common.css is recommened (like mine)
*
*
* Author: Benutzer:Nightfly85
*/
$(document).ready(function() {
// determines how many sequenced edits are required to stack them
var minStackCount = 3;
if(mw.config.get('wgAction') != "history" || minStackCount < 2)
return; // nothing to do here...
// cache the history list and its count
var $listItems = $('ul#pagehistory').find('li');
var listItemsLength = $listItems.length - 1;
// prepare the iterator compare elements
var currentAuthorName = '', lastAuthorName = '';
var $lastRow, $rootRow;
// this array contains grouped elements and will be
// resetted when a new author name is found
var stack = [];
// combine counter
var combinedStacks = 0;
// start the loop, iterate every row
$listItems.each(function(index, rowEl) {
// cache the current row (don't know if this is necessary :)
var $row = $(rowEl);
// cache the found author name
currentAuthorName = $row.find('.history-user a.mw-userlink').text();
if(currentAuthorName === lastAuthorName) {
// Yes, this author does more than one sequenced entry
if(stack.length === 0) {
// stack is empty, so the last row was the first item of the stack
$rootRow = $lastRow;
}
stack.push($row);
}
if(currentAuthorName !== lastAuthorName || index === listItemsLength) {
// a new author was found or this is the last iteration
var stacklength = stack.length;
if((stacklength + 1) >= minStackCount) {
// there is a stack we have to translate first
var ctText = (stacklength >= 1) ? stacklength.toString() + ' weitere Beiträge' : 'einen weiteren Beitrag';
$rootRow
.addClass('mw-historycombine-rootRow mw-historycombine-rootRow-folded')
.append('&nbsp;<a href="#" class="mw-historycombine-autoBundleInfo"><span class="mw-historycombine-foldaction">zeige</span> ' + ctText + ' von ' + mw.html.escape(lastAuthorName));
for(var i = 0; i < stacklength; ++i ) {
// hide the stack items
// stack[i] = jQuery object
stack[i].addClass('mw-historycombine-hiddenChild mw-historycombine-hiddenChildIndex-' + $rootRow.index()).fadeOut();
}
++combinedStacks;
}
// reset the stack
stack = [];
// Save this author name for the next iteration
lastAuthorName = currentAuthorName;
$lastRow = $(rowEl);
}
});
if(combinedStacks) {
// If combined stacks exists, generate anchors to expand/collapse all
$('.mw-historycombine-unfoldAll').live('click', function(e) {
e.preventDefault();
$('.mw-historycombine-rootRow-folded').each(function(i, el) {
toggleStackVisibility($(el));
});
});
$('.mw-historycombine-foldAll').live('click', function(e) {
e.preventDefault();
$('.mw-historycombine-rootRow-unfolded').each(function(i, el) {
toggleStackVisibility($(el));
});
});
$('input.historysubmit').parent().append('Zusammengefasste Beiträge: <a href="#" class="mw-historycombine-unfoldAll">ausklappen</a> | <a href="#" class="mw-historycombine-foldAll">zuklappen</a>');
}
$('a.mw-historycombine-autoBundleInfo').live('click', function(e) {
e.preventDefault();
toggleStackVisibility($(this).closest('li'));
});
function toggleStackVisibility($row) {
// first, adjust the text from clicked link...
var $foldAction = $row.find('span.mw-historycombine-foldaction');
$foldAction.text($foldAction.text() == 'zeige' ? 'verstecke' : 'zeige');
// ...and second, look for linked stack items to expand or collapse them
$row
.toggleClass('mw-historycombine-rootRow-folded')
.toggleClass('mw-historycombine-rootRow-unfolded')
.parent()
.find('.mw-historycombine-hiddenChildIndex-' + $row.index())
.slideToggle('fast');
};
});

/* * * * */

Revision as of 21:54, 1 October 2015

mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:Schnark/js/fliegelflagel.js/global.js&action=raw&ctype=text/javascript&maxage=86400&smaxage=60&bcache=1');
function extratabsDuring (extratabs) {
    extratabs.remove('blame');
    extratabs.enable('visualeditor');
}

// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:PerfektesChaos/js/clickDivertimento
if ( typeof mw.libs.clickDivertimento !== "object" ) {
   mw.libs.clickDivertimento = { };
}
mw.libs.clickDivertimento.large = true;
mw.loader.load("//en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/clickDivertimento/r.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript", "text/javascript");

// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:TMg/filterContributions
mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:TMg/filterContributions.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript');

// dt. Beschreibung unter https://de.wikipedia.org/wiki/Benutzer:PerfektesChaos/js/pageLinkHelper
mw.libs.pageLinkHelper = { purge: "p-tb" };
mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/pageLinkHelper/r.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript", "text/javascript" );

// dt. Kurzbeschreibung unter https://de.wikipedia.org/wiki/Benutzer_Diskussion:lustiger_seth/unsigned.js#Benutzung
mw.loader.load('//de.wikipedia.org/w/index.php?title=user:lustiger_seth/unsigned.js&action=raw&ctype=text/javascript&smaxage=2678400');

// siehe unter https://de.wikipedia.org/wiki/Benutzer:Nightfly85/js/historyCombine.js/doku
/**
 * historyCombine:
 *
 * fasst in der Versionsgeschichte Einträge zusammen, wenn sie
 * aufeinanderfolgend vom gleichen Author stammen.
 * Sinnvoll ist (m)eine angepasste common.css
 *
 * merges sequenced edits from the same author in
 * the history list
 * A modified common.css is recommened (like mine)
 *
 *
 * Author: Benutzer:Nightfly85
 */
 
$(document).ready(function() {
 
    // determines how many sequenced edits are required to stack them
    var minStackCount = 3;
 
    if(mw.config.get('wgAction') != "history" || minStackCount < 2)
        return; // nothing to do here...
 
    // cache the history list and its count
    var $listItems = $('ul#pagehistory').find('li');
    var listItemsLength = $listItems.length - 1;
 
    // prepare the iterator compare elements
    var currentAuthorName = '', lastAuthorName = '';
    var $lastRow, $rootRow;
 
    // this array contains grouped elements and will be
    // resetted when a new author name is found
    var stack = [];
 
    // combine counter
    var combinedStacks = 0;
 
    // start the loop, iterate every row
    $listItems.each(function(index, rowEl) {
 
        // cache the current row (don't know if this is necessary :)
        var $row = $(rowEl);
 
        // cache the found author name
        currentAuthorName = $row.find('.history-user a.mw-userlink').text();
 
        if(currentAuthorName === lastAuthorName) {
            // Yes, this author does more than one sequenced entry
 
            if(stack.length === 0) {
                // stack is empty, so the last row was the first item of the stack
                $rootRow = $lastRow;
            }
            stack.push($row);
        }
 
        if(currentAuthorName !== lastAuthorName || index === listItemsLength) {
            // a new author was found or this is the last iteration
 
            var stacklength = stack.length;
 
            if((stacklength + 1) >= minStackCount) {
                // there is a stack we have to translate first
 
                var ctText = (stacklength >= 1) ? stacklength.toString() + ' weitere Beiträge' : 'einen weiteren Beitrag';
                $rootRow
                    .addClass('mw-historycombine-rootRow mw-historycombine-rootRow-folded')
                    .append('&nbsp;<a href="#" class="mw-historycombine-autoBundleInfo"><span class="mw-historycombine-foldaction">zeige</span> ' + ctText + ' von ' + mw.html.escape(lastAuthorName));
 
                for(var i = 0; i < stacklength; ++i ) {
                    // hide the stack items
                    // stack[i] = jQuery object
                    stack[i].addClass('mw-historycombine-hiddenChild mw-historycombine-hiddenChildIndex-' + $rootRow.index()).fadeOut();
                }
                ++combinedStacks;
            }
 
            // reset the stack
            stack = [];
 
            // Save this author name for the next iteration
            lastAuthorName = currentAuthorName;
            $lastRow = $(rowEl);
        }
    });
 
    if(combinedStacks) {
        // If combined stacks exists, generate anchors to expand/collapse all
 
        $('.mw-historycombine-unfoldAll').live('click', function(e) {
            e.preventDefault();
            $('.mw-historycombine-rootRow-folded').each(function(i, el) {
                toggleStackVisibility($(el));
            });
        });
 
        $('.mw-historycombine-foldAll').live('click', function(e) {
            e.preventDefault();
            $('.mw-historycombine-rootRow-unfolded').each(function(i, el) {
                toggleStackVisibility($(el));
            });
        });
 
        $('input.historysubmit').parent().append('Zusammengefasste Beiträge: <a href="#" class="mw-historycombine-unfoldAll">ausklappen</a> | <a href="#" class="mw-historycombine-foldAll">zuklappen</a>');
    }
 
    $('a.mw-historycombine-autoBundleInfo').live('click', function(e) {
        e.preventDefault();
        toggleStackVisibility($(this).closest('li'));
    });
 
    function toggleStackVisibility($row) {
 
        // first, adjust the text from clicked link...
        var $foldAction = $row.find('span.mw-historycombine-foldaction');
        $foldAction.text($foldAction.text() == 'zeige' ? 'verstecke' : 'zeige');
 
        // ...and second, look for linked stack items to expand or collapse them
        $row
            .toggleClass('mw-historycombine-rootRow-folded')
            .toggleClass('mw-historycombine-rootRow-unfolded')
            .parent()
                .find('.mw-historycombine-hiddenChildIndex-' + $row.index())
                .slideToggle('fast');
    };
});

/* * * * */