moveSettings.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* $Id: moveSettings.js 2758 2007-03-25 18:26:15Z b4rt $ */
  2. /**
  3. * addMoveEntry
  4. */
  5. function addMoveEntry () {
  6. var val = lrtrim(document.theForm.category.value);
  7. if (val == "") {
  8. alert("Please enter a Directory first!");
  9. return false;
  10. } else if (val.indexOf('/') != 0) {
  11. alert("Directory must be absolute !");
  12. return false;
  13. } else {
  14. for (var i = 0; i < document.theForm.categorylist.options.length; i++) {
  15. if ((lrtrim(document.theForm.categorylist.options[i].text)) == val) {
  16. alert("Move-dir already exists");
  17. return false;
  18. }
  19. if ((lrtrim(document.theForm.categorylist.options[i].text)) == val + "/") {
  20. alert("Move-dir already exists");
  21. return false;
  22. }
  23. }
  24. var catliststr = document.theForm.move_paths;
  25. var catliste = document.theForm.categorylist;
  26. var newentry = document.createElement("option");
  27. newentry.text = val;
  28. // empty the new category field
  29. document.theForm.category.value = "";
  30. newentry.value = catliste.length;
  31. if (navigator.appName == "Netscape")
  32. catliste.add(newentry, null);
  33. else
  34. catliste.add(newentry);
  35. if (catliststr.value == "")
  36. catliststr.value = newentry.text;
  37. else
  38. catliststr.value = catliststr.value + ":" + newentry.text;
  39. }
  40. }
  41. /**
  42. * removeMoveEntry
  43. */
  44. function removeMoveEntry() {
  45. var catliststr = document.theForm.move_paths;
  46. if (document.theForm.categorylist.selectedIndex != -1) {
  47. document.theForm.categorylist.remove(document.theForm.categorylist.selectedIndex);
  48. var newValue = "";
  49. for (var j = 0; j < document.theForm.categorylist.options.length; j++) {
  50. if (j > 0)
  51. newValue += ":";
  52. newValue += lrtrim(document.theForm.categorylist.options[j].text);
  53. }
  54. catliststr.value = lrtrim(newValue);
  55. } else {
  56. alert("Please select an entry first!");
  57. }
  58. }