-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplateCode.js
More file actions
66 lines (59 loc) · 1.85 KB
/
templateCode.js
File metadata and controls
66 lines (59 loc) · 1.85 KB
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
<html>
<head>
<title>Hello World</title>
</head>
<body>
<div>Hello to Watson on Node-RED</div>
<div id="id_hello">
<span>Hello</span>
<span id="id_nameout"></span>
</div>
<form id="id_form">
<div>
<span>
What is your name:
</span>
<span>
<input type="text" name="name"
id="id_name"/>
</span>
</div>
<div>
<input type="submit" value="Enter"
id="id_enter"/>
</div>
</form>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
setupPage();
});
function setupPage(){
$('#id_hello').hide();
$('#id_form').submit(onSubmitClicked);
enterbutton();
}
function onSubmitClicked(event){
$('#id_nameout').text($('#id_name').val());
$('#id_hello').show();
$('#id_form').hide();
event.preventDefault();
}
function enterbutton(){
$(function() {
$("form input").keypress(function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$('#id_enter').click();
return false;
} else {
return true;
}
});
});
}
</script>
</body>
</html>