-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"timeZone": "America/New_York", | ||
"dependencies": {}, | ||
"exceptionLogging": "STACKDRIVER", | ||
"runtimeVersion": "V8", | ||
"oauthScopes": [ | ||
"https://www.googleapis.com/auth/userinfo.email", | ||
"https://www.googleapis.com/auth/spreadsheets.currentonly", | ||
"https://www.googleapis.com/auth/script.external_request", | ||
"https://www.googleapis.com/auth/script.container.ui" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function onOpen() { | ||
var ui = SpreadsheetApp.getUi(); | ||
ui.createMenu('Lehigh Preserve') | ||
.addItem('Check My Work', 'sendSheetData') | ||
.addToUi(); | ||
} | ||
|
||
function sendSheetData() { | ||
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | ||
var data = sheet.getDataRange().getValues(); | ||
|
||
var payload = JSON.stringify(data); | ||
|
||
var url = 'https://preserve.lehigh.edu/workbench/check'; | ||
const oauthToken = ScriptApp.getIdentityToken(); | ||
var options = { | ||
method: 'POST', | ||
headers: { | ||
'Authorization': 'Bearer ' + oauthToken | ||
}, | ||
contentType: 'application/json', | ||
payload: payload | ||
}; | ||
|
||
var response = UrlFetchApp.fetch(url, options); | ||
var result = JSON.parse(response.getContentText()); | ||
|
||
displayErrors(result); | ||
} | ||
|
||
function displayErrors(errors) { | ||
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | ||
|
||
for (var cell in errors) { | ||
var error = errors[cell]; | ||
sheet.getRange(cell).setBackground('red').setNote(error); | ||
} | ||
|
||
SpreadsheetApp.getUi().alert('Errors highlighted in the sheet.'); | ||
} |