MediaWiki:PreMarkup.js: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1:
$( 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....
var OriginalText = $this.html();
 
function returnBoxedText(match, p1) { return '<box>' + p1 + '</box>'; }
$this.parent(".mw-collapsible-content").show(); /// temporary show collapsible content to read its location....
function returnSpanPosStr(match, p1) {
$this.parent().parent(".mw-collapsible-content").show(); /// temporary show collapsible content to read its location....
var MarginTop = 0;
var MarginLeft = 0;
var Rotation = 0;
switch(p1) {
 
case "":
function returnBoxedText(match, p1) { return '' + p1 + ''; }
MarginTop = 5;
function returnSpanPosStr(match, p1) {
var MarginTop MarginLeft = 05;
var MarginLeft Rotation = 0225;
var Rotation = 0 break;
switch (p1) { case "-tr":
MarginTop = 5;
MarginLeft = 5;
Rotation = 225;
break;
case "-br":
MarginTop = 20;
MarginLeft = 50;
Rotation = 315;
break;
case "-bl":
MarginTop = 10;
MarginLeft = -5;
Rotation = 45;
break;
case "-tl":
MarginLeft MarginTop = -50;
Rotation MarginLeft = 225-5;
Rotation = 135;
break;
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%;">&nbsp</point-here>';
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;
}
 
var newText = OriginalText.replace(/&lt;box&gt;(.*)&lt;\/box&gt;/g, returnBoxedText);
newText = newText.replace(/&lt;point-here(\S*)&gt;/g, returnSpanPosStr);
$this.html(newText);
 
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%;">&nbsp</point-here>';
}
 
$this.find('box').each(function () {
var newText = OriginalText.replace(/&lt;box&gt;(.*)&lt;\/box&gt;/g, returnBoxedText);
posTop = $(this).position().top - 3;
newText = newText.replace(/&lt;point-here(\S*)&gt;/g, returnSpanPosStr);
posLeft = $(this).htmlposition(newText).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;">&nbsp</div>' );
});
 
 
$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;">&nbsp</div>');
});
 
});
 
});