Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="wrapper">

  <h1>Create Reminders<br>for <a href="http://www.dueapp.com/">Due</a> – without Due</h1>

  <p>&#10004; with natural date &amp; time parsing</p>

  <div class="form">
    <input id="task" type="text" placeholder="Remind someone to..." autofocus>

    <div class="duedate">
      <span class="date"></span>&nbsp;<span class="diff"></span>
    </div>

    <div class="parser">
      <div class="title"></div>
      <div class="subtitle"></div>
    </div>

    <div class="shortcuts">
      <div onclick="setTime(9,30)">9:30</div>
      <div onclick="setTime(12,00)">12:00</div>
      <div onclick="setTime(18,30)">18:30</div>
      <div onclick="setTime(22,00)">22:00</div>

      <div onclick="editTime(10)">+10 <span class="unit">mins</span></div>
      <div onclick="editTime(60)">+1 <span class="unit">hr</span></div>
      <div onclick="editTime(180)">+3 <span class="unit">hr</span></div>
      <div onclick="editTime(1440)">+1 <span class="unit">day</span></div>

      <div onclick="editTime(-10)">-10 <span class="unit">mins</span></div>
      <div onclick="editTime(-60)">-1 <span class="unit">hr</span></div>
      <div onclick="editTime(-180)">-3 <span class="unit">hr</span></div>
      <div onclick="editTime(-1440)">-1 <span class="unit">day</span></div>
    </div>

    <div class="clear"></div>
  </div>

  <p>Share the <a class="due" href="#">Due link</a> via</p>

  <p class="share">
    <a class="mail" href="#">Mail</a>
    <a class="whatsapp" href="#">WhatsApp</a>
    <a class="threema" href="#">Threema</a>
  </p>

  <footer>
    <p>created by <a href="https://stefangrund.de/">Stefan Grund</a> / <a href="https://twitter.com/eay">@eay</a><br>Read <a href="http://eay.cc/2015/create-reminders-for-due-without-due/">my blog post</a> / code on <a href="https://codepen.io/eay/pen/ByRjyv">CodePen</a><br>&nbsp;</p>
  </footer>

</div>
              
            
!

CSS

              
                /* Imports */

@import url(https://fonts.googleapis.com/css?family=Roboto);

/* Variables */

$color_bg: #565555;
$font_size: 16px;
$font_size_small: 14px;

/* Base styles */

html, body {
    height: 98%;
}

body {
	background: linear-gradient(135deg, $color_bg, darken($color_bg, 10%)) fixed;
	text-align: center;
	font-family: 'Roboto', sans-serif;
	font-size: 16px;
	color: #fff;
}

a {
	color: #fff;
	text-decoration: underline;
}

h1 {
	font-size: 24px;
  font-weight: 400;
	margin-bottom: -8px;
	a { 
		text-decoration: none;
		border-bottom: 2px solid #fff;
	}
}

input {
	outline: 0;
	margin: 0;
	border: 0;
}

/* Sections */

.wrapper {
	@media (min-width: 401px) { 
		width: 374px;
		margin: 13px auto 13px auto;
	}
	@media (max-width: 400px) { 
		width: 93.5%;
		margin: 3.25%;
	}

	// Vertical positioning
	@media (min-height: 600px) {
		position: relative;
		top: 45%;
		-webkit-transform: translateY(-45%);
		-ms-transform: translateY(-45%);
		transform: translateY(-45%);
	}
}

.form {
	width: 100%;
	text-align: left;

	background-color: #fff;
	font-size: 16px;
	color: #000;

	// The input field
	#task {
		width: 94%;
		height: 45px;
		padding: 0 3%;
	}

	// Row for date and time difference
	.duedate {
		width: 94%;
		height: 40px;
		line-height: 40px;
		padding: 0 3%;
		background-color: #9D0507;
		.date { color: #ddd; }
		.diff { color: #fff; }
	}

	// Row for parsed natural language
	.parser {
		width: 100%;
		padding: 6px 0;
		text-align: center;
		border-bottom: 1px solid #ccc;
		display: none;
		&:hover {
			cursor: pointer;
		}
		.subtitle {
			font-size: 13px;
		}
	}

	// Shortcuts to edit date/time
	.shortcuts {
		div { 
			@media (min-width: 401px) { width: 24.8%; }
			@media (max-width: 400px) { width: 24.7%; }
			height: 54px;
			line-height: 54px;
			float: left;
			cursor: pointer;
			text-align: center;
			border-right: 1px solid #ccc;
		}
		div:nth-child(4n) {
			border-right: 0;
		}
		div:nth-child(-n+8) {
			border-bottom: 1px solid #ccc;
		}
		div:hover {
			background-color: #ccc;
		}

		.unit {
			font-size: 14px;
		}
	}

	.clear {
		clear: both;
	}
}

.share {
	margin: -8px 0 0 0;
	a { 
		display: inline-block;
		border: 1px solid #fff;
		border-radius: 8px;
		padding: 8px;
		text-decoration: none;
	}
}

footer {
	font-size: 14px;
	line-height: 21px;
	color: #bbb;
}
              
            
!

JS

              
                // Global variables
var date = new XDate();
var today = new XDate();

var dateFormat = 'ddd, MMM d, HH:mm'; // Fri, Jul 18, 13:15
var task = "Buy milk";

var dateAdded = false;

// Create URL for Due
function output() {
	timestamp = Math.round(date.getTime()/1000); // convert milliseconds to Unix time stamp
	return 'due://x-callback-url/add?title=' + encodeURIComponent(task) + '&duedate=' + timestamp;
}

// Prettify units
function prettify(x, unit) {
	unit = ' ' + unit;
	if (Math.round(x) == 1 || Math.round(x) == -1) { return unit; }
	else { return unit + 's'; }
}

// Update date and URLs
function update() {

	// Display difference between now and due date
	var diff = today.diffMinutes(date);
	var diffText;

	if (diff >= 0) {
		if (diff < 60) { diffText = 'in ' + Math.round(diff) + prettify(diff, 'minute'); }
		else if (diff < 1439) { diffText = 'in ' + Math.round(diff/60) + prettify(diff/60, 'hour'); }
		else if (diff >= 1440) { diffText = 'in ' + Math.round(diff/1440) + prettify(diff/1440, 'day'); }
	}
	else {
		if (diff > -60) { diffText = Math.round(diff) + prettify(diff, 'minute') + ' ago'; }
		else if (diff > -1439) { diffText = Math.round(diff/60) + prettify(diff/60, 'hour') + ' ago'; }
		else if (diff <= -1440) { diffText = Math.round(diff/1440) + prettify(diff/1440, 'day') + ' ago'; }
		diffText = diffText.substr(1); // remove negative symbol
	}

	var dateFormatted = date.toString(dateFormat);
	$('.date').text(dateFormatted);
	$('.diff').text(diffText);

	// Create output for services
	var taskTitle = encodeURIComponent('Due Reminder: '+task);

	$('.due').attr('href', output());
	$('.mail').attr('href', 'mailto:?subject='+taskTitle+'&body='+encodeURIComponent(output()));
	$('.whatsapp').attr('href', 'whatsapp://send?text='+taskTitle+'%20'+encodeURIComponent(output()));
	$('.threema').attr('href', 'threema://compose?text='+taskTitle+'%20'+encodeURIComponent(output()));
}

// Set and control the parsed natural language
function showParser(dateParsed) {

	// Get and combine known and implied values
	var knownValues   = dateParsed[0].start.knownValues;
	var impliedValues = dateParsed[0].start.impliedValues;
	var parsedValues = $.extend({}, knownValues, impliedValues)

	// Set new XDate with parsed values 
	var parsedDate = new XDate();
	if(date.getFullYear() > parsedValues.year) {
		parsedDate.setFullYear(date.getFullYear());
	}
	else {
		parsedDate.setFullYear(parsedValues.year);
	}
	parsedDate.setMonth(parsedValues.month-1); // month is zero-indexed
	parsedDate.setDate(parsedValues.day);
	parsedDate.setHours(parsedValues.hour);
	parsedDate.setMinutes(parsedValues.minute);

	// Format new date
	var parsedDateFormatted = parsedDate.toString(dateFormat);

	// Show parser controls
	$('.parser').slideDown('fast', function() {
		$('.title').text('Set to "' + dateParsed[0].text + '"');
		$('.subtitle').text(parsedDateFormatted);
	});

	// Hide parser controls
	$('.parser').click(function() {
		date = parsedDate;
		update();
		$('.parser').slideUp('fast');
	});
}

// Set to preconfigurated times
function setTime(hour, minutes) {

	// prevent early hours to increase days
	if(hour < date.getHours() && dateAdded != true) {
		date.addDays(1);
		dateAdded = true;
	}

	date.setHours(hour);
	date.setMinutes(minutes);
	update();
}

// Add or remove time (in minutes)
function editTime(minutes) {
	date.addMinutes(minutes);
	update();
}

// On page load
$(document).ready( function() {

	// Round minutes up to 10 min 
	var roundNumber = Math.ceil(date.getMinutes() / 10) * 10;
	date.setMinutes(roundNumber);
	update();
});

// Get and parse data from user input
$('.form').on('input', function() {
	task = $('#task').val();

	var dateParsed = chrono.parse(task);
	if(dateParsed.length > 0) {
		showParser(dateParsed);
	}

	update();
});
              
            
!
999px

Console