Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/communication/failure/code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ function doGet() {

function getUnreadEmails() {
// 'got' instead of 'get' will throw an error.
return GmailApp.gotInboxUnreadCount();
}
return GmailApp.getInboxUnreadCount();
}
11 changes: 8 additions & 3 deletions ui/communication/private/code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ function getBankBalance() {
return deepSecret_(email);
}

/**
* @param {string} email The user's email address.
* @return {string} A string with the user's balance.
* @private
*/
function deepSecret_(email) {
// Do some secret calculations
return email + ' has $1,000,000 in the bank.';
}
// Do some secret calculations
return email + ' has $1,000,000 in the bank.';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer template literal

}
49 changes: 49 additions & 0 deletions ui/communication/runner.gs
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
/* eslint-disable no-unused-vars */

/**
* @typedef {Object} GoogleScriptRun
* @property {function():void} doSomething
* @property {function():void} doSomethingElse
* @property {function(function(string):void):GoogleScriptRun} withSuccessHandler
* @property {function(function(Error):void):GoogleScriptRun} withFailureHandler
*/

/**
* @type {{script: {run: GoogleScriptRun}}}
*/
var google = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google is a global here. use any

script: {
run: {
doSomething: function() {},
doSomethingElse: function() {},
withSuccessHandler: function() {
return this;
},
withFailureHandler: function() {
return this;
},
},
},
};

/**
* @param {Error} error
*/
function onFailure(error) {
console.log(error.message);
}

/**
* @param {string} result
*/
function onSuccess(result) {
console.log(result);
}

/**
* @param {string} result
*/
function onDifferentSuccess(result) {
console.log(result);
}

var myRunner = google.script.run.withFailureHandler(onFailure);
var myRunner1 = myRunner.withSuccessHandler(onSuccess);
var myRunner2 = myRunner.withSuccessHandler(onDifferentSuccess);
Expand Down
10 changes: 10 additions & 0 deletions ui/forms/code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ function doGet() {
return HtmlService.createHtmlOutputFromFile('Index');
}

/**
* @typedef {{myFile: any}} FormObject
*/

/**
* Processes a form submission with a file upload.
*
* @param {FormObject} formObject The form object submitted by the user.
* @return {string} The URL of the uploaded file.
*/
function processForm(formObject) {
var formBlob = formObject.myFile;
var driveFile = DriveApp.createFile(formBlob);
Expand Down
Loading