Skip to content

Instantly share code, notes, and snippets.

@esquifit
Created May 2, 2010 12:19
Show Gist options
  • Save esquifit/387092 to your computer and use it in GitHub Desktop.
Save esquifit/387092 to your computer and use it in GitHub Desktop.
Inserts an QRCode image of the selection
CmdUtils.CreateCommand({
name: "qr_code",
homepage: "http://yonen.ca/",
author: { name: "Jessy Ouellette", email: "jessy.ouellette@gmail.com"},
takes: {"text": noun_arb_text},
_getQRCodeUrl: function(QRText) {
var QRCodeUrl = "http://qrcode.kaywa.com/code/";
return QRCodeUrl + QRText.text;
},
preview: function( pblock, QRText ) {
var msg = "Inserts an QRCode image of the selection: <br/>";
msg += "<img src='%s'/>".replace( /%s/, this._getQRCodeUrl(QRText) );
pblock.innerHTML = msg;
},
execute: function( QRText) {
CmdUtils.setSelection( "<img src='" + this._getQRCodeUrl(QRText) +"'/>");
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment