MediaWiki:Common.js: Difference between revisions
Appearance
Content deleted Content added
Caleb Cooper (talk | contribs) No edit summary Tag: Reverted |
Caleb Cooper (talk | contribs) No edit summary Tag: Reverted |
||
| Line 5: | Line 5: | ||
importScript('MediaWiki:FilterTable.js'); |
importScript('MediaWiki:FilterTable.js'); |
||
/* Mark up pre's with box or pointer |
/* Mark up pre's with box or pointer /* |
||
importScript('MediaWiki:PreMarkup.js'); |
/* importScript('MediaWiki:PreMarkup.js'); /* |
||
$(document).ready(function () { |
|||
$('pre').each(function () { |
|||
var $this = $(this) |
|||
var OriginalText = $this.html(); |
|||
$this.parent(".mw-collapsible-content").show(); /// temporary show collapsible content to read its location.... |
|||
$this.parent().parent(".mw-collapsible-content").show(); /// temporary show collapsible content to read its location.... |
|||
function returnBoxedText(match, p1) { return '' + p1 + ''; } |
|||
function returnSpanPosStr(match, p1) { |
|||
var MarginTop = 0; |
|||
var MarginLeft = 0; |
|||
var Rotation = 0; |
|||
switch (p1) { |
|||
case "": |
|||
MarginTop = 5; |
|||
MarginLeft = 5; |
|||
Rotation = 225; |
|||
break; |
|||
case "-tr": |
|||
MarginTop = 5; |
|||
MarginLeft = 5; |
|||
Rotation = 225; |
|||
break; |
|||
case "-br": |
|||
MarginTop = 20; |
|||
MarginLeft = 0; |
|||
Rotation = 315; |
|||
break; |
|||
break; |
|||
case "-bl": |
|||
MarginTop = 10; |
|||
MarginLeft = -5; |
|||
Rotation = 45; |
|||
break; |
|||
case "-tl": |
|||
MarginTop = 0; |
|||
MarginLeft = -5; |
|||
Rotation = 135; |
|||
break; |
|||
} |
|||
return '<point-here class="pre-arrow" orientation="' + p1 + '" style="position:absolute; maring-left: ' + MarginLeft + 'px; margin-top: ' + MarginTop + 'px; transform: rotate(' + Rotation + 'deg); transform-origin: 0% 0%;"> </point-here>'; |
|||
} |
|||
var newText = OriginalText.replace(/<box>(.*)<\/box>/g, returnBoxedText); |
|||
newText = newText.replace(/<point-here(\S*)>/g, returnSpanPosStr); |
|||
$this.html(newText); |
|||
$this.find('box').each(function () { |
|||
posTop = $(this).position().top - 3; |
|||
posLeft = $(this).position().left - 3; |
|||
boxWidth = $(this).width(); |
|||
$this.append('<div style="padding:1px; padding-left:2px; border: 2px solid red; border-radius: 5px; box-shadow: 0.5px 0.5px 5px 0.5px red; position: absolute; left: ' + posLeft + 'px; top: ' + posTop + 'px; width:' + boxWidth + 'px;"> </div>'); |
|||
}); |
|||
}); |
|||
}); |
|||
/** |
/** |
||
Revision as of 10:32, 16 April 2024
/* [[Category:AutoDumpContentFromCommons]] */
/* Any JavaScript here will be loaded for all users on every page load. */
/* Script for filtering mediawiki tables*/
importScript('MediaWiki:FilterTable.js');
/* Mark up pre's with box or pointer /*
/* importScript('MediaWiki:PreMarkup.js'); /*
$(document).ready(function () {
$('pre').each(function () {
var $this = $(this)
var OriginalText = $this.html();
$this.parent(".mw-collapsible-content").show(); /// temporary show collapsible content to read its location....
$this.parent().parent(".mw-collapsible-content").show(); /// temporary show collapsible content to read its location....
function returnBoxedText(match, p1) { return '' + p1 + ''; }
function returnSpanPosStr(match, p1) {
var MarginTop = 0;
var MarginLeft = 0;
var Rotation = 0;
switch (p1) {
case "":
MarginTop = 5;
MarginLeft = 5;
Rotation = 225;
break;
case "-tr":
MarginTop = 5;
MarginLeft = 5;
Rotation = 225;
break;
case "-br":
MarginTop = 20;
MarginLeft = 0;
Rotation = 315;
break;
break;
case "-bl":
MarginTop = 10;
MarginLeft = -5;
Rotation = 45;
break;
case "-tl":
MarginTop = 0;
MarginLeft = -5;
Rotation = 135;
break;
}
return '<point-here class="pre-arrow" orientation="' + p1 + '" style="position:absolute; maring-left: ' + MarginLeft + 'px; margin-top: ' + MarginTop + 'px; transform: rotate(' + Rotation + 'deg); transform-origin: 0% 0%;"> </point-here>';
}
var newText = OriginalText.replace(/<box>(.*)<\/box>/g, returnBoxedText);
newText = newText.replace(/<point-here(\S*)>/g, returnSpanPosStr);
$this.html(newText);
$this.find('box').each(function () {
posTop = $(this).position().top - 3;
posLeft = $(this).position().left - 3;
boxWidth = $(this).width();
$this.append('<div style="padding:1px; padding-left:2px; border: 2px solid red; border-radius: 5px; box-shadow: 0.5px 0.5px 5px 0.5px red; position: absolute; left: ' + posLeft + 'px; top: ' + posTop + 'px; width:' + boxWidth + 'px;"> </div>');
});
});
});
/**
* @source https://www.mediawiki.org/wiki/Snippets/Open_specific_links_in_new_window
* @version 2018-09-15
*/
$( function () {
$( '#mw-content-text' ).on( 'click', '.newwin > a', function () {
var otherWindow = window.open();
otherWindow.opener = null;
otherWindow.location = this;
return false;
} );
} );