mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
add alert for asking user for string
This commit is contained in:
parent
52773c577f
commit
007e1e4acb
3 changed files with 48 additions and 4 deletions
|
@ -78,6 +78,13 @@ EM_JS(void, call_dialog, (const char* str, const char** but_strs,
|
||||||
nbDialog(UTF8ToString(str), buttons, proc, closure);
|
nbDialog(UTF8ToString(str), buttons, proc, closure);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
EM_JS(void, call_get_string, (const char* msg, const char* dflt,
|
||||||
|
AlertProc proc, void* closure), {
|
||||||
|
let jsMgs = UTF8ToString(msg);
|
||||||
|
let jsDflt = UTF8ToString(dflt);
|
||||||
|
nbGetString( jsMgs, jsDflt, proc, closure );
|
||||||
|
} );
|
||||||
|
|
||||||
EM_JS(void, call_haveDevID, (void* closure, const char* devid), {
|
EM_JS(void, call_haveDevID, (void* closure, const char* devid), {
|
||||||
onHaveDevID(closure, UTF8ToString(devid));
|
onHaveDevID(closure, UTF8ToString(devid));
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,6 +67,11 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea.stringedit {
|
||||||
|
rows: 1;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="centered">
|
<body class="centered">
|
||||||
|
|
|
@ -87,17 +87,23 @@ function mqttSend( topic, ptr ) {
|
||||||
return canSend;
|
return canSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nbDialog(msg, buttons, proc, closure) {
|
function newDlgWMsg(msg) {
|
||||||
let container = document.getElementById('nbalert');
|
let container = document.getElementById('nbalert');
|
||||||
|
|
||||||
let dlg = document.createElement('div');
|
let dlg = document.createElement('div');
|
||||||
dlg.classList.add('nbalert');
|
dlg.classList.add('nbalert');
|
||||||
dlg.style.zIndex = 10000;
|
dlg.style.zIndex = 10000 + container.childElementCount;
|
||||||
container.appendChild( dlg );
|
container.appendChild( dlg );
|
||||||
|
|
||||||
let txtDiv = document.createElement('div');
|
let txtDiv = document.createElement('div');
|
||||||
dlg.appendChild( txtDiv );
|
|
||||||
txtDiv.textContent = msg
|
txtDiv.textContent = msg
|
||||||
|
dlg.appendChild( txtDiv );
|
||||||
|
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nbDialog(msg, buttons, proc, closure) {
|
||||||
|
let dlg = newDlgWMsg( msg );
|
||||||
|
|
||||||
let span = document.createElement('div');
|
let span = document.createElement('div');
|
||||||
span.classList.add('buttonRow');
|
span.classList.add('buttonRow');
|
||||||
|
@ -107,13 +113,39 @@ function nbDialog(msg, buttons, proc, closure) {
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
Module.ccall('onDlgButton', null, ['number', 'number', 'string'],
|
Module.ccall('onDlgButton', null, ['number', 'number', 'string'],
|
||||||
[proc, closure, buttonTxt]);
|
[proc, closure, buttonTxt]);
|
||||||
container.removeChild(dlg);
|
dlg.parentNode.removeChild(dlg);
|
||||||
};
|
};
|
||||||
span.appendChild( button );
|
span.appendChild( button );
|
||||||
}
|
}
|
||||||
dlg.appendChild( span );
|
dlg.appendChild( span );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nbGetString(msg, dflt, proc, closure) {
|
||||||
|
let dlg = newDlgWMsg( msg );
|
||||||
|
|
||||||
|
let tarea = document.createElement('textarea');
|
||||||
|
tarea.classList.add('stringedit');
|
||||||
|
tarea.value = dflt;
|
||||||
|
dlg.appendChild( tarea );
|
||||||
|
|
||||||
|
dismissed = function(str) {
|
||||||
|
dlg.parentNode.removeChild(dlg);
|
||||||
|
Module.ccall('onDlgButton', null, ['number', 'number', 'string'],
|
||||||
|
[proc, closure, str]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let buttons = document.createElement('div');
|
||||||
|
dlg.appendChild(buttons);
|
||||||
|
let cancel = document.createElement('button');
|
||||||
|
cancel.textContent = "Cancel";
|
||||||
|
buttons.appendChild(cancel);
|
||||||
|
cancel.onclick = function() { dismissed(null);}
|
||||||
|
let ok = document.createElement('button');
|
||||||
|
ok.textContent = 'OK';
|
||||||
|
buttons.appendChild(ok);
|
||||||
|
ok.onclick = function() { dismissed(tarea.value);}
|
||||||
|
}
|
||||||
|
|
||||||
for ( let one of ['paho-mqtt.js'] ) {
|
for ( let one of ['paho-mqtt.js'] ) {
|
||||||
let script = document.createElement('script');
|
let script = document.createElement('script');
|
||||||
script.src = one
|
script.src = one
|
||||||
|
|
Loading…
Reference in a new issue