/
Code.js
36 lines (29 loc) · 1.1 KB
/
Code.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
/**
* @OnlyCurrentDoc
*/
function onInstall(e) {
onOpen(e);
Logger.log(e.authMode);
}
/******************* UI **************************/
// Add the menu to the document.
/******************************************************/
function onOpen(e) {
var ui = DocumentApp.getUi();
ui.createAddonMenu().addItem("Watch", "showSidebar").addSeparator().addItem('About DocuTube', 'showAbout')
.addToUi();
}
// Abstract server-side methods
function DTApi(namespace, method) {
return this[namespace][method]
.apply(this,Array.prototype.slice.call(arguments,2));
}
function showAbout() {
var app = HtmlService.createHtmlOutputFromFile("about").setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL).setTitle("About DocuTube").setWidth(600).setHeight(300);
DocumentApp.getUi().showModalDialog(app, "About DocuTube");
}
// Build the app from a template and display embedded videos
function showSidebar() {
var app = HtmlService.createHtmlOutputFromFile("sidebar").setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL).setTitle("DocuTube Watch");
DocumentApp.getUi().showSidebar(app);
}