All pastes #190737 Raw Edit

ronino

public javascript v1 · immutable
·published 2006-10-04 08:28 UTC
rendered paste body
  // remove the given search bar or the last one if none is given, moving the  // submit button to the then last bar  function removeSearchBar(barId)  {    try    {      // nothing to remove, we always keep the first bar      if (barCount <= 1)        return false;      var form = document.getElementById("search");      var lastBarId = "searchBar" + barCount;      var rmBarId   = barId ? barId : lastBarId;      var rmBar = document.getElementById(rmBarId);      // move the submit button to the new last bar if the current last bar is      // removed      if (rmBarId == lastBarId)      {        var submit = getSubmitButton(lastBarId).cloneNode(true);        document.getElementById("searchBar" + (barCount - 1)).appendChild(submit);      }      // remove the selected bar      if (rmBar)        form.removeChild(rmBar);      barCount--;      updateMenuBar();    }    catch (e)    {      window.status = e.message;    }  }