cef/cef1/tests/cefclient/res/modaldialog.html
2012-04-03 01:27:13 +00:00

79 lines
1.5 KiB
HTML

<!doctype html>
<html>
<head>
<title>A Modal Dialog</title>
</head>
<body>
Argument:<input id="argument" type="text" size="32"><br>
<br>
Reply:<input id="reply" type="text" autofocus="autofocus" size="32"><br>
<p>
<button onclick="OnOK(false)">Cancel</button> <button onclick="OnOK(true)">OK</button>
</p>
<p id="time"></p>
<script>
function init()
{
timer();
setInterval(timer, 200);
setValueToId('argument', dialogArguments.msg);
}
function timer()
{
updateId("time",new Date().toLocaleString());
}
function updateId(id, html, append)
{
id = document.getElementById(id);
if (typeof html == "boolean")
html = html?"Yes":"No";
if (append)
id.innerHTML += html + '<br>';
else
id.innerHTML = html;
}
function setValueToId(id, v)
{
id = document.getElementById(id);
id.value = v;
}
function getValueFromId(id)
{
id = document.getElementById(id);
if (id)
return id.value;
else
return "";
}
function OnOK(what)
{
if (what)
returnValue = { dialogResult:true, msg: "'"+ getValueFromId('reply') + "'" };
else
returnValue = { dialogResult:false, msg:'(cancelled)' };
window.close();
}
function keydown(e)
{
if (!e) e= event;
if (e.keyCode == 27) {
OnOK(false);
} else if (e.keyCode == 13) {
OnOK(true);
}
}
document.addEventListener('keydown', keydown, false);
window.addEventListener('load', init, false);
</script>
</body>
</html>