-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.js
97 lines (81 loc) · 2.69 KB
/
plugin.js
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
options.plugins.push(
RevealChalkboard,
RevealMenu,
RevealChart,
RevealFullscreen,
RevealPoll,
RevealQnA,
RevealSeminar,
RevealAudioSlideshow,
RevealAudioRecorder
);
function generateToken(length) {
var token = "";
while (token.length < length) {
token += (Math.random() * new Date().getTime()).toString(36).replace(/\./g, '');
}
return token.substr(0, length);
}
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function addParam(url, param, value) {
var a = document.createElement('a'),
regex = /(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;
var match, str = [];
a.href = url;
param = encodeURIComponent(param);
while (match = regex.exec(a.search)) {
if (param != match[1]) str.push(match[1] + (match[2] ? "=" + match[2] : ""));
}
str.push(param + (value ? "=" + encodeURIComponent(value) : ""));
a.search = str.join("&");
return a.href;
}
function logger(event) {
//document.getElementById("seminar-status").innerHTML = event;
console.log(event);
}
window.onload = function () {
var room = getParameterByName("room") || generateToken(32);
var link = addParam(window.location.href, "room", room);
var roomElement = document.getElementById("room");
console.log('roomElement=' + roomElement);
if (roomElement !== null && typeof roomElement !== null && roomElement !== 'undefined') {
console.log("room get");
document.getElementById("room").innerHTML = link;
document.getElementById("room").href = link;
}
var hostElement = document.querySelector("#host");
console.log('hostElement=' + hostElement);
if (hostElement !== null && typeof hostElement !== null && hostElement !== 'undefined') {
console.log("host get");
document.querySelector("#host").addEventListener('click', function (e) {
e.preventDefault();
RevealSeminar.open_or_join_room(Reveal.getConfig().seminar.password);
});
}
var closeElement = document.querySelector("#close");
console.log('closeElement=' + closeElement);
if (closeElement !== null && typeof closeElement !== null && closeElement !== 'undefined') {
console.log("close get");
document.querySelector("#close").addEventListener('click', function (e) {
e.preventDefault();
RevealSeminar.close_room(Reveal.getConfig().seminar.password);
});
}
var qrcode = new QRious({
element: document.getElementById('qrcode'),
level: 'H',
size: 500,
value: link
});
}