/
sidebar.html
87 lines (85 loc) · 3.13 KB
/
sidebar.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
<!DOCTYPE html>
<html>
<head>
<base target="_top" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link
rel="stylesheet"
href="https://ssl.gstatic.com/docs/script/css/add-ons.css"
/>
<style>
body {
font-family: sans-serif;
}
#search-result > img {
width: 320px;
height: 180px;
display: block;
margin: 15px auto 0;
}
#embed {
width: 100%;
font-family: sans-serif;
}
#srcSelect {
width: 100%;
margin-bottom: 10px;
}
#srcSelect span {
display: inline-block;
margin-right: 15px;
color: rgba(255, 255, 255, 1);
background-color: rgba(0, 0, 255, 0.8);
cursor: pointer;
border-radius: 3px;
border: 1px solid rgba(0, 0, 180, 0.8);
padding: 12px;
}
#srcSelect span:hover {
color: rgba(0, 0, 180, 1);
background-color: rgba(255, 255, 255, 0.8);
}
</style>
</head>
<body>
<div id="embed">
<p>
<b>DocuTube</b> will show videos linked in your document here so
you don't have to leave your work.
</p>
<button id="load-video-btn" class="action" onclick="loadVideos()">
Load Videos
</button>
</div>
</body>
<script type="text/javascript">
function loadVideos() {
// On the server, process the document and display the returned values.
google.script.run
.withSuccessHandler(showFrames)
.DTApi('DT', 'getVideos');
}
function showFrames(frames) {
const container = document.querySelector(`#embed`);
container.innerHTML = ``;
for (var i = 0; i < frames.length; i++) {
if (frames[i].type === 'video') {
container.insertAdjacentHTML(
'beforeend',
`<iframe src="https://youtube.com/embed/${frames[i].id}" width='100%' height='auto' frameborder='0' allowfullscreen></iframe><hr />`,
);
} else if (frames[i].type === 'playlist') {
container.insertAdjacentHTML(
'beforeend',
`<iframe src="https://youtube.com/embed/videoseries?list=${frames[i].id}" width='100%' height='auto' frameborder='0' allowfullscreen></iframe><hr />`,
);
} else if (frames[i].type === 'channel') {
container.insertAdjacentHTML(
'beforeend',
`<h3>No preview available. <a href="https://youtube.com/channel/${frames[i].id}" target='_blank'>Go to the channel</h3><hr />`,
);
}
}
}
</script>
</html>