resdirSettings.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* $Id: resdirSettings.js 2758 2007-03-25 18:26:15Z b4rt $ */
  2. /**
  3. * addDirEntry
  4. */
  5. function addDirEntry () {
  6. var val = lrtrim(document.theForm.resdirentry.value);
  7. if (val != "") {
  8. if (val.indexOf('/') != -1) {
  9. alert("No slashes allowed");
  10. return false;
  11. }
  12. for (var i = 0; i < document.theForm.resdirlist.options.length; i++) {
  13. if ((lrtrim(document.theForm.resdirlist.options[i].text)) == val) {
  14. alert("Entry already exists.");
  15. return false;
  16. }
  17. }
  18. var resliststr = document.theForm.dir_restricted;
  19. var reslist = document.theForm.resdirlist;
  20. var newentry = document.createElement("option");
  21. newentry.text = val;
  22. document.theForm.resdirentry.value = "";
  23. newentry.value = reslist.length;
  24. if (navigator.appName == "Netscape") {
  25. reslist.add(newentry, null);
  26. } else {
  27. reslist.add(newentry);
  28. }
  29. if (resliststr.value == "") {
  30. resliststr.value = newentry.text;
  31. } else {
  32. resliststr.value = resliststr.value + ":" + newentry.text;
  33. }
  34. } else {
  35. alert("Please enter a Entry first!");
  36. }
  37. }
  38. /**
  39. * removeDirEntry
  40. */
  41. function removeDirEntry() {
  42. var resliststr = document.theForm.dir_restricted;
  43. if (document.theForm.resdirlist.selectedIndex != -1) {
  44. document.theForm.resdirlist.remove(document.theForm.resdirlist.selectedIndex);
  45. var newValue = "";
  46. for (var j = 0; j < document.theForm.resdirlist.options.length; j++) {
  47. if (j > 0) {
  48. newValue += ":";
  49. }
  50. newValue += lrtrim(document.theForm.resdirlist.options[j].text);
  51. }
  52. resliststr.value = lrtrim(newValue);
  53. } else {
  54. alert("Please select an entry first!");
  55. }
  56. }