Skip to content

Instantly share code, notes, and snippets.

@jethrolarson
Created January 21, 2009 20:04
Show Gist options
  • 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: "[email protected]"},
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