Jump to content

MediaWiki:Common.js/edit.js: Difference between revisions

writing code to insert call to BSL function template up through arg 1 (as a test); removing unused generateTable()
(preparing to write code for BSL function template wizard)
(writing code to insert call to BSL function template up through arg 1 (as a test); removing unused generateTable())
Line 538: Line 538:
var align = (f.inputAlign.checked) ? 'align="center"' : '';
var align = (f.inputAlign.checked) ? 'align="center"' : '';


//generateTable(caption, exhead, nbCol, nbRow, exfield, align);
var code = '\n';
var code = '\n';
code += '{| ' + align + ' ';
code += '{| ' + align + ' ';
Line 577: Line 576:
         /* Set width of popup (height has to be set in Live.css); labels on left are 115px,
         /* Set width of popup (height has to be set in Live.css); labels on left are 115px,
           and each column requires 150px as long as Name field is "size 20"; the 8 arguments
           and each column requires 150px as long as Name field is "size 20"; the 8 arguments
           are broken into two rows, so that means the first row has five columns, Name and
           are broken into two rows, so that means the first row has five columns: Name and
           arguments 1-4 */
           arguments 1-4 */
XEBPopup.prototype.width = 115 + (150 * 5);
XEBPopup.prototype.width = 115 + (150 * 5);
Line 679: Line 678:
function insertBSLFuncCode()
function insertBSLFuncCode()
{
{
var i;
var f = document.XEBPopupBSLFuncForm;
var f = document.XEBPopupBSLFuncForm;
var caption = (f.inputCaption.checked) ? '|+ TABLE CAPTION \n' : '';
var exhead = (f.inputHead.checked) ? '|- style="background: #DDFFDD;"\n' : '';
var nbRow = parseInt(f.inputRow.value, 10);
var nbCol = parseInt(f.inputCol.value, 10);
var exfield = f.inputItems.checked;
var align = (f.inputAlign.checked) ? 'align="center"' : '';


//generateTable(caption, exhead, nbCol, nbRow, exfield, align);
var call = '{{BSLfunc\n';
var code = '\n';
call += '|type=' + f.inputFuncType + '\n';
code += '{| ' + align + ' ';
call += '|default=' + f.inputDefault + '\n';
code += (f.inputSort.checked) ? 'class="wikitable sortable" \n' : '\n';
call += '|name=' + f.inputFuncName + '\n';
code += caption + exhead;
if (!f.inputMac) call += '|mac=no\n';
if (exfield) {
if (!f.inputWin) call += '|win=no\n';
code += '!\n';
 
}
if (f.inputArg1Name)
for (i = 1; i < nbCol + 1; i++) {
{
code += '! COLUMN ' + i + '\n';
if (f.inputArg1Opt) call += "|arg1optional=yes\n';
}
call += '|arg1default=' + f.inputArg1Default + '\n';
var items = 0;
call += '|arg1type=' + f.inputArg1Type + '\n';
for (var j = 0; j < nbRow; j++) {
call += '|arg1name=' + f.inputArg1Name + '\n';
if (exfield) {
if (f.inputArg1Alt)
items++;
{
code += '|-\n! style="background: #FFDDDD;"|ITEM ' + items + '\n';
call += '|arg1alttype=' + f.inputArg1AltType + '\n';
} else {
call += '|arg1altname=' + f.inputArg1AltName + '\n';
code += '|-\n';
}
for (i = 0; i < nbCol; i++) {
code += '| Element ' + i + '\n';
}
}
}
}
code += '|}\n';
call += '}}';
hideXEBPopup();
hideXEBPopup();
insertTags('', '', code);
insertTags('', '', call);
extendSummary(f.inputFuncName);
extendSummary('added ' + f.inputFuncName);


return false;
return false;
Line 840: Line 829:
txtarea.focus();
txtarea.focus();
}
}
//============================================================
// Table generator
//============================================================
/** en: Generate an array using MediaWiki syntax
* @author: originally from fr:user:dake
* @version: 0.2 */
function generateTable(caption, exhead, nbCol, nbRow, exfield, align) {
}


function XEBPopupRef(e) {
function XEBPopupRef(e) {