This file contains hidden or 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 scheduledCollection(){ | |
| var schedule = []; | |
| // dates/times in mm/dd/yyyy hh:mm - timezone matches settings in File > Project properties | |
| schedule.push({start:"08/29/2012 15:00", end:"08/29/2012 16:00"}); | |
| schedule.push({start:"08/29/2012 20:00", end:"08/29/2012 22:00"}); | |
| checkCollect(schedule); | |
| } | |
| function checkCollect(schedule){ | |
| var now = new Date(); | 
  
    
      This file contains hidden or 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 fetchUrlfromRSS(url) { | |
| var cache = CacheService.getPublicCache(); // using Cache service to prevent too many urlfetch | |
| var cached = cache.get(url); | |
| if (cached != null) { // if value in cache return it | |
| return cached; | |
| } | |
| // otherwise build urlfetch | |
| var options = {"method" : "get"}; | |
| try { | |
| var response = UrlFetchApp.fetch(url , options); | 
  
    
      This file contains hidden or 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 youtube(){ | |
| // Setup OAuthServiceConfig | |
| var oAuthConfig = UrlFetchApp.addOAuthService("youtube"); | |
| oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); | |
| oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=http%3A%2F%2Fgdata.youtube.com%2F"); | |
| oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); | |
| oAuthConfig.setConsumerKey("anonymous"); | |
| oAuthConfig.setConsumerSecret("anonymous"); | |
| // Setup optional parameters to point request at OAuthConfigService. The "twitter" | 
  
    
      This file contains hidden or 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 doGet(e){ | |
| // get some variables passed from the querystring | |
| var project = e.parameter.title; | |
| var range = e.parameter.range; | |
| var sheet = e.parameter.sheet; | |
| // Grab a basic html template to fill in the blanks - see https://developers.google.com/apps-script/html_service | |
| var t = HtmlService.createTemplateFromFile("reportTemplate"); | |
| // some bits of code to grab the source urls | |
| var doc = SpreadsheetApp.openById(ScriptProperties.getProperty('active')); | 
  
    
      This file contains hidden or 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 youtube(){ | |
| // Setup OAuthServiceConfig | |
| var oAuthConfig = UrlFetchApp.addOAuthService("youtube"); | |
| oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); | |
| oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=http%3A%2F%2Fgdata.youtube.com%2F"); | |
| oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); | |
| oAuthConfig.setConsumerKey("anonymous"); | |
| oAuthConfig.setConsumerSecret("anonymous"); | |
| // Setup optional parameters to point request at OAuthConfigService. The "twitter" | 
  
    
      This file contains hidden or 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
    
  
  
    
  | // This code excluding Google(c) Code tab: | |
| /* | |
| Copyright 2011 Martin Hawksey | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | 
  
    
      This file contains hidden or 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
    
  
  
    
  | // If not installed from the Apps Script Library to start form processing select Run > onInstall twice (once to authnticate), the second time to add the trigger | |
| function doOnFormSumbit(e) { | |
| var doc = SpreadsheetApp.getActiveSpreadsheet(); | |
| var sheetName = e.values[1]; // assuming field to split data by is first form element | |
| // see if new sheet | |
| var sheetToWrite = doc.getSheetByName(sheetName) || null; | |
| // if new sheet insert column headers | |
| if (sheetToWrite == null){ | |
| var sheets = doc.getSheets(); | |
| var sheetToWrite = doc.insertSheet(sheetName); | 
  
    
      This file contains hidden or 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 getJSON(aUrl,sheetname) { | |
| //var sheetname = "test"; | |
| //var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json"; | |
| var response = UrlFetchApp.fetch(aUrl); // get feed | |
| var dataAll = Utilities.jsonParse(response.getContentText()); // | |
| var data = dataAll.value.items; | |
| for (i in data){ | |
| data[i].pubDate = new Date(data[i].pubDate); | |
| data[i].start = data[i].pubDate; | |
| } | 
  
    
      This file contains hidden or 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() { | |
| var menuEntries = [ {name: "Create Diary Doc from Sheet", functionName: "createDocFromSheet"}]; | |
| var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
| ss.addMenu("Fitness Diaries", menuEntries); | |
| } | |
| function createDocFromSheet(){ | |
| var templateid = "1O4afl8SZmMxMFpAiN16VZIddJDaFdeRBbFyBtJvepwM"; // get template file id | |
| var FOLDER_NAME = "Fitness Diaries"; // folder name of where to put completed diaries | |
| // get the data from an individual user | 
  
    
      This file contains hidden or 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
    
  
  
    
  | /* | |
| Copyright 2011 Martin Hawksey and Dito LLC | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software |