<commit_before>// eventList.js is a simple tool for displaying an events list based on a Google Calender id
// Handmade with love by <NAME> || http://github.com/TheHeat || @marcheatley
// Inspired by http://kevin.deldycke.com/2012/07/displaying-upcoming-events-google-calendar-javascript/


// **********************
// Functions and helpers


// Day and Month name formatting helpers
var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");


// Switch to add the appropriate suffix to date
function formatDate(dateNumber){

  var append = "";

  switch (dateNumber){
    case 1: case 21: case 31: append = "st"; break;
    case 2: case 22:          append = "nd"; break;
    case 3: case 23:          append = "rd"; break;
    default:                  append = "th"; break;
  }
  return dateNumber + append;
}


// Bump 24h clock down to 12h am/pm
function formatTime(hour, minutes){

  if(hour < 12){
    return hour + ":" + pad(minutes) + "am";
  }else {
    return (hour - 12) + ":" + pad(minutes) + "pm";
  }
}


// Autolink finds and formats links in specified strings
// It is cool and made by <NAME>
// https://github.com/bryanwoods/autolink-js
(function() {
  var autoLink,
    __slice = [].slice;

  autoLink = function() {
    var k, linkAttributes, option, options, pattern, v;
    options = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
    pattern = /(^|\s)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~_|])/gi;
    if (!(options.length > 0)) {
      return this.replace(pattern, "$1<a href='$2'>$2</a>");
    }
    option = options[0];
    linkAttributes = ((function() {
      var _results;
      _results = [];
      for (k in option) {
        v = option[k];
        if (k !== 'callback') {
          _results.push(" " + k + "='" + v + "'");
        }
      }
      return _results;
    })()).join('');
    return this.replace(pattern, function(match, space, url) {
      var link;
      link = (typeof option.callback === "function" ? option.callback(url) : void 0) || ("<a href='" + url + "'" + linkAttributes + ">" + url + "</a>");
      return "" + space + link;
    });
  };

  String.prototype['autoLink'] = autoLink;

}).call(this);


// Utility method to pad a string on the left
// Thanks to http://sajjadhossain.com/2008/10/31/javascript-string-trimming-and-padding/
function pad(n){return n<10 ? '0'+n : n}

$.fn.eventList = function(calID, args){

  //Set some default parameters. All of these can be overridden by passing an object with one or more of these properties
  var defaults = {
    // orderby: 'starttime',
    // singleevents: true,
    maxResults: 8,
    // key: '<KEY>'
  }

  //Combine the parameters args and defaults
  var params = $.extend(true, defaults, args);

  //Delete parameters specific to this function in order to compose a query string
  // var queryStringParams = $.extend(true, {}, params);

  //Serialize the parameters into a query string
  var queryString = decodeURIComponent($.param(params));

  // Create the container elements for the list and feed links
  $(this).html('<ol class="events-list"><li>Nothing to see here!</li></ol><div class="feed-links"></div>');

  // All the feed strings
  var calJSON = 'https://www.googleapis.com/calendar/v3/calendars/' + calID + '/events?' + queryString;
  var calGoog = 'http://www.google.com/calendar/embed?src=' + calID;
  var calICal = 'http://www.google.com/calendar/ical/' + calID + '/public/basic.ics';
  
  // Get list of upcoming iCal events formatted in JSON
  $.getJSON( calJSON, function(data){

  // Parse and render each event
  $.each(data.items, function(i, item){

    if(i == 0) {
      $(".events-list li").first().hide();
    };


    // **********************<commit_msg>ditches old API key<commit_after>// eventList.js is a simple tool for displaying an events list based on a Google Calender id
// Handmade with love by <NAME> || http://github.com/TheHeat || @marcheatley
// Inspired by http://kevin.deldycke.com/2012/07/displaying-upcoming-events-google-calendar-javascript/


// **********************
// Functions and helpers


// Day and Month name formatting helpers
var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");


// Switch to add the appropriate suffix to date
function formatDate(dateNumber){

  var append = "";

  switch (dateNumber){
    case 1: case 21: case 31: append = "st"; break;
    case 2: case 22:          append = "nd"; break;
    case 3: case 23:          append = "rd"; break;
    default:                  append = "th"; break;
  }
  return dateNumber + append;
}


// Bump 24h clock down to 12h am/pm
function formatTime(hour, minutes){

  if(hour < 12){
    return hour + ":" + pad(minutes) + "am";
  }else {
    return (hour - 12) + ":" + pad(minutes) + "pm";
  }
}


// Autolink finds and formats links in specified strings
// It is cool and made by <NAME>
// https://github.com/bryanwoods/autolink-js
(function() {
  var autoLink,
    __slice = [].slice;

  autoLink = function() {
    var k, linkAttributes, option, options, pattern, v;
    options = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
    pattern = /(^|\s)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~_|])/gi;
    if (!(options.length > 0)) {
      return this.replace(pattern, "$1<a href='$2'>$2</a>");
    }
    option = options[0];
    linkAttributes = ((function() {
      var _results;
      _results = [];
      for (k in option) {
        v = option[k];
        if (k !== 'callback') {
          _results.push(" " + k + "='" + v + "'");
        }
      }
      return _results;
    })()).join('');
    return this.replace(pattern, function(match, space, url) {
      var link;
      link = (typeof option.callback === "function" ? option.callback(url) : void 0) || ("<a href='" + url + "'" + linkAttributes + ">" + url + "</a>");
      return "" + space + link;
    });
  };

  String.prototype['autoLink'] = autoLink;

}).call(this);


// Utility method to pad a string on the left
// Thanks to http://sajjadhossain.com/2008/10/31/javascript-string-trimming-and-padding/
function pad(n){return n<10 ? '0'+n : n}

$.fn.eventList = function(calID, args){

  //Set some default parameters. All of these can be overridden by passing an object with one or more of these properties
  var defaults = {
    // orderby: 'starttime',
    // singleevents: true,
    maxResults: 8,
    // key: ''
  }

  //Combine the parameters args and defaults
  var params = $.extend(true, defaults, args);

  //Delete parameters specific to this function in order to compose a query string
  // var queryStringParams = $.extend(true, {}, params);

  //Serialize the parameters into a query string
  var queryString = decodeURIComponent($.param(params));

  // Create the container elements for the list and feed links
  $(this).html('<ol class="events-list"><li>Nothing to see here!</li></ol><div class="feed-links"></div>');

  // All the feed strings
  var calJSON = 'https://www.googleapis.com/calendar/v3/calendars/' + calID + '/events?' + queryString;
  var calGoog = 'http://www.google.com/calendar/embed?src=' + calID;
  var calICal = 'http://www.google.com/calendar/ical/' + calID + '/public/basic.ics';
  
  // Get list of upcoming iCal events formatted in JSON
  $.getJSON( calJSON, function(data){

  // Parse and render each event
  $.each(data.items, function(i, item){

    if(i == 0) {
      $(".events-list li").first().hide();
    };


    // **********************
{'fraction_non_alphanumeric': 0.18523694575022234, 'fraction_numerical': 0.014991741837123618, 'mean_word_length': 3.0286591606960083, 'pattern_counts': {'":': 4, '<': 34, '<?xml version=': 0, '>': 30, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4002567', 'n_tokens_mistral': 2677, 'n_tokens_neox': 2476, 'n_words': 736}