Skip to content

Instantly share code, notes, and snippets.

@jethrolarson
Created January 21, 2009 20:04
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 jethrolarson/50159 to your computer and use it in GitHub Desktop.
Save jethrolarson/50159 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "hex-to-decimal",
icon: "",
homepage: "http://gist.github.com/gists/50159",
author: { name: "Jethro Larson", email: "jethrolarson@gmail.com"},
license: "GPL",
description: "Convert Hexidecimal Integer to Decimal",
help: "Enter a Hexidecimal number",
takes: {"Hex": noun_arb_text},
_toDec: function(Hex){
var hex = Hex.text.replace("#","").replace("0x","");
return parseInt(hex,16);
},
preview: function( pblock, Hex ) {
pblock.innerHTML = "Hex <kbd>" + Hex.text +"</kbd> in Decimal is <kbd>" + this._toDec(Hex)+"</kbd>";
},
execute: function(Hex) {
CmdUtils.setSelection(this._toDec(Hex));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment