forked from calderonroberto/thingbroker-jquery-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (62 loc) · 2.21 KB
/
index.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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Shout</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.thingbroker.js"></script>
<script type="text/javascript" src="processing-1.4.1.min.js"></script>
<style type="text/css">
p {color:gray;font-size:16px; font-style:bold; width:100px; height:100px; background-color:#E9E74A; float:left; margin-left:5px; margin-top:5px;padding:4px}
</style>
<script type="text/javascript">
function drawSomeText(id) {
var pjs = Processing.getInstanceById(id);
var text = document.getElementById('inputtext').value;
pjs.drawText(text);
}
function submitTask(id) {
var taskText = document.getElementById('inputtext').value;
var event = {task:taskText};
var t = $.ThingBroker({debug:true});
t.postThing("#tasks");
var e = t.postEvent("#tasks", event);
}
function visualizeTasks(id) {
var pjs = Processing.getInstanceById(id);
var e = $.ThingBroker().getEvents("#tasks");
pjs.drawTasks(e);
}
function appendChat() {
var t = document.getElementById('inputtext').value;
var event = {append:"<p>"+t+"</p>"};
$.ThingBroker({debug:true}).postEvent("#chat", event);
}
</script>
</head>
<body>
<canvas id="demoprocessing" data-processing-sources="demoprocessing.pde"></canvas>
<br>
<input type="textfield" value="my text" id="inputtext">
<button type="button" onclick="appendChat()">append to chat</button>
<button type="button" onclick="submitTask()">submitTask</button>
<hr>
<input type="text" id="txtbox" />
<div id="chat"><p>Chat Div.</p></div>
<div id="tasks"></div>
<script type="text/javascript">
$("#chat").thing({listen:true, debug: true});
$("#txtbox").keypress(function(e){
if (e.which == 13) {
$(this).thing({prepend:'<p>'+$(this).val()+'</p>', to: '#chat', debug: true});
$(this).val("");
}
});
$("#tasks").thing({listen:true,
debug:true,
eventCallback:function(json){
visualizeTasks('demoprocessing');
}
});
</script>
</body>
</html>