-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.html
45 lines (39 loc) · 1.07 KB
/
test.html
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
<!doctype html>
<html>
<head>
</head>
<body>
<input type="text" id="textInput"></input>
<textarea id="textArea"></textarea>
<script src="./caret-position.js"></script>
<script>
function assert(truthy, message) {
if (truthy) { return }
alert("Failed assert: " + message)
}
function test(input) {
caretPosition.set(input, 1)
var position = caretPosition.get(input)
var message = 'get/set position 1'
assert(position.start == 1, message)
assert(position.end == 1, message)
assert(position.caret == 1, message)
caretPosition.set(input, 1, 3)
var position = caretPosition.get(input)
console.log(position)
var message = 'get/set position 1,3'
assert(position.start == 1, message)
assert(position.end == 3, message)
assert(position.caret == 3, message)
}
window.onload = function() {
var textInput = document.getElementById('textInput'),
textArea = document.getElementById('textArea'),
testText = 'lorem ipsum dolores samblum dictatum'
textInput.value = textArea.value = testText
test(textInput)
test(textArea)
}
</script>
</body>
</html>