User:Diwas/vector.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
The accompanying .css page for this skin can be added at User:Diwas/vector.css. |
- Report page listing warnings and errors.
// stockphoto_prevent=true;
mw.loader.load("//de.wikipedia.org/w/index.php?title=User:lustiger_seth/unsigned.js&action=raw&ctype=text/javascript&dontcountme=s");
// Versionsvergleich zwischen mehreren Versionen auflösen
$(function() {
var multidiff = document.getElementsByClassName("diff-multi")[0];
if (! multidiff) return;
var leftlink = document.getElementById("mw-diff-otitle1").getElementsByTagName("a")[0].href;
var left = document.createElement("a");
left.href = leftlink + "&diff=next";
left.appendChild(document.createTextNode("→"));
multidiff.insertBefore(left, multidiff.firstChild);
var rightlink = document.getElementById("mw-diff-ntitle1").getElementsByTagName("a")[0].href;
var right = document.createElement("a");
right.href = rightlink + "&diff=prev";
right.appendChild(document.createTextNode("←"));
multidiff.appendChild(right);
});
$('#editform').find('input[type="text"]').keypress(function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
/**
* 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(' <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').click(function(e) {
e.preventDefault();
$('.mw-historycombine-rootRow-folded').each(function(i, el) {
toggleStackVisibility($(el));
});
});
$('.mw-historycombine-unfoldAll').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').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');
}
});
// eigene Beiträge nur geänderte
if ( wgCanonicalSpecialPageName == "Contributions" ) addOnloadHook( function() {
var monthsel = document.getElementById( 'month' );
if( !monthsel ) return;
var content = document.getElementById( 'bodyContent' )
|| document.getElementById( 'mw_contentholder' ) || document.getElementById( 'article' );
var list = content.getElementsByTagName( 'ul' );
if (list.length === 0) return;
list = list[list.length - 1]; // Last one should (hopefully) be the contribs list in most cases
var span = document.createElement( 'span' );
span.style.marginLeft = '1em';
span.appendChild( document.createTextNode( 'Doppeleinträge ausblenden' ) );
var cbdupl = document.createElement( 'input' );
cbdupl.type = 'checkbox';
span.appendChild( cbdupl );
span.appendChild( document.createTextNode( 'aktuelle Beiträge ausblenden' ) );
var cbtop = document.createElement( 'input' );
cbtop.type = 'checkbox';
span.appendChild( cbtop );
function refreshContribs() {
var li = list.getElementsByTagName( 'li' );
var titles = {};
for ( var i=0; i < li.length; i++ ) {
var link = li[i].getElementsByTagName( 'a' )[1];
var strong = getElementsByClassName( li[i], 'span', 'mw-uctop' );
if ( ( titles[link.title] && cbdupl.checked ) || ( strong.length && cbtop.checked ) )
li[i].style.display = 'none';
else li[i].style.display = 'list-item';
titles[link.title] = true;
}
}
cbdupl.onclick = refreshContribs;
cbtop.onclick = refreshContribs;
monthsel.parentNode.parentNode.appendChild( span );
});
// eigene Beiträge nur geänderte
if ( wgCanonicalSpecialPageName == "Contributions" ) addOnloadHook( function() {
var monthsel = document.getElementById( 'month' );
if( !monthsel ) return;
var content = document.getElementById( 'bodyContent' )
|| document.getElementById( 'mw_contentholder' ) || document.getElementById( 'article' )
var list = content.getElementsByTagName( 'ul' );
if (list.length == 0) return;
list = list[list.length - 1]; // Last one should (hopefully) be the contribs list in most cases
var span = document.createElement( 'span' );
span.style.marginLeft = '1em';
span.appendChild( document.createTextNode( 'Doppeleinträge ausblenden' ) );
var cbdupl = document.createElement( 'input' );
cbdupl.type = 'checkbox';
span.appendChild( cbdupl );
span.appendChild( document.createTextNode( 'aktuelle Beiträge ausblenden' ) );
var cbtop = document.createElement( 'input' );
cbtop.type = 'checkbox';
span.appendChild( cbtop );
function refreshContribs() {
var li = list.getElementsByTagName( 'li' );
var titles = {};
for ( var i=0; i < li.length; i++ ) {
var link = li[i].getElementsByTagName( 'a' )[1];
var strong = getElementsByClassName( li[i], 'span', 'mw-uctop' );
if ( ( titles[link.title] && cbdupl.checked ) || ( strong.length && cbtop.checked ) )
li[i].style.display = 'none';
else li[i].style.display = 'list-item';
titles[link.title] = true;
}
}
cbdupl.onclick = refreshContribs;
cbtop.onclick = refreshContribs;
monthsel.parentNode.parentNode.appendChild( span );
});