|
1 | 1 | // --- DocumentAppp (DocumentApp plus) --- |
2 | | -(function(r) { |
| 2 | +(function (r) { |
3 | 3 | var DocumentAppp; |
4 | | - DocumentAppp = (function() { |
| 4 | + DocumentAppp = function () { |
5 | 5 | var gToM, putError, putInternalError; |
6 | 6 |
|
7 | 7 | class DocumentAppp { |
8 | 8 | constructor(id_) { |
9 | 9 | this.name = "DocumentAppp"; |
10 | 10 | if (id_ !== "create") { |
11 | | - if (id_ === "" || DriveApp.getFileById(id_).getMimeType() !== MimeType.GOOGLE_DOCS) { |
| 11 | + if ( |
| 12 | + id_ === "" || |
| 13 | + DriveApp.getFileById(id_).getMimeType() !== MimeType.GOOGLE_DOCS |
| 14 | + ) { |
12 | 15 | putError.call(this, "This file ID is not the file ID of Document."); |
13 | 16 | } |
14 | 17 | this.obj = { |
15 | | - documentId: id_ |
| 18 | + documentId: id_, |
16 | 19 | }; |
17 | 20 | } |
18 | 21 | this.headers = { |
19 | | - Authorization: `Bearer ${ScriptApp.getOAuthToken()}` |
| 22 | + Authorization: `Bearer ${ScriptApp.getOAuthToken()}`, |
20 | 23 | }; |
21 | 24 | this.mainObj = {}; |
22 | 25 | } |
|
26 | 29 | gToM.call(this); |
27 | 30 | return new WordApp(this.mainObj.blob).getTableColumnWidth(); |
28 | 31 | } |
29 | | - |
30 | | - }; |
| 32 | + } |
31 | 33 |
|
32 | 34 | DocumentAppp.name = "DocumentAppp"; |
33 | 35 |
|
34 | 36 | // --- end methods |
35 | | - gToM = function() { |
| 37 | + gToM = function () { |
36 | 38 | var obj, url; |
37 | 39 | url = `https://www.googleapis.com/drive/v3/files/${this.obj.documentId}/export?mimeType=${MimeType.MICROSOFT_WORD}`; |
38 | 40 | obj = UrlFetchApp.fetch(url, { |
39 | | - headers: this.headers |
| 41 | + headers: this.headers, |
40 | 42 | }); |
41 | 43 | if (obj.getResponseCode() !== 200) { |
42 | | - putError.call(this, "Document ID might be not correct. Please check it again."); |
| 44 | + putError.call( |
| 45 | + this, |
| 46 | + "Document ID might be not correct. Please check it again." |
| 47 | + ); |
43 | 48 | } |
44 | 49 | this.mainObj.blob = obj.getBlob(); |
45 | 50 | }; |
46 | 51 |
|
47 | | - putError = function(m) { |
| 52 | + putError = function (m) { |
48 | 53 | throw new Error(`${m}`); |
49 | 54 | }; |
50 | 55 |
|
51 | | - putInternalError = function(m) { |
| 56 | + putInternalError = function (m) { |
52 | 57 | throw new Error(`Internal error: ${m}`); |
53 | 58 | }; |
54 | 59 |
|
55 | 60 | return DocumentAppp; |
56 | | - |
57 | | - }).call(this); |
58 | | - return r.DocumentAppp = DocumentAppp; |
| 61 | + }.call(this); |
| 62 | + return (r.DocumentAppp = DocumentAppp); |
59 | 63 | })(this); |
0 commit comments