-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
191 lines (165 loc) · 6.11 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html>
<html>
<head>
<title>SignalRamp Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow">
<style type="text/css">
body
{
font-family: 'Trebuchet MS';
}
.container
{
padding: 5px;
margin: 5px;
background-color: #a5a5a5;
max-width:320px;
}
.container input
{
width:30px;
}
.container input[type='text'],textarea
{
width:300px;
}
.container label
{
cursor:pointer;
}
.container textarea
{
height:100px;
}
.interact
{
cursor:pointer;
width: 100px;
height:100px;
text-align:center;
padding: 10px;
background-color:#F8F8F8;
}
#divClickable
{
background-color:#F8F8F8;
border:1px solid #000;
}
</style>
<!-- jquery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" type="text/javascript"></script>
<!-- local js -->
<script type="text/javascript" src="jquery.signalR-1.0.0.js"></script>
<script type="text/javascript" src="jquery.signalRamp.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//only sync elements across pages inside the #holdElements container
//the proxyName MUST be unique to the listeners of this section.
$("#holdElements").signalRamp({
proxyName: 'uniqueName'
, sensibility: 0
, callbacks: {
bridgeStarted: function (name, bridge) {
//the bridge has started
}
,
bridgeInitialized: function (bridge, done) {
//the bridge hasn't started yet, so add
//custom proxy events to the bridge here
done(); //callback when complete
}
, valueChanged: function (id, val) {
//a value of the wired elements has changed
}
, checkChanged: function (id, check) {
//the check property of one of the wired elements has changed
}
, uiEventChanged: function (id, type) {
//a mouseover, mouseout, mousedown, mouseup, or click (type) event
//fired on one of the wired elements
}
,
dataSend: function (pkg, done) {
//prior to a pkg being sent, you can augment
//the pkg call here with server side actions
done();
}
,
dataReceive: function (pkg) {
//data was received, you can check the status
//of an action wired on the dataSend here
//TODO: explain what this means!
}
}
});
//local event handlers are all that is required
//when dom elements are decorated with the appropriate
//signalRamp class, these events will fire across
//all subscribed clients
$("#divClickable").click(function (e) {
var bg = $(this).css("background-color");
if (bg === "rgb(248, 248, 248)") {
$(this).css("background-color", "#f99");
} else {
$(this).css("background-color", "#f8f8f8");
}
});
$("#divHoverable").mouseover(function (e) {
$(this).css("border", "2px solid blue");
});
$("#divHoverable").mouseout(function (e) {
$(this).css("border", "none");
});
$("#divOverOut").mousedown(function (e) {
$(this).css("border", '2px solid green');
});
$("#divOverOut").mouseup(function (e) {
$(this).css("border", 'none');
});
});
</script>
<meta name="viewport" content="width=device-width, maximum-scale=1.0" />
</head>
<body>
<h2>SignalRamp Demo</h2>
<p>Below are the currently supported scenarios. Changes in values and checked status, as well as click, mousedown, mouseup, and hover events will propagate to all subscribed clients.</p>
<div id="holdElements">
<div class="container">
<input type="text" id="txtFirst" />
</div>
<div class="container">
<label for="chkFirst"><input type="checkbox" id="chkFirst" />Checkbox</label>
</div>
<div class="container">
<label for="radioFirst"><input type="radio" name="radioGroup" id="radioFirst" />First</label>
<br />
<label for="radioSecond"><input type="radio" name="radioGroup" id="radioSecond" />Second</label>
</div>
<div class="container">
<select id='selectFirst'>
<option id="optFirst">first</option>
<option id="optSecond">second</option>
</select>
</div>
<div class="container">
<textarea id="areaFirst">some text</textarea>
</div>
<div class="container">
<div id="divClickable" class="interact signalRampClick">
CLICK ME
</div>
</div>
<div class="container">
<div id="divHoverable" class="interact signalRampHover">
HOVER ME
</div>
</div>
<div class="container">
<div id="divOverOut" class="interact signalRampMouseDown signalRampMouseUp">
MOUSE DOWN AND UP
</div>
</div>
</div>
</body>
</html>