-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
30 lines (28 loc) · 1003 Bytes
/
example.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contentcommandable</title>
</head>
<body>
<h2>Content editable:</h2>
<div id="contentcommandable" contenteditable="true" style="background: #eee;">Hello</div>
<h2>Commands:</h2>
<button onclick="document.querySelector('#buffer').innerHTML = '';">Clear</button>
<div id="buffer" style="overflow-y: auto; max-height:500px;"></div>
<script type="application/javascript">var module = {};</script>
<script type="application/javascript" src="contentcommandable.js"></script>
<script type="application/javascript">
window.onload = function() {
var buffer = document.querySelector('#buffer');
contentCommandable(document.querySelector('#contentcommandable'), function(msg, arg) {
var newItem = document.createElement('div');
newItem.innerText = msg + ', ' + arg;
buffer.appendChild(newItem);
console.log(msg + ', ' + arg);
buffer.scrollTop = buffer.scrollHeight;
});
};
</script>
</body>
</html>