Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity 0.5 Author Tutorial

11 bytes added, 00:08, 30 August 2009
Modernized.
The <code>toLocaleDateString()</code> function is native to Javascript, so if you're not familiar with it check out the documentation for the Javascript [https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date Date object].
=== A Better Preview ===
It's time to add a better preview to the date command. Let's have the preview show the date, so that the user will know what to expect when they execute the command. (As a side benefit the user doesn't even need to execute the command to do a quick check of the day.)
names: ["insert date"],
_date: functiondate__date(){ var date = return new Date(); return date.toLocaleDateString();
},
preview: functiondate_preview( pblock ) {
var msg = _('Inserts today\'s date: "<i>${date}</i>"');
pblock.innerHTML = CmdUtils.renderTemplate( msg, {date: this._date()} );
},
execute: functiondate_execute() { CmdUtils.setSelection( this._date() );
}
})
<pre>
preview: functiondate_preview( pblock ) {
var msg = 'Inserts today's date: "<i>${date}</i>"';
pblock.innerHTML = _( msg, {date: this._date()} );
},
</pre>
<pre>
preview: function( pblock ) {
pblock.innerHTML = _("This will show until the AJAX request returns");
CmdUtils.previewGet(pblock, "http:// AJAX requestexample.com", function (htm) { pblock.innerHTML = getFromServer(htm; });
},
</pre>
 
In the future, we may work on streamlining this process.
== Documentation and Metadata ==
73
edits

Navigation menu