Wikipedysta:Matma Rex/table.js
//zwinięte z http://ka.wikipedia.org/wiki/მედიავიკი:Common.js
function tableInit()
{
if(document.getElementById('wpTextbox1'))
{
var tableBoxCode =
'<h5>Generowanie tabeli</h5>'+
'<form onsubmit="tableGenerate(parseInt(document.paramForm.inputCol.value), parseInt(document.paramForm.inputRow.value), parseInt(document.paramForm.inputBorder.value), document.paramForm.inputHeader.checked, document.paramForm.inputLine.checked, document.paramForm.inputItems.checked, document.paramForm.inputAlign.value, document.paramForm.inputPad.checked);return false" name="paramForm">'+
'<label for="inputAlign">Wyrównanie (<tt>align</tt>):</label> '+
'<input type="text" name="inputAlign" id="inputAlign" value="center"><br />'+
'<label for="inputRow">Wiersze:</label> '+
'<input type="text" name="inputRow" id="inputRow" value="3"><br />'+
'<label for="inputCol">Kolumny:</label> '+
'<input type="text" name="inputCol" id="inputCol" value="3"><br />'+
'<label for="inputHeader">Tytuł:</label> '+
'<input type="checkbox" name="inputHeader" id="inputHeader" checked="1"><br />'+
'<label for="inputBorder">Obramowanie:</label> '+
'<input type="text" name="inputBorder" id="inputBorder" value="1"><br />'+
'<label for="inputPad">Padding:</label> '+
'<input type="checkbox" name="inputPad" id="inputPad"><br />'+
'<label for="inputLine">Kolorowanie wierszy:</label> '+
'<input type="checkbox" name="inputLine" id="inputLine" checked="1"><br />'+
'<label for="inputItems">Nagłówki w pionie:</label> '+
'<input type="checkbox" name="inputItems" id="inputItems">'+
'</form">'+
'<p><input type="submit" value="Wstaw kod" /></p>'
csslink=document.createElement('link')
csslink.rel="stylesheet"
csslink.type="text/css"
csslink.href="http://pl.wikipedia.org/w/index.php?title=Wikipedysta:Matma_Rex/table.css&action=raw&ctype=text/css&dontcountme=s"
document.getElementsByTagName('head')[0].appendChild(csslink)
var tableBox=document.createElement('div');
tableBox.style.cssText='border:1px solid #ccc; background:#eee; font-size:80%; display:none'
tableBox.id='insertingTable'
tableBox.innerHTML=tableBoxCode
el=document.getElementById('editform');
el.parentNode.insertBefore(tableBox,el);
}
}
function tableShowHide()
{
obj=document.getElementById('insertingTable')
if(obj.style.display=='none') obj.style.display=''
else obj.style.display='none'
}
function tableGenerate(nbCol, nbRow, border, styleHeader, styleLine, exfield, align, padding)
{
var code=''
if(styleHeader)
{
code += '{| style="'+(align=='center'?'margin:0 auto':'float:'+align)+';border:'+border+'px solid black;text-align:center;background:white"\n';
code += "|'''Tytuł'''\n";
if(padding)
{
code += '{| class="wikitable" cellpadding="0" cellspacing="0" style="margin:1em"'+"\n"
}
else
{
code += '{| class="wikitable" cellpadding="0" cellspacing="0" style="margin:0;margin-top:1em"'+"\n"
}
}
else
{
code += '{| style="'+(align=='center'?'margin:0 auto':'float:'+align)+';border:'+border+';text-align:center;background:white"\n';
code += '|+\n';
}
if(exfield) code += '!\n';
for (i=0;i<nbCol;i++)
{
code += '!style="background:#dfd"|Nagłówek '+(i+1)+'\n'
}
for (j=0,items=0;j<nbRow;j++)
{
if((j+1)%2==0 && styleLine)
{
code += '|- style="background:#efefef"\n'
}
else
{
code += '|-\n'
}
if(exfield)
{
items++
code += '!style="background:#fdd"|Nagłówek '+items+'\n'
}
for(i=0;i<nbCol;i++)
{
code += '|Komórka\n'
}
}
if (styleHeader) code += '|}\n'
code += '|}\n'
insertTags('','', code)
}
function tableButton()
{
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 a=document.createElement('a')
a.innerHTML='<img src="http://upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png" alt="Tabela" title="Wstaw tabelę" width="23" height="22" style="cursor:pointer" />'
a.href='javascript:tableShowHide()'
toolbar.appendChild(a)
}
$(tableButton)
$(tableInit)
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.