Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <container>
  <div class="row">
    <div class="col-sm-12">
      <h1>Calendar token (.ICS file) Generator in browser</h1>
      <p>This jquery program will generate a .ICS file for distribution via various digital mediums that is compatible with major calendar programs. This is specifically built for distributing Outlook calendar tokens with only the essential fields required. This program works within the browser 100% and your file is created and saved locally.</p>
      <p><strong>Note:</strong> When viewed in calendar programs the event time is shown according to the user's local time zone. (e.g. 5pm in Las Vegas is 2 hours behind Chicago and the event will show as 7pm when viewed in a calendar in Chicago). Be sure to double check the file local to the timezone.</p>
      <hr>
      <form>
        <label for="eventname">Event Name</label>
        <input name="eventname" type="text" id="eventname" value="" placeholder="The main text shown on the calendar save" autocomplete="off" />
        <div class="row">
          <div class="col-sm-6">
            <label for="startdate">Start Date, Time, Zone</label>
            <input name="startdate" type="text" id="startdatepicker" autocomplete="off" placeholder="Click here to open the datetimepicker" />
          </div>
          <div class="col-sm-6">
            <label for="enddate">End Date, Time, Zone</label>
            <input name="enddate" type="text" id="enddatepicker" autocomplete="off" placeholder="Click here to open the datetimepicker" />
          </div>
        </div>
        <small>Use <a href="https://www.timeanddate.com/worldclock/converter.html?iso=20190112T140000&p1=tz_gmt&p2=64&p3=127&p4=136&p5=179" target="_blank">Timeanddate.com's time zone finder</a> to learn the time zone dependent on <u><strong>location, date, AND daylight savings</strong></u>.</small>

        <label for="eventloc">Location</label>
        <input name="eventloc" type="text" value="" placeholder="Enter name of place and/or street address. Doesn't affect time zone. No character limit." autocomplete="off" />
        <label for="eventdesc">Description</label>
        <textarea name="eventdesc" type="text" value="" placeholder="Text to be displayed when event is opened, sometimes seen in previews. No character limit." autocomplete="off"></textarea>
        <label for="eventuid">Unique ID</label>
        <input name="eventuid" type="text" value="" id="eventuid" />
        <small>Overwrite this if updating a pre-existing ICS file or event. Otherwise users will have two events (though named the same) saved to their calendar program. If lost, open the pre-existing ICS file with Notepad/Textedit and look for "UID:" line 16.</small>
        <fakebutton>Download</fakebutton>
        <input type="checkbox" name="debug" value="Debug" class="debugtoggle">Show debug field?
      </form>
    </div>
    <debug style="display: none;">
      <h6>Debug</h6>
      <p>Start datetime input: <span id="sdi"></span></p>
      <p>moment.js raw UTC: <span id="sdr"></span></p>
      <p>Start datetime UTC: <span id="sdu"></span></p>
      <p id="debuglinka" style="display: none;">Refer to <a href="https://google.com" id="debuglink" target="_blank">this link</a>. It will prefill for Chicago with your datetime from above to verify it is correct.</p>
    </debug>
  </div>
</container>

<!-- ICS Example

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
CLASS:PUBLIC
DESCRIPTION: here goes the description
DTEND:20181114T230000Z
DTSTART:20181114T180000Z
LOCATION: here goes the location
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Default name
TRANSP:OPAQUE
UID:040000008200E00074C5B7101A82E008000000008062306C6261CA01000000000000000
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-ALLOWEXTERNCHECK:TRUE
X-MS-OLK-AUTOFILLLOCATION:FALSE
X-MS-OLK-CONFTYPE:0
BEGIN:VALARM
TRIGGER:-PT1440M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR

-->
              
            
!

CSS

              
                * {
  font-family: "Arial", sans-serif;
  box-sizing: border-box;
  font-size: 14px;
}
.row, .col-sm-6 {margin-bottom: 0;}
h1 {font-size: 25px; font-weight: bold;}
body { margin: 1em; }
label, small {

}
label { font-size: 13px; font-weight: bold; margin-bottom: 3px; margin-top: 5px}
input[type=button], input[type=submit], input[type=reset], fakebutton {
    margin-top: 1em;
}
debug p { display: block; width: 100%; font-weight: bold;}
container {
  display: block;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
form * {
  display: block;
  margin-bottom: 5px;
}
span { font-weight: normal !important; color: blue; }
input, textarea, fakebutton {
  width: 100%;
  border: none;
  background-color: #ddd;
  padding: 5px;
}
small { width: 100%; margin-top: 5px; margin-bottom:0}
small, small a, small u, small strong { font-size: 11px;  display: inline-block; line-height: 1.2em;}
form textarea { height:100px; }
input[type=checkbox] { display: inline-block; margin-bottom: 3px; margin-top: 10px; width: auto; margin-right: 10px;}
input[type=button], input[type=submit], input[type=reset], fakebutton {
  background-color: #000;
  color: white;
  text-align: center;
  /* border: none;
  padding: 16px 32px;
  text-decoration: none;
  margin: 0;
  cursor: pointer; */
}
fakebutton { cursor: pointer; padding: 15px 0; text-transform: uppercase;}
debug { margin: 15px; border: dashed black 1px; padding: 20px 20px 0; background-color: rgba(0,0,0,.1); width: 100%;}

.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-timepicker-div .ui_tpicker_unit_hide{ display: none; }

.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input { background: none; color: inherit; border: none; outline: none; border-bottom: solid 1px #555; width: 95%; }
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input:focus { border-bottom-color: #aaa; }

.ui-timepicker-rtl{ direction: rtl; }
.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
.ui-timepicker-rtl dl dt{ float: right; clear: right; }
.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; }

/* Shortened version style */
.ui-timepicker-div.ui-timepicker-oneLine { padding-right: 2px; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time, 
.ui-timepicker-div.ui-timepicker-oneLine dt { display: none; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label { display: block; padding-top: 2px; }
.ui-timepicker-div.ui-timepicker-oneLine dl { text-align: right; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd, 
.ui-timepicker-div.ui-timepicker-oneLine dl dd > div { display:inline-block; margin:0; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute:before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second:before { content:':'; display:inline-block; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec:before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec:before { content:'.'; display:inline-block; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide:before{ display: none; }
              
            
!

JS

              
                $(".debugtoggle").change(function() {
  $("debug").toggle(this.checked);
});
function dateManipulate(date) {
  var sdi = date;
  var sdr = moment.utc(date, "MM/DD/YYYY hh:mm a Z").format();
  var sdu = moment
    .utc(date, "MM/DD/YYYY hh:mm a Z")
    .format("YYYYMMDD[T]HHmm[00Z]");
  var sdv = moment
    .utc(date, "MM/DD/YYYY hh:mm a Z")
    .format("YYYYMMDD[T]HHmm[00]");
  $("#sdi").html(sdi);
  $("#sdr").html(sdr);
  $("#sdu").html(sdu);
  $("#debuglinka").show();
  $("#debuglink").attr(
    "href",
    "https://www.timeanddate.com/worldclock/converter.html?iso=" + sdv + "&p1=tz_gmt&p2=64&p3=127&p4=136&p5=179"
  );
  var utc = sdu;
  return utc;
}
$("#startdatepicker").datetimepicker({
  timeFormat: "hh:mm tt z",
  timezoneText: "UTC",
  timezone: "-0000",
  stepMinute: 15,
  onSelect: function() {
    $("#enddatepicker").val(this.value);
    dateManipulate(this.value); // necessary for debug
  }
});
$("#enddatepicker").datetimepicker({
  timeFormat: "hh:mm tt z",
  timezoneText: "UTC",
  timezone: "-0000",
  stepMinute: 15
});

function UIDgen() {
  var eventUIDN = "";
  for (var i = 0; i < 16; i++) {
    eventUIDN += Math.floor(Math.random() * (10 - 1 + 1) + 1);
    $("#eventuid").val(eventUIDN);
  }
}

$(document).ready( UIDgen() );
  
$("fakebutton").click(
  function() {
    var eventname = "NOTHING";
    var eventdesc = "NOTHING";
    var eventloc = "NOTHING";
    var eventuid = "NOTHING";
    var startdate = "NOTHING";
    var enddate = "NOTHING";
    
    eventname = $("form").find("input[name='eventname']").val();
    eventdesc = $("form").find("textarea[name='eventdesc']").val();
    eventloc = $("form").find("input[name='eventloc']").val();
    eventuid = $("form").find("input[name='eventuid']").val();
    startdate = $("form").find("input[name='startdate']").val();
    enddate = $("form").find("input[name='enddate']").val();
    var filenametrue = eventname.split(" ").join("_");
  filenametrue = filenametrue.replace(/[_\W]+/g, "_") + ".ics";

  startdate = dateManipulate(startdate);
  enddate = dateManipulate(enddate);
  var icsContent =
    "BEGIN:VCALENDAR\r\nPRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nX-MS-OLK-FORCEINSPECTOROPEN:TRUE\r\nBEGIN:VEVENT\r\nCLASS:PUBLIC\r\nDESCRIPTION:" +
    eventdesc +
    "\r\nDTEND:" +
    enddate +
    "\r\nDTSTART:" +
    startdate +
    "\r\nLOCATION:" +
    eventloc +
    "\r\nPRIORITY:5\r\nSEQUENCE:0\r\nSUMMARY;LANGUAGE=en-us:" +
    eventname +
    "\r\nTRANSP:OPAQUE\r\nUID:" +
    eventuid +
    "\r\nX-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\nX-MICROSOFT-CDO-IMPORTANCE:1\r\nX-MICROSOFT-DISALLOW-COUNTER:FALSE\r\nX-MS-OLK-ALLOWEXTERNCHECK:TRUE\r\nX-MS-OLK-AUTOFILLLOCATION:FALSE\r\nX-MS-OLK-CONFTYPE:0\r\nBEGIN:VALARM\r\nTRIGGER:-PT1440M\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR";

  var hiddenDL = document.createElement("a");
  hiddenDL.setAttribute(
    "href",
    "data:text/plain;charset=utf-8," + encodeURIComponent(icsContent)
  );
  hiddenDL.setAttribute("download", filenametrue);
  hiddenDL.setAttribute("target", "_blank");
  hiddenDL.style.display = "none";
  document.body.appendChild(hiddenDL);
  hiddenDL.click();
  document.body.removeChild(hiddenDL);
    
  UIDgen();
    
  }
  
);
              
            
!
999px

Console