MediaWiki:Gadget-VertTableau.js: Skirtumas tarp puslapio versijų

Puslapis iš Vikižodyno, laisvojo žodyno.
Ištrintas turinys Pridėtas turinys
Hoo man (aptarimas | indėlis)
S Bot: Security fix: protocol-relative URLs per https://meta.wikimedia.org/?oldid=3197161 (questions?).
Nėra keitimo santraukos
109 eilutė: 109 eilutė:
}
}


addOnloadHook(vert_tab);
$(vert_tab);

07:45, 21 gruodžio 2015 versija

function tabElem(pcode, pname, pselected){
  this.code = pcode;
  this.name = pname;
  this.selected = pselected;
}

var tabArray = new Array();
tabArray[0] = new tabElem('trans', 'Vertimai', true);
tabArray[1] = new tabElem('sin', 'Sinonimai', false);
tabArray[2] = new tabElem('ant', 'Antonimai', false);
tabArray[3] = new tabElem('rel', 'Išraiškos arba posakiai', false);
var userKlb = 'lt';
var userKat = '';
var userEti = '';
var userNaud = '';
var userSinKat = '';
var userSinSin = '';
var userAntKat = '';
var userAntAnt = '';
var userRelKat = '';
var userRelRel = '';
var userTransKat = '';
var userTransKlb = '';
var userVert = '';
var userTransKlb2 = '';
var userVert2 = '';
var userText = '';

function generateVert(typeNr, iHeader, kat)
{
	var bcode = "\n";
	if (iHeader==1)
		bcode += '<br clear=all />\n==== '+tabArray[typeNr].name+' ====\n\n';
        var iKat = kat;
        if (iKat.length == 0)
           iKat = userKat;
        bcode += '{'+'{'+tabArray[typeNr].code+'-top|'+iKat+'}'+'}\n';
	var ecode = '';
        if (typeNr > 0)
           bcode += '* ';
        else
           bcode += '';
	ecode += '\n{'+'{'+tabArray[typeNr].code+'-mid}'+'}\n';
	ecode += '{'+'{'+tabArray[typeNr].code+'-bottom}'+'}\n';
	insertTags(bcode, ecode, ''); 
}

function popupVert()
{
  var popup = window.open('','name','height=400,width=500');
  
  javaCode  =  '<script type="text\/javascript"> ';
  javaCode +=  'function insertCode(){ ';
  javaCode += 'var typeCode = parseInt(document.paramForm.inputType.selectedIndex); '
  javaCode += 'var iHeader = document.paramForm.inputHeader.checked; '
  javaCode += 'var kat = document.paramForm.inputKat.value; '
  javaCode += 'window.opener.generateVert(typeCode,iHeader,kat); '
  javaCode += 'window.close(); '
  javaCode += '}<\/script>';

  var ltyp = "<select name=\"inputType\"> ";
  for (i=0; i<tabArray.length; i++){
    ltyp += '<option value="'+tabArray[i].code+'" '+((tabArray[i].selected)?'selected="selected"':'')+'>'+tabArray[i].name+'</option> ';
  }
  ltyp += "</select> ";
  
  popup.document.write('<html><head><title>Kategorizuotos lentelės įterpimas</title>');
  popup.document.write('<script type="text\/javascript" src="\/skins-1.5\/common\/wikibits.js"><!-- wikibits js --><\/script>');
  popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>');
  popup.document.write(javaCode); 
  popup.document.write('</head><body>');
  popup.document.write('<p>Kategorizuotos lentelės įterpimas į „'+wgTitle+'“.</p>');
  popup.document.write('<p>Prašome pasirinkti įterpiamos lentelės parametrus: </p>');
  popup.document.write('<form name="paramForm"><table border=0>');
  popup.document.write('<tr><td>Lentelės tipas:</td><td>'+ltyp+'</td></tr>');
  popup.document.write('<tr><td>Ar įterpti antraštinę eilutę:</td><td><input type="checkbox" name="inputHeader" checked="1" ></td></tr>');
  popup.document.write('<tr><td>Kategorija:</td><td><input type="text" name="inputKat" value="" ></td></tr>');
  popup.document.write('</table></form">');
  popup.document.write('<p><a href="javascript:insertCode()">Įterpti kodą</a></p>');
  popup.document.write('<p><a href="javascript:self.close()">Uždaryti</a></p>');
  popup.document.write('</body></html>');
  popup.document.close();
}

function vert_tab()
{
var toolbar = document.getElementById('toolbar');
if (!toolbar) return false;
 
var textbox = document.getElementById('wpTextbox1');
if (!textbox) return false;
 
if (!document.selection && textbox.selectionStart == null)
return false;
 
var image = document.createElement("img");
image.width = 23;
image.height = 22;
image.src = '//upload.wikimedia.org/wikipedia/commons/b/b6/Button_code1.png';
image.border = 0;
image.alt = 'Kategorizuota lentelė';
image.title = 'Kategorizuota lentelė';
image.style.cursor = "pointer";
image.onclick = function() {
   popupVert();
   return false;
}
toolbar.appendChild(image);
}

$(vert_tab);