Skip to content

Instantly share code, notes, and snippets.

@mikebranski
Created February 9, 2009 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebranski/60902 to your computer and use it in GitHub Desktop.
Save mikebranski/60902 to your computer and use it in GitHub Desktop.
// From the command authoring tutorial
CmdUtils.CreateCommand({
name: "date",
homepage: "http://www.leftrightdesigns.com/",
author: {name: "Mike Branski", email: "mikebranski@gmail.com"},
description: "Inserts today's date.",
help: "If you're in an editable text area, inserts today's date, formatted for the current locale.",
_date: function() {
var date = new Date();
return date.toLocaleDateString();
},
preview: function( pblock ) {
var msg = 'Insert todays date: "<i>${date}</i>"';
pblock.innerHTML = CmdUtils.renderTemplate( msg, {date: this._date()} );
},
execute: function() {
CmdUtils.setSelection( this._date() );
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment