Code Explanation - nobe4/extralendar GitHub Wiki

main.gs

var args = {/* arguments */};

Script arguments, see configure variables for more details.

CalendarApp.getColor();
MailApp.getRemainingDailyQuota();
SpreadsheetApp.flush();

Before using any of Google service we must provide access to it, those tree lines ensure that google allow access to the script. Nothing more will be done.

function main(){ /* main execution */ }

This is the function that will be called firstly, it will fetch the core.gs script from github and execute it.

core.gs

function core(){ /* core execution */ }

This function will be called first by the main.gs script. It ensure everything inside it will be executed inside a try{}catch{}

function coreFunction(){ /* coreFunction execution */}

This function will be called by the core function. It will do several steps :

  • Check the arguments provided by the user;
  • Get the user calendar;
  • Create the two dates used below;
  • Get all the cookies required by the extranet;
  • Fetch the extranet and get all events between the two dates;
  • Parse the events;
  • Reset the calendar between the two dates;
  • Create the events in the calendar;
  • Logout from the extranet.