Created
October 16, 2009 04:20
-
-
Save pao/211553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var noun_type_url_or_arb = { | |
label: "url or text", | |
default: noun_type_url.default, | |
suggest: function nt_url_arb_sugg(text, html, callback, selectionIndices) { | |
var textLC = text.toLowerCase(); | |
if (textLC.substring(0,4) == "url ") { | |
return noun_type_url.suggest(text.substring(4), text.substring(4), callback, selectionIndices); | |
} else { | |
return noun_arb_text.suggest(text, html, callback, selectionIndices); | |
} | |
} | |
}; | |
/* This is a template command. */ | |
CmdUtils.CreateCommand({ | |
names: ["qr"], | |
icon: "http://2dcode.ning.com/favicon.ico", | |
description: "Generate a QR code.", | |
help: "Input text to encode it in a QR barcode. The default is the URL of the current page. Press enter to insert the QR code.", | |
author: {name: "Patrick O'Leary", email: "[email protected]"}, | |
license: "GPL", | |
homepage: "http://patrick.greentaperacing.us/", | |
arguments: [{role: 'object', nountype: noun_type_url_or_arb}, {role: 'format', nountype: noun_type_percentage, label: 'size'}], | |
preview: function preview(pblock, args) { | |
var chssize = Math.ceil(150*args.format.data); | |
var chsstr = chssize + 'x' + chssize; | |
pblock.innerHTML = "<img src='http://chart.apis.google.com/chart?cht=qr&chs=" + chsstr + "&chl=" + escape(args.object.text) + "' />"; | |
}, | |
execute: function execute(args) { | |
var chssize = Math.ceil(350*args.format.data); | |
var chsstr = chssize + 'x' + chssize; | |
CmdUtils.setSelection("<img src='http://chart.apis.google.com/chart?cht=qr&chs=" + chsstr + "&chl=" + escape(args.object.text) + "' />"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment