CmdUtils.CreateCommand({
  names: ["assigntome"],
  icon: "https://bugzilla.mozilla.org/skins/custom/images/bugzilla.png",
  author: { name: "Jeremiah Orem", email: "oremj@mozilla.com"},
  arguments: [ { role: "object",
                 nountype: ["submit", "dont_submit"],
                 label: "submit"} ],
  license: "MPL",
  description: "Assigns current bug to you.",

  preview: function(pblock, url) {
    var template = "Assign current bug to you.";
    pblock.innerHTML = CmdUtils.renderTemplate(template, {});
  },
  execute: function( arguments ) {
    var logout_re = /[\s\S]*Log.*out.*[\s]\s*(.*)\s/m;
    var doc = jQuery(Application.activeWindow.activeTab.document);
    var user_name = doc.find('#useful-links').find('ul.links:first').find('li:last').text().replace(logout_re, "$1");
    doc.find('#bz_assignee_edit_container').hide();
    doc.find('#bz_assignee_input').show();
    doc.find('#assigned_to').attr("value",user_name);
    if( arguments.object.text == "submit" ) {
      doc.find('#commit_top').click();
    }
  }
});
/* OLD API
noun_type_bugzilla = new CmdUtils.NounType("bugzilla",["submit", "dont_submit"]);

CmdUtils.CreateCommand({
  name: "assigntome",
  icon: "https://bugzilla.mozilla.org/skins/custom/images/bugzilla.png",
  author: { name: "Jeremiah Orem", email: "oremj@mozilla.com"},
  takes: { "action": noun_type_bugzilla },

  license: "MPL",
  description: "Assigns current bug to you.",

  preview: function(pblock, url) {
    var template = "Assign current bug to you.";
    pblock.innerHTML = CmdUtils.renderTemplate(template, {});
  },
  execute: function(command) {
    var logout_re = /[\s\S]*Log.*out.*[\s]\s*(.*)\s/m;
    var doc = jQuery(Application.activeWindow.activeTab.document);
    var user_name = doc.find('#useful-links').find('ul.links:first').find('li:last').text().replace(logout_re, "$1");
    doc.find('#bz_assignee_edit_container').hide();
    doc.find('#bz_assignee_input').show();
    doc.find('#assigned_to').attr("value",user_name);
    if( command.text == "submit" ) {
      doc.find('#commit_top').click();
    }
  }
});
*/

