Coder Social home page Coder Social logo

femotizo / add-to-calendar-buttons Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commonpike/add-to-calendar-buttons

0.0 1.0 0.0 692 KB

Easily add a "add to calendar" button to your websites. This JavaScript library supports Google Calendar, Office 365, iCal, Outlook and Yahoo Calendar.

CSS 22.52% JavaScript 53.46% HTML 24.02%

add-to-calendar-buttons's Introduction

OuiCal2

A simple JS library that enables you to add an "add to calendar" button for your upcoming events.

Inspiration

This project was inspired by Eventbrite's add to calendar feature (which should have been open sourced #justSayin).

Later, it was adjusted to look and behave more like AddToCalendar, which suddenly became a commercial tool, and very expensive too #justSayin.

How to use it?

Method 1

Call 'addToCalendar' with your event info, pass in any optional parameters such as a class and/ or id and boom! Insert your add-to-calendar div wherever you'd like.

The only fields that are mandatory are:

  • Event title
  • Start time

Example

var myCalendar = addToCalendar({
  options: {
    class: 'my-class',
    
    // You can pass an ID. If you don't, one will be generated for you
    id: 'my-id'
  },
  data: {
    // Event title
    title: 'Get on the front page of HN',

    // Event start date
    start: new Date('June 15, 2013 19:00'),
    
    // Event timezone. Will convert the given time to that zone
    timezone: America/Los_Angeles,          

    // Event duration (IN MINUTES)
    duration: 120,

    // You can also choose to set an end time
    // If an end time is set, this will take precedence over duration
    // end: new Date('June 15, 2013 23:00'), 
    
    // You can also choose to set 'all day'
    // If this is set, this will override end time, duration and timezone
    // allday:true,

    // Event Address
    address: 'The internet',

    // Event Description
    description: 'Get on the front page of HN, then prepare for world domination.'
  }
});

document.querySelector('#place-where-I-want-this-calendar').appendChild(myCalendar);

Method 2

Write your events data in several hidden HTML tags with the right classnames, and wrap them in a div. Then call 'createCalendar' with the outer div and boom! The calendar is appended to your wrapping div. The only fields that are mandatory are:

  • Event title
  • Start time

Example

<div title="Add to Calendar" class="add-to-calendar">
  <span class="start">12/18/2018 08:00 AM</span>
  <span class="timezone">America/Los_Angeles</span>
  <!--span class="end">12/18/2018 10:00 AM</span-->
  <!--span class="duration">60</span-->
  <!--span class="allday">true</span-->
  <span class="title">Summary of the event</span>
  <span class="description">Description of the event</span>
  <span class="location">Location of the event</span>
</div>

Demo

Here is a live example

Calendar Generator

Need to generate an add-to-calendar widget on the fly? No problem, go here.

GitHub Project Page

Official Project Page

License

MIT

add-to-calendar-buttons's People

Contributors

carlsednaoui avatar maryrosecook avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.