Skip to content

Instantly share code, notes, and snippets.

@jethrolarson
Created January 21, 2009 20:27
Show Gist options
  • Save jethrolarson/50166 to your computer and use it in GitHub Desktop.
Save jethrolarson/50166 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "decimal-to-hex",
icon: "",
homepage: "http://jethro-larson.appspot.com",
author: { name: "Jethro Larson", email: "[email protected]"},
license: "GPL",
description: "Convert Decimal Integer to Hex",
help: "Enter a Decimal number",
takes: {"Decimal": noun_arb_text},
_toDec: function(Decimal){
var dec = parseInt(Decimal.text,10);
return dec.toString(16);
},
preview: function( pblock, Decimal ) {
pblock.innerHTML = "Decimal <kbd>" + Decimal.text +"</kbd> in Hex is <kbd>#" + this._toDec(Decimal)+"</kbd>";
},
execute: function(Decimal) {
CmdUtils.setSelection("#"+this._toDec(Decimal));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment