Last active
February 26, 2024 09:54
-
-
Save iqwirty/11082838 to your computer and use it in GitHub Desktop.
A lightweight interface for adding notes to Evernote, to run on Google Apps Script
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
// | |
// Provides a lightweight and responsive interface for | |
// adding a note to my Evernote account. Uses the Evernote | |
// email service for adding the note. | |
// | |
// | |
// Global variables / configuration | |
// | |
// This is the private email address provided by Evernote to | |
// receive new notes via the email service. This address | |
// should be kept private! | |
var evernoteEmail = 'your evernote email address'; | |
// This is a secondary email address to use for keeping | |
// an additional backup or for monitoring the app's | |
// workings. | |
var backupEmail = 'a backup email address'; | |
// The spacing between UI elements in the column | |
var pixelSpacing = 5; | |
// The width of the text entry boxes | |
var width = 400; | |
// The height of the note content entry box | |
var height = 200; | |
// Application title text | |
var titleText = 'everadd - What do you want to remember?'; | |
// Send button text | |
var sendButtonText = 'Send to Evernote...'; | |
// The message to display after sending successfully | |
var successStatusText = 'Sent to Evernote via email service...'; | |
// | |
// doGet() - Handles the initial visit to the web app | |
// | |
function doGet() { | |
// Create the web application in response to GET request | |
var everadd = UiApp.createApplication(); | |
// Show a title for the app | |
var title = everadd.createHTML('<h3>' + titleText + '</h3>'); | |
// Note title | |
var noteTitle = everadd.createTextBox() | |
.setName('noteTitle') | |
.setId('noteTitle'); | |
noteTitle.setWidth(width); | |
// Note content | |
var noteContent = everadd.createTextArea() | |
.setName('noteContent') | |
.setId('noteContent'); | |
noteContent.setSize(width, height); | |
// Action button - send to Evernote | |
var sendNote = everadd.createButton(sendButtonText); | |
// Status label - keep it hidden until user clicks the "Send" button | |
var status = everadd.createLabel(successStatusText) | |
.setId('status') | |
.setVisible(false); | |
// Create a vertical panel for a neat layout | |
var column = everadd.createVerticalPanel(); | |
column.setSpacing(pixelSpacing); | |
column.add(title); | |
column.add(noteTitle); | |
column.add(noteContent); | |
column.add(sendNote); | |
column.add(status); | |
// Set some style on the column of UI widgets | |
column.setStyleAttribute('margin-left', 'auto') | |
.setStyleAttribute('margin-right', 'auto'); | |
// Add the panel to the application layout | |
everadd.add(column); | |
// Create and configure the button handler | |
var buttonHandler = everadd.createServerHandler('buttonHandler'); | |
buttonHandler.addCallbackElement(status); | |
buttonHandler.addCallbackElement(noteContent); | |
buttonHandler.addCallbackElement(noteTitle); | |
sendNote.addClickHandler(buttonHandler); | |
// The doGet() function must always return an instance of the application | |
return everadd; | |
} | |
// | |
// buttonHandler() - Handles the callback from the button click | |
// | |
function buttonHandler(e) { | |
// Get a reference to the active UI application | |
var everadd = UiApp.getActiveApplication(); | |
// We need to retrieve the data from the note title and content | |
// via the event parameter. | |
var noteTitle = e.parameter['noteTitle']; | |
var noteContent = e.parameter['noteContent']; | |
// Send the note title / content via email to Evernote | |
MailApp.sendEmail({ | |
to: evernoteEmail, | |
bcc: backupEmail, | |
// Use the subject syntax to tag the note for easy filing | |
subject: noteTitle + " #everadd", | |
htmlBody: noteContent | |
}); | |
// Show the status label - we are assuming | |
// errors don't happen, the status always shows | |
// a success message. | |
var status = everadd.getElementById('status'); | |
status.setVisible(true); | |
everadd.close(); | |
return everadd; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current known issues / things to work on: