mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
refactor: one method for rows of buttons
This commit is contained in:
parent
ae4985e518
commit
07d5bd9883
1 changed files with 27 additions and 22 deletions
|
@ -102,22 +102,28 @@ function newDlgWMsg(msg) {
|
||||||
return dlg;
|
return dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nbDialog(msg, buttons, proc, closure) {
|
function newButtonDiv(buttons, proc) {
|
||||||
let dlg = newDlgWMsg( msg );
|
let div = document.createElement('div');
|
||||||
|
div.classList.add('buttonRow');
|
||||||
let span = document.createElement('div');
|
|
||||||
span.classList.add('buttonRow');
|
|
||||||
for ( let buttonTxt of buttons ) {
|
for ( let buttonTxt of buttons ) {
|
||||||
let button = document.createElement('button');
|
let button = document.createElement('button');
|
||||||
button.textContent = buttonTxt;
|
button.textContent = buttonTxt;
|
||||||
button.onclick = function() {
|
button.onclick = function() { proc(buttonTxt); };
|
||||||
|
div.appendChild( button );
|
||||||
|
}
|
||||||
|
|
||||||
|
return div;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nbDialog(msg, buttons, proc, closure) {
|
||||||
|
let dlg = newDlgWMsg( msg );
|
||||||
|
|
||||||
|
butProc = function(buttonTxt) {
|
||||||
Module.ccall('onDlgButton', null, ['number', 'number', 'string'],
|
Module.ccall('onDlgButton', null, ['number', 'number', 'string'],
|
||||||
[proc, closure, buttonTxt]);
|
[proc, closure, buttonTxt]);
|
||||||
dlg.parentNode.removeChild(dlg);
|
dlg.parentNode.removeChild(dlg);
|
||||||
};
|
|
||||||
span.appendChild( button );
|
|
||||||
}
|
}
|
||||||
dlg.appendChild( span );
|
dlg.appendChild( newButtonDiv( buttons, butProc ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function nbGetString(msg, dflt, proc, closure) {
|
function nbGetString(msg, dflt, proc, closure) {
|
||||||
|
@ -134,16 +140,15 @@ function nbGetString(msg, dflt, proc, closure) {
|
||||||
[proc, closure, str]);
|
[proc, closure, str]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let buttons = document.createElement('div');
|
buttons = ["Cancel", "OK"];
|
||||||
dlg.appendChild(buttons);
|
butProc = function(str) {
|
||||||
let cancel = document.createElement('button');
|
if ( str == buttons[0] ) {
|
||||||
cancel.textContent = "Cancel";
|
dismissed(null);
|
||||||
buttons.appendChild(cancel);
|
} else if ( str == buttons[1] ) {
|
||||||
cancel.onclick = function() { dismissed(null);}
|
dismissed(tarea.value);
|
||||||
let ok = document.createElement('button');
|
}
|
||||||
ok.textContent = 'OK';
|
}
|
||||||
buttons.appendChild(ok);
|
dlg.appendChild( newButtonDiv( buttons, butProc ) );
|
||||||
ok.onclick = function() { dismissed(tarea.value);}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( let one of ['paho-mqtt.js'] ) {
|
for ( let one of ['paho-mqtt.js'] ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue