MediaWiki:Monobook.js
Notă: După publicare, trebuie să treceți peste memoria cache a navigatorului pentru a putea vedea modificările:
- Firefox / Safari: Țineți apăsat pe Shift în timp ce faceți clic pe Reîncărcare ori apăsați Ctrl-F5 sau Ctrl-R (⌘-R pe un sistem Mac);
- Google Chrome: Apăsați Ctrl-Shift-R (⌘-Shift-R pe un sistem Mac);
- Internet Explorer / Edge: Țineți apăsat pe Ctrl în timp ce faceți clic pe Reîmprosptare sau apăsați Ctrl-F5;
- Opera: Apăsați Ctrl-F5.
/*
<pre><nowiki>
*/
if (window.showModalDialog && document.compatMode && document.compatMode == "CSS1Compat")
{
var oldWidth;
var docEl = document.documentElement;
function fixIEScroll()
{
if (!oldWidth || docEl.clientWidth > oldWidth)
doFixIEScroll();
else
setTimeout(doFixIEScroll, 1);
oldWidth = docEl.clientWidth;
}
function doFixIEScroll() {
docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
}
if (document.attachEvent) {
document.attachEvent("onreadystatechange", fixIEScroll);
attachEvent("onresize", fixIEScroll);
}
}
function LegAF()
{
// iterate over all <span>-elements
for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
// if found a AF span
if(a.className == "AF") {
// iterate over all <li>-elements
for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
// if found a AF link
if(b.className == "interwiki-" + a.id) {
b.style.padding = "0 0 0 16px";
b.style.backgroundImage = "url('//upload.wikimedia.org/wikipedia/ro/5/53/Pictograma-LegAF.png')";
b.style.backgroundRepeat = "no-repeat";
b.title = "Acest articol este considerat a fi de calitate";
}
}
}
}
}
jQuery(document).ready(LegAF);
// ============================================================
// BEGIN Dynamic Navigation Bars
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all <div>-elements
for(
var i=0;
NavFrame = document.getElementsByTagName("div")[i];
i++
) {
// if found a navigation bar
if (NavFrame.className == "NavFrame") {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in <div class="NavFrame">
NavFrame.insertBefore(
NavToggle,
NavFrame.firstChild
);
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBar(i);
}
}
}
jQuery(document).ready(createNavigationBarToggleButton);
var NavigationBarHide = '[ Ascundere ]';
var NavigationBarShow = '[ Extindere ]';
var NavigationBarShowDefault = 1;
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarShow;
}
}
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarHide;
}
}
}
}
// END Dynamic Navigation Bars
// ============================================================
//============================================================
//
// ÎNCEPUT dispariţie titlu din pagina principală (test)
//
//============================================================
var mpTitle = "Pagina principală";
var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
if (isMainPage && !isDiff)
{
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
var mpSmallEnabled;
var mpMinWidth = 700;
function mainPageTransform()
{
if ((isMainPage || /[\/=:]Main_Page/.test(document.location)) && document.getElementById('ca-nstab-main'))
document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Pagina principală';
var mpContentEl = document.getElementById("bodyContent");
var mpBrowseEl = document.getElementById("EnWpMpBrowse");
var mpContainEl = document.getElementById("EnWpMpBrowseContainer");
var mpMarginEl = document.getElementById("EnWpMpMargin");
var mpEl = document.getElementById("EnWpMainPage");
if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl)
return;
if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth)
{
mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild);
mpBrowseEl.className = "EnWpMpBrowseBottom";
mpMarginEl.style.marginRight = 0;
mpSmallEnabled = true;
}
else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth)
{
mpEl.insertBefore(mpBrowseEl, mpEl.firstChild);
mpBrowseEl.className = "EnWpMpBrowseRight";
mpMarginEl.style.marginRight = "13.8em";
mpSmallEnabled = false;
}
}
var onloadFuncts = [ mainPageTransform ];
if (window.addEventListener)
window.addEventListener("resize", mainPageTransform, false);
else if (window.attachEvent)
window.attachEvent("onresize", mainPageTransform);
}
//============================================================
// SFÂRŞIT dispariţie titlu din pagina principală
//============================================================
//============================================================
//
// ÎNCEPUT previzualizare rapidă
//
//============================================================
/**
* Script de ajoutant une option de prévisualisation rapide.
*
*
* English: Add a Quick View option on the Edit pages.
* This script add 2 new buttons into the "editButtons" div.
* When QuickPrev button is press, the content of edit window
* is retreived and parsed using regular expressions.
*
* @author: fr:user:aoineko
* @version: 0.2
*/
function addQuickPreview()
{
var QuickPreviewBtnTitle = "Previzualizare rapidă a modificărilor dumneavoastră [Alt + Q]";
var QuickPreviewBtnValue = "Previzualizare rapidă";
var QuickPrevHideBtnTitle = "Ascundeţi previzualizarea rapidă [Alt + H]";
var QuickPrevHideBtnValue = "Ascundeţi";
var div = document.getElementsByTagName('div');
for(var i = 0; i < div.length ; i++)
{
if(div[i].className == "editButtons") // search "editButtons" div
{
div[i].appendChild(document.createElement("br")); // add a <br/>
var wpQuick = document.createElement("input"); // create and set the "QuickPrev" button
wpQuick.setAttribute("id", "wpQuick");
wpQuick.setAttribute("name", "wpQuick");
wpQuick.setAttribute("title", QuickPreviewBtnTitle);
wpQuick.setAttribute("value", QuickPreviewBtnValue);
wpQuick.setAttribute("type", "button");
wpQuick.setAttribute("onclick", "doQuickPreview();");
wpQuick.setAttribute("tabindex", "8");
wpQuick.setAttribute("accesskey", "Q");
div[i].appendChild(wpQuick);
var wpHide = document.createElement("input"); // create and set the "Hide" button
wpHide.setAttribute("id", "wpHide");
wpHide.setAttribute("name", "wpHide");
wpHide.setAttribute("title", QuickPrevHideBtnTitle);
wpHide.setAttribute("value", QuickPrevHideBtnValue);
wpHide.setAttribute("type", "button");
wpHide.setAttribute("onclick", "hideQuickPreview();");
wpHide.setAttribute("tabindex", "9");
wpHide.setAttribute("accesskey", "H");
div[i].appendChild(wpHide);
}
}
}
/// Retreive current code and parse it
function doQuickPreview()
{
var wpQuickPreview = document.getElementById("wpQuickPreview");
if(!wpQuickPreview)
{
/*var l = document.getElementsByTagName('div');
for(var i = 0; i < l.length ; i++)
if(l[i].className == "previewnote")
wpQuickPreview = l;
if(!wpQuickPreview)*/
{
wpQuickPreview = document.createElement("div");
wpQuickPreview.setAttribute("style", "border:solid 1px gray; width:100%; margin-top:1em; margin-bottom:1em; padding:0.5em;");
var wpSummaryLabel = document.getElementById("wpSummaryLabel");
wpSummaryLabel.parentNode.insertBefore(wpQuickPreview, wpSummaryLabel);
}
wpQuickPreview.setAttribute("id", "wpQuickPreview");
}
wpQuickPreview.style.display = "block";
wpTextbox1 = document.getElementById("wpTextbox1");
var str = "=Previzualizare rapidă=\n" + wpTextbox1.value;
var qp = new QuickPreview(str);
wpQuickPreview.innerHTML = qp.Parse();
}
function QuickPreview(wiki)
{
this.line = wiki.split(/\n/);
this.html = new String;
this.list = 0; // current list depth
this.tab = 0; // current tabulation depth
this.pre = false; /// inside a <pre> tag
this.para = false; /// inside a paragraph
this.HandlePre = function(i)
{
if(this.line[i][0] == ' ')
{
if(this.para)
{
this.para = false;
this.html += "</p>\n";
}
if(!this.pre)
{
this.pre = true;
this.html += "<pre>\n";
}
this.html += this.line[i] + "\n";
return true;
}
else if(this.pre)
{
this.pre = false;
this.html += "</pre>\n";
}
return false;
};
this.HandleH = function(i)
{
if(res = this.line[i].match(/^(={1,6})(.*)\1(.*)$/))
{
this.line[i] = "<h" + res[1].length + ">" + res[2] + "</h" + res[1].length + ">" + res[3];
return true;
}
return false;
};
this.Parse = function()
{
this.html = "";
for(var i = 0; i < this.line.length ; i++)
{
var p = true;
if(this.HandlePre(i))
continue;
if(this.HandleH(i))
p = false;
if(p && !this.para)
{
this.para = true;
this.html += "<p>";
}
this.html += this.line[i]
// Sign //
.replace(/~{5}/g, Date())
.replace(/~{4}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px yellow;'>Semnătură</span> "+Date())
.replace(/~{3}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px yellow;'>Semnătură</span>")
// Style //
.replace(/'''''(.*?)''(.*?)'''/g, "<strong><em>$1</em>$2</strong>")
.replace(/'''''(.*?)'''(.*?)''/g, "<em><strong>$1</strong>$2</em>")
.replace(/'''(.*?)''(.*?)'''''/g, "<strong>$1<em>$2</em></strong>")
.replace(/'''''(.*?)''''/g, "<strong><em>\'$1</em></strong>")
.replace(/''''(.*?)''''/g, "<strong><em>$1</em></strong>")
.replace(/''''(.*?)'''/g, "<strong>\'$1</strong>")
.replace(/'''(.*?)'''/g, "<strong>$1</strong>")
.replace(/'''(.*?)''/g, "<em>\'$1</em>")
.replace(/''(.*?)''/g, "<em>$1</em>")
// List //
.replace(/^\*(.*)/g, "<li>$1</li>")
.replace(/^#(.*)/g, "<li>$1</li>")
.replace(/^:(.*)/g, "<li>$1</li>")
// Link //
.replace(/\{\{([^\|]*).*}}/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px lightgreen;'>Format : $1</span>")
.replace(/\[\[[Ii]magine:([^\|]*)[^\[]*\]\]/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px lightblue;'>Imagine : $1</span>")
.replace(/\[\[[Cc]ategorie:([^\|]*)[^\[]*\]\]/g, "<span style='padding:0.2em; margin:0.5em; border:dashed 1px #FF8080;'><a href='/wiki/Categorie:$1' title='$1'>Categorie : $1</a></span>")
.replace(/\[\[([^\[.]*)\|([^\[.]*)\]\]/g, "<a href='/wiki/$1' title='$1'>$2</a>")
.replace(/\[\[([^\[.]*)\]\]/g, "<a href='/wiki/$1' title='$1'>$1</a>")
/*
// Special //
.replace(/\n\n/g, "\n\n<br/>")
.replace(/(^|\n)-{4}(?!~)/g, "<hr/>")
// Table //
.replace(/(^|\n)\{\|(.*)/g, "$1<table $2>")
.replace(/(^|\n)\|}/g, "$1</table>")
.replace(/(^|\n)(\|.*)\|\|/g, "$1$2</td><td>")
.replace(/(^|\n)\|[^-}](.*)/g, "$1</td>$2<td>")
.replace(/(^|\n)(!.*)!!/g, "$1$2</th><th>")
.replace(/(^|\n)![^-](.*)/g, "$1</th>$2<th>")
*/
;
this.html += "\n";
}
return this.html;
};
};
/// Hide
function hideQuickPreview()
{
var wpQuickPreview = document.getElementById("wpQuickPreview");
if(wpQuickPreview)
{
wpQuickPreview.style.display = 'none';
}
}
jQuery(document).ready(addQuickPreview);
//============================================================
// SFÂRŞIT previzualizare rapidă
//============================================================
/*
</nowiki> </pre>
*/