Today I’ve returned to my explanation of the CSP Schedule Converter extension.  At the very end of the function the rest of the parts are identified and the information is concatenated into the end resulting ics file.  

function createics (schedule) { ….

   var begin = "BEGIN:VEVENT";

   var end = "END:VEVENT";

   var summary = "SUMMARY:" + schedule[i].teamname + " " + schedule[i].tshirtcolor;

   var description = "DESCRIPTION:" + "Game #" + schedule[i].game + " vs " + schedule[i].competitor;

   var pprivate = "CLASS:PRIVATE";

   var icsevent = begin + "\n" + summary + "\n" + description + "\n" + dtstamp + "\n" + dtstart + "\n" + dtend +   "\n" + pprivate + "\n" + end + "\n";

   finalics += icsevent;  


finalics += "END:VCALENDAR";

return finalics


As mentioned previously, ics and csv files need to be formatted a particular way in order to be imported correctly as calendar files.  To start an ics file event entry you input this text: BEGIN:VEVENT.  Subsequently END:VEVENT identifies the end of an event entry in an ics file.  I’ve created these for each entry, and labeled them as begin and end variables.  Then I create a variable called summary which includes the team name and whether or not you’re home or away for that game.  The description variable includes the game number of the season, game and the competitor.  

As with the csv file, use pprivate to identify that the event is classified as private unless the particular user wishes to adjust it otherwise.  Then to complete it I concatenate it all together into a singular icsevent variable.  As I go through each event on the page an ics version is created and added to the finalics list.  To complete the entire ics file, the string “END:VCALENDAR” is added.  The variable finalics is then returned from the function createics().

Up Next Time: Using jQuery to create an interface for my extension