-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
47 lines (37 loc) · 1005 Bytes
/
data.js
File metadata and controls
47 lines (37 loc) · 1005 Bytes
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
function getData(jsonAction) {
/*
if (jsonAction['link'] != '') {
return getDataGitHub(jsonAction);
} else {
return getDataDrive(jsonAction);
}
*/
return getDataDrive(jsonAction);
return 0;
}
function getDataGitHub(jsonAction) {
// initialize local variables
var jsonData = {};
// get json text data
var url = jsonAction['link'];
return getDataUrl(url);
}
function getDataUrl(url) {
var response = UrlFetchApp.fetch(url);
// parse json text into object
var jsonData = JSON.parse(response.getContentText())
// return
return jsonData;
}
function getDataDrive(jsonAction) {
var filename = jsonAction['name'].toLowerCase();
var foldUsage = DriveApp.getFolderById('0B2A_XQu_O5s-clRqdjNHYmlCa1E'); // folder: usage
var files = foldUsage.getFilesByName(filename);
while (files.hasNext()) {
var file = files.next();
var action_id = file.getId();
jsonData = getScenarioJson(action_id);
return jsonData;
}
return 0;
}