-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresent.html
More file actions
176 lines (168 loc) · 6.79 KB
/
Copy pathpresent.html
File metadata and controls
176 lines (168 loc) · 6.79 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
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
<html><head>
<title>control a screen</title></head>
<body>
<link href="https://pi.pe/pipe.css" media="all" rel="stylesheet" />
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<script src="https://pi.pe/iot/js/phono.sdp.js"></script>
<script type="text/javascript">
(function () {
function getFinger(descsdp) {
var sdp = Phono.sdp.parseSDP(descsdp)
var myfp = JSON.stringify(sdp.contents[0].fingerprint.print);
myfp = myfp.split(":").join("");
myfp = myfp.split('"').join("");
console.log("fingerprint is " + myfp)
return myfp;
};
PipeDb = {
addMyCertToPeerConf: function (peerconf, mkpc) {
mkpc();
},
dbAddPrint: function(print, doneCB) {
console.log("pretending to Add a new print ");
doneCB(print);
},
whoAmI: function (okCB, failCB) {
var peerconfig = {
"iceServers": [
{urls: "stun:146.148.121.175:3478"},
{urls: "turn:146.148.121.175:3478?transport=udp", 'credential': 'charliebrown', 'username': 'owner'},
],
"bundlePolicy":"max-bundle","iceCandidatePoolSize":1
};
var pc = new RTCPeerConnection(peerconfig, null);
pc.createDataChannel('echo', {});
pc.createOffer()
.then(function (localDesc) {
var myfp = getFinger(localDesc.sdp);
okCB(myfp,pc);
})
.catch(function (error) {
failCB(error);
});
}
};
}());
</script>
<script src="https://pi.pe/iot/js/pipeDuct.js"></script>
<script src="https://pi.pe/iot/js/qrcode.js"></script>
<script type="text/javascript">
var id = undefined;
var duct = null;
var pipe;
function onNewDc(channel) {
console.log("New DC ")
pipe.onmessage = onDcMessage;
}
function fakeonn(){
var pc = duct.peerCon;
var that = duct;
pc.createOffer(that.sdpConstraints).then(desc => {
pc.setLocalDescription(desc).then( _ => {
console.log("Set Local description");
that.sendSDP(pc);
});
}).catch (that.logError);
}
function sendUrl(d){
var page = d.firstElementChild.src;
var cmd = JSON.stringify({url:page});
console.log("sending cmd"+cmd);
pipe.send(cmd);
}
function makedc(tofinger,n) {
duct.setTo(tofinger);
duct.setNonce(n);
pipe = duct.createDataChannel("slide", {});
fakeonn();
var c = $('#myCarousel');
pipe.onopen = function() {
console.log ("have pipe");
c.on('slid.bs.carousel', function (ev) {
console.log(ev.relatedTarget);
sendUrl(ev.relatedTarget);
});
var active = c.find('.active');
};
pipe.onmessage = function(message) {};
pipe.onclose = function() {};
}
function gotId(liid,wcpc) {
id = liid;
duct = new PipeDuct(id);
duct.connect = function() {
var that = this;
var promise = new Promise(function(resolve, reject) {
that.withPc(wcpc, resolve);
});
return promise;
};
duct.setOnDataChannel(onNewDc);
duct.connect().then(function (d) {
console.log("connected as " + id);
var h = document.location.hash.substring(1);
var bs = h.split(":");
var q= bs[0];
var n = bs[1];
console.log("Q = "+q+" n= "+n);
makedc(q,n);
});
}
$(document).ready(function() {
PipeDb.whoAmI(gotId, function(err) {
console.log("could not create identity " + err)
});
});
</script>
<h1 id="title" class="text-center">Remote presenter</h1>
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active" id="1">
<img class="d-block img-fluid" src="slides/Slide01.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide02.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide03.jpg" />
</div>
<div class="carousel-item ">
<img class="d-block img-fluid" src="slides/Slide04.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide05.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide06.jpg" />
</div>
<div class="carousel-item ">
<img class="d-block img-fluid" src="slides/Slide07.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide08.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide09.jpg" />
</div>
<div class="carousel-item ">
<img class="d-block img-fluid" src="slides/Slide10.jpg" />
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="slides/Slide11.jpg" />
</div>
</div>
<a id="prev" class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a id="next" class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</body>
</html>