blob: e711b31e057cdcd1c2ceea390c687c63fcceb914 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<head>
<title>Testing Javascript</title>
<meta name="viewport" content="user-scalable=no">
<script type="text/javascript">
const seen = {};
function updateResult(event) {
document.getElementById('result').innerText = event.target.value;
}
function displayMessage(message) {
document.getElementById('result').innerText = message;
}
function appendMessage(message) {
document.getElementById('result').innerText += " " + message + " ";
}
</script>
</head>
<body>
<h1>Type Stuff</h1>
<div id="resultContainer">
Result: <p id="result"></p>
</div>
<div>
<form action="#">
<p>
<label>keyDown: <input type="text" id="keyDown" onkeydown="updateResult(event)"/></label>
<label>keyPress: <input type="text" id="keyPress" onkeypress="updateResult(event)"/></label>
<label>keyUp: <input type="text" id="keyUp" onkeyup="updateResult(event)"/></label>
<label>change: <input type="text" id="change" onchange="updateResult(event)"/></label>
</p>
<p>
<label>change:
<input type="checkbox" id="checkbox" value="checkbox thing" onchange="updateResult(event)"/>
</label>
</p>
<p>
<label>keyDown:
<textarea id="keyDownArea" onkeydown="updateResult(event)" rows="2" cols="15"></textarea>
</label>
<label>keyPress:
<textarea id="keyPressArea" onkeypress="updateResult(event)" rows="2" cols="15"></textarea>
</label>
<label>keyUp:
<textarea id="keyUpArea" onkeyup="updateResult(event)" rows="2" cols="15"></textarea>
</label>
</p>
<p>
<select id="selector" onchange="updateResult(event)">
<option value="foo">Foo</option>
<option value="bar">Bar</option>
</select>
</p>
</form>
</div>
<div id="formageddon">
<form action="#">
Key Up: <input type="text" id="keyUp" onkeyup="javascript:updateContent(this)"/><br/>
Key Down: <input type="text" id="keyDown" onkeydown="javascript:updateContent(this)"/><br/>
Key Press: <input type="text" id="keyPress" onkeypress="javascript:updateContent(this)"/><br/>
Change: <input type="text" id="change" onkeypress="javascript:displayMessage('change')"/><br/>
<textarea id="keyDownArea" onkeydown="javascript:updateContent(this)" rows="2" cols="15"></textarea>
<textarea id="keyPressArea" onkeypress="javascript:updateContent(this)" rows="2" cols="15"></textarea>
<textarea id="keyUpArea" onkeyup="javascript:updateContent(this)" rows="2" cols="15"></textarea>
<select id="selector" onchange="javascript:updateContent(this)">
<option value="foo">Foo</option>
<option value="bar">Bar</option>
</select>
<input type="checkbox" id="checkbox" value="checkbox thing" onchange="javascript:updateContent(this)"/>
<input id="clickField" type="text" onclick="document.getElementById('clickField').value='Clicked';" value="Hello"/>
<input id="doubleClickField" type="text" onclick="document.getElementById('doubleClickField').value='Clicked';" ondblclick="document.getElementById('doubleClickField').value='DoubleClicked';" oncontextmenu="document.getElementById('doubleClickField').value='ContextClicked'; return false;" value="DoubleHello"/>
<input id="clearMe" value="Something" onchange="displayMessage('Cleared')"/>
<input type="text" id="notDisplayed" style="display: none">
</form>
</div>
<div>
<form>
<input type="text" id="keyReporter" size="80"
onkeyup="appendMessage('up: ' + event.keyCode)"
onkeypress="appendMessage('press: ' + event.keyCode)"
onkeydown="displayMessage(''); appendMessage('down: ' + event.keyCode)" />
<input name="suppress" onkeydown="if (event.preventDefault) event.preventDefault(); event.returnValue = false; return false;" onkeypress="appendMessage('press');"/>
</form>
</div>
</body>
</html>
|