-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.html
97 lines (77 loc) · 2.34 KB
/
base.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://cdn.jsdelivr.net/sockjs/0.3/sockjs.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(function() {
var conn = null;
function connect() {
disconnect();
link = 'http://' + window.location.host + '/viewer'
console.log(link)
conn = new SockJS(link);
console.log('Connecting...');
conn.onopen = function() {
console.log('Connected.');
update_ui();
};
conn.onmessage = function(e) {
console.log('Received: ' + e.data);
};
conn.onclose = function() {
console.log('Disconnected.');
conn = null;
update_ui();
};
}
function disconnect() {
if (conn != null) {
console.log('Disconnecting...');
conn.close();
conn = null;
update_ui();
}
}
function update_ui() {
var msg = '';
if (conn == null || conn.readyState != SockJS.OPEN) {
$('#status').text('disconnected');
$('#connect').text('Connect');
} else {
$('#status').text('connected (' + conn.protocol + ')');
$('#connect').text('Disconnect');
}
}
$('.add').click(function() {
console.log("add");
id = $(this).attr("data-id");
name = $(this);
quantity = $("#slider"+id).val();
console.log("ID:"+id);
console.log("QTY:"+quantity);
console.log("NAME:"+name);
conn.send("allo");
});
$('form').submit(function() {
var text = $('#text').val();
console.log('Sending: ' + text);
conn.send(text);
$('#text').val('').focus();
return false;
});
connect();
});
</script>
<style>
.no-link {cursor: default !important;font-weight: normal !important;background-color: white !important;}
</style>
</head>
<body>
{% block page %}{% end %}
</body>
</html>