-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCode.gs
More file actions
46 lines (38 loc) · 1.03 KB
/
Code.gs
File metadata and controls
46 lines (38 loc) · 1.03 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
//https://developers.google.com/apps-script/guides/services/authorization#manual_authorization_scopes_for_sheets_docs_and_forms
/*
Make the extension only avaible to the current document
*/
/**
* @OnlyCurrentDoc
*/
function onOpen() {
SpreadsheetApp.getUi().createMenu('Fit Sync')
.addItem('Menu', 'showSidebar')
.addItem('Refresh Data', 'loadDataToSpreadSheet')
.addToUi();
Logger.log("started");
loadDataToSpreadSheet();
}
function showSidebar() {
var html = doGet().setTitle('Fit Sync').setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
function onInstall(){
onOpen();
/*https://developers.google.com/apps-script/guides/triggers/installable
*/
ScriptApp.newTrigger('loadDataToSpreadSheet')
.timeBased()
.everyHours(24)
.create();
}
function doGet() {
return HtmlService
.createTemplateFromFile('Page')
.evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}