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
function publish() { | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = spreadsheet.getSheetByName('Announcements'); | |
var data = sheet.getDataRange().getValues(); | |
var site = SitesApp.getSite('erickoledauniversity'); | |
var page = site.getChildByName('announcements'); | |
for (var i = 0; i < data.length; i++) { | |
var row = data[i]; | |
var title = row[1]; | |
var description = row[2]; |
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
/** | |
* Sends an email using the contents of a Google Document as the body. | |
*/ | |
function sendDocument(documentId, recipient, subject) { | |
var html = convertToHtml(documentId); | |
html = inlineCss(html); | |
GmailApp.sendEmail(recipient, subject, null, { | |
htmlBody: html | |
}); | |
} |
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
/** | |
* @file A sample showing how to format date/time values in Apps Script so that they appear in the | |
* user's timezone. View a working version here: | |
* https://docs.google.com/spreadsheets/d/1VlI8HibL9kh_wlmO0G1ltMGVo6S-urGrDqDbfEp9eeY/edit | |
*/ | |
/** | |
* Add menu item after the spreadsheet opens. | |
*/ | |
function onOpen() { |
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
function removeMultipleLineBreaks(element) { | |
if (!element) { | |
element = DocumentApp.getActiveDocument().getBody(); | |
} | |
var parent = element.getParent(); | |
// Remove empty paragraphs | |
if (element.getType() == DocumentApp.ElementType.PARAGRAPH | |
&& element.asParagraph().getText().replace(/\s/g, '') == '') { | |
if (!(parent.getType() == DocumentApp.ElementType.BODY_SECTION | |
&& parent.getChildIndex(element) == parent.getNumChildren() - 1)) { |
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
(function() { | |
// Include jQuery. | |
var script = document.createElement('script'); | |
script.src = 'https://code.jquery.com/jquery-2.1.1.min.js'; | |
script.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
var sections = [ | |
'Default MIME Types', | |
'Default File Extensions', |
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
/** | |
* Converts an XML string to a JSON object, using logic similar to the | |
* sunset method Xml.parse(). | |
* @param {string} xml The XML to parse. | |
* @returns {Object} The parsed XML. | |
*/ | |
function xmlToJson(xml) { | |
var doc = XmlService.parse(xml); | |
var result = {}; | |
var root = doc.getRootElement(); |
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
// Change this values based on your spreadsheet. | |
var SHEET_NAME = 'Form Responses 1'; | |
var STATUS_COLUMN_NUMBER = 4; | |
var PROCESSED_STATUS = 'Processed'; | |
var LAST_ROW_KEY = 'lastRow'; | |
var LOCK_TIMEOUT_MS = 60000; // 1 minute | |
var MAX_RUNTIME_MS = 240000; // 4 minutes | |
/** |
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
function onOpen() { | |
SpreadsheetApp.getUi().createMenu('Testing') | |
.addItem('Show Sidebar', 'showSidebar') | |
.addToUi(); | |
} | |
function showSidebar() { | |
var sidebar = HtmlService.createHtmlOutputFromFile('Sidebar') | |
.setSandboxMode(HtmlService.SandboxMode.IFRAME) | |
.setTitle('Sidebar'); |
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
function createTrigger() { | |
var time = new Date(); | |
time.setMinutes(time.getMinutes() + 5); | |
ScriptApp.newTrigger('run') | |
.timeBased() | |
.at(time) | |
.create(); | |
} | |
function run() { |
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
function createEventWithAttachment() { | |
var driveFileId = '...'; | |
var file = DriveApp.getFileById(driveFileId); | |
var event = { | |
summary: 'Test Event with Attachments', | |
description: 'Woot!', | |
attachments: [{ | |
fileId: driveFileId, | |
fileUrl: file.getUrl(), | |
mimeType: file.getMimeType(), |
OlderNewer