MediaWiki:Common.js
Ծանուցում. Հիշելուց հետո կատարված փոփոխությունները տեսնելու համար մաքրեք ձեր զննարկիչի հիշապահեստը. Mozilla / Firefox / Safari՝ Ctrl+Shift+R (Cmd+Shift+R Mac OS X-ում) Konqueror՝ F5 Opera՝ Tools→Preferences ընտրացանկից։ Internet Explorer՝ Ctrl+F5
// import scripts for Interwiki Transclusion from http://wikisource.org/wiki/Wikisource:Shared_Scripts
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:InterWikiTransclusion.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:DoubleWiki.js&action=raw&ctype=text/javascript');
/**********************
*** Display options (see [[template:option]])
*** by [[en:user:ThomasV]]
**********************/
function OptionText() {
var indexNavigationBar = 0;
// iterate over all < span >-elements until class "OptionText" is found
for(var i=0; SpanElem = document.getElementsByTagName("span")[i]; i++) {
// if found an option span
if (SpanElem.className == "OptionText") {
//SpanElem.style.display = 'none';
OptionTitle = SpanElem.title;
OptionStyle = SpanElem.firstChild.getAttribute('style');
//check if option was already encountered...
if(!document.getElementById(OptionTitle)) {
//read cookie
var DisplayOptionDefault = true;
CookieDisplayOption = $.cookie("Display"+OptionTitle);
if (CookieDisplayOption ) {
if (CookieDisplayOption == "false") {
DisplayOptionDefault = false;
}
}
var PageDisplay = document.createElement("li");
PageDisplay.setAttribute('id', OptionTitle);
var PageDisplayLink = document.createElement("a");
OptionText = document.createTextNode("Désactiver "+OptionTitle);
PageDisplayLink.appendChild(OptionText);
PageDisplayLink.setAttribute('href','javascript:displayOptionText("'+OptionTitle+'","' + OptionStyle +'", '+DisplayOptionDefault+');');
PageDisplay.appendChild(PageDisplayLink);
var optlist = document.getElementById("optlist");
if(!optlist) {
var displayOptions = document.createElement("div");
displayOptions.style.marginTop = "0.7em";
displayOptions.innerHTML = '<h5>դիտել<\/h5><div class="pBody"><ul id="optlist"></ul><\/div>';
document.getElementById("p-tb").appendChild(displayOptions);
optlist = document.getElementById("optlist");
}
optlist.appendChild(PageDisplay);
displayOptionText(OptionTitle,OptionStyle,DisplayOptionDefault);
}
}
}
}
function displayOptionText(optiontitle, optionstyle, bool) {
$.cookie("Display"+optiontitle,bool);
var PageDisplayLink = document.getElementById(optiontitle).firstChild;;
// iterate over all < span >-elements
for(var i=0; SpanElem = document.getElementsByTagName("span")[i]; i++) {
// if found an option text
if ((SpanElem.className == "OptionText") && (SpanElem.title == optiontitle)) {
if(bool==true ) {
SpanElem.setAttribute('style',optionstyle);
PageDisplayLink.firstChild.data = (optiontitle);
PageDisplayLink.setAttribute('href', 'javascript:displayOptionText("'+optiontitle+'","'+optionstyle+'", false);');
}
if(bool==false) {
SpanElem.setAttribute('style','null');
PageDisplayLink.firstChild.data = (optiontitle);
PageDisplayLink.setAttribute('href', 'javascript:displayOptionText("'+optiontitle+'","'+optionstyle+'", true);');
}
}
}
}
$(document).ready(OptionText);
/**********************
*** add menu on edit page /for selecting subsets of special characters
*** by [[en:user:Pathoschild]]
*** - note: must match MediaWiki:Edittools
**********************/
function addCharSubsetMenu() {
var specialchars = document.getElementById('specialchars');
if (specialchars) {
var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
menu += "<option>Ընտրել</option>";
menu += "<option>Սիմվոլներ և լիգատուրաներ</option>";
menu += "<option>Ակցենտներ</option>";
menu += "<option>Թիլդաներ</option>";
menu += "<option>Cedillas</option>";
menu += "<option>Diereses</option>";
menu += "<option>Circumflexes</option>";
menu += "<option>Macrons</option>";
menu += "<option>Other diacritics</option>";
menu += "<option>Հունարեն</option>";
menu += "<option>Եբրայերեն</option>";
menu += "<option>Կիրիլիկ</option>";
menu += "<option>IPA</option>";
menu += "<option>Հաճախակի_կաղապարներ</option>";
menu += "</select>";
specialchars.innerHTML = menu + specialchars.innerHTML.replace(/_newline_/gm, "\n");
/* default subset - try to use a cookie some day */
chooseCharSubset(0);
}
}
/* select subsection of special characters */
function chooseCharSubset(s) {
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = i == s ? 'inline' : 'none';
l[i].style.visibility = i == s ? 'visible' : 'hidden';
}
}
$(document).ready(addCharSubsetMenu);
/*
* port from [[:he:mediawiki:common.js]] for [[mediawiki:edittools]] -Steve
*/
/* פונקציה שמשמשת לאיפשור ניקוד ב[[מדיה ויקי:edittools]] */
function nikud(){
if (document.getElementById('edit-templates')!=null){
for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
if(a.className == "nikud") {
a.onclick=function(){insertTags('', this.title, '');return false;};
}
}
}
}
$(document).ready(nikud);
/**********************
*** Automatically generate page footer from values in {{header}}
*** by [[user:GrafZahl]]
**********************/
function DisplayFooter() {
if(document.getElementById && mw.config.get('wgNamespaceNumber')==0) {
nofooter = document.getElementById('nofooter');
hp = document.getElementById('headerprevious');
hn = document.getElementById('headernext');
content = document.getElementById('bodyContent');
catlinks = document.getElementById('catlinks');
footer = document.createElement('table');
//header_template = document.getElementById('headertemplate');
if( (!((content) && (footer))) || (!(hp || hn)) ||
(nofooter))
return;
footer.setAttribute('class', 'headertemplate');
footer.setAttribute('id', 'footertemplate');
footer.setAttribute('style', 'margin-top:1em; clear:both;');
/* Begin footer HTML code */
tr = document.createElement('tr');
td = document.createElement('td');
td.setAttribute('align', 'left');
td.setAttribute('width', '33%');
if (hp) {
fp = hp.cloneNode(true);
fp.setAttribute('id', 'footerprevious');
td.appendChild(fp);
}
tr.appendChild(td);
td = document.createElement('td');
td.setAttribute('align', 'center');
td.setAttribute('width', '34%');
a = document.createElement('a');
a.setAttribute('href', '#top');
text = document.createTextNode('▲ Վեր ▲');
a.appendChild(text);
td.appendChild(a);
tr.appendChild(td);
td = document.createElement('td');
td.setAttribute('align', 'right');
td.setAttribute('width', '33%');
if (hn) {
fn = hn.cloneNode(true);
fn.setAttribute('id', 'footernext');
td.appendChild(fn);
}
tr.appendChild(td);
footer.appendChild(tr);
/* End footer HTML code */
if(catlinks) // place footer before category box
content.insertBefore(footer, catlinks);
else
content.appendChild(footer);
}
}
$(document).ready(DisplayFooter);