CmdUtils.CreateCommand({
  name: "trim",
  takes: {"url to trim": noun_type_url},
  author: { name: "N G"},
  license: "GPL",
  icon: "http://tr.im/favicon.ico",
  description: "Replaces the selected URL with a <a href=\"http://tr.im\">tr.im url</a>. Inspired by 'tinyurl' command found here https://ubiquity.mozilla.com/herd/all-feeds//a4f54881dde1f1b733088c6bf5e2d02532d38cc7-7153/",
  preview: function( pblock, urlToTrim){
    pblock.innerHTML = "Replaces the selected URL with a tr.im url.";
    var baseUrl = "http://api.tr.im/api/trim_simple?url=";
    pblock.innerHTML = "Replaces the selected URL with ",
    jQuery.get( baseUrl + urlToTrim.text, function( trim ) {
      if(trim != "Error") pblock.innerHTML += trim;
    });
  },
  execute: function(urlToTrim) {
    //escaping urlToShorten will not create the right tinyurl
    var baseUrl = "http://api.tr.im/api/trim_simple?url=";
    jQuery.get( baseUrl + urlToTrim.text, function( trim ) {
      CmdUtils.setSelection( trim );
    });
  }
});
