diff templates/classic/html/help_controls.js @ 1900:db187e5cabc6 maint-0.6

backport from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Thu, 06 Nov 2003 07:19:17 +0000
parents c4968040459e
children 75fe2131b6d9
line wrap: on
line diff
--- a/templates/classic/html/help_controls.js	Tue Nov 04 12:39:54 2003 +0000
+++ b/templates/classic/html/help_controls.js	Thu Nov 06 07:19:17 2003 +0000
@@ -51,29 +51,34 @@
   return temp;
 }
 
+function determineList() {
+  // generate a comma-separated list of the checked items
+  if (document.frm_help.check==undefined) { return; }
+  var list = new Array();
+  if (document.frm_help.check.length==undefined) {
+      if (document.frm_help.check.checked) {
+          list.push(document.frm_help.check.value);
+      }
+  } else {
+      for (box=0; box < document.frm_help.check.length; box++) {
+          if (document.frm_help.check[box].checked) {
+              list.push(document.frm_help.check[box].value);
+          }
+      }
+  }
+  return new String(list.join(','));
+}
+
 function updateList() {
   // write back to opener window
   if (document.frm_help.check==undefined) { return; }
-  var list = new Array();
-  for (box=0; box < document.frm_help.check.length; box++) {
-      if (document.frm_help.check[box].checked) {
-          list.push(document.frm_help.check[box].value);
-      }
-  }
-  window.opener.document.itemSynopsis[field].value = list.join(",");
+  window.opener.document.itemSynopsis[field].value = determineList();
 }
 
 function updatePreview() {
-  // add new checkbox selections to preview
+  // update the preview box
   if (document.frm_help.check==undefined) { return; }
-  var list = new Array();
-  for (box=0; box < document.frm_help.check.length; box++) {
-      if (document.frm_help.check[box].checked) {
-          list.push(document.frm_help.check[box].value);
-      }
-  }
-  listString = new String(list.join(','));
-  writePreview(listString);
+  writePreview(determineList());
 }
 
 function clearList() {
@@ -89,7 +94,18 @@
   if (document.frm_help.check==undefined) { return; }
   var to_check;
   var list = vals.split(",");
-   for (box=0; box < document.frm_help.check.length; box++) {
+  if (document.frm_help.check.length==undefined) {
+      check = document.frm_help.check;
+      to_check = false;
+      for (val in list) {
+          if (check.value==trim(list[val])) {
+              to_check = true;
+              break;
+          }
+      }
+      check.checked = to_check;
+  } else {
+    for (box=0; box < document.frm_help.check.length; box++) {
       check = document.frm_help.check[box];
       to_check = false;
       for (val in list) {
@@ -99,26 +115,15 @@
           }
       }
       check.checked = to_check;
+    }
   }
 }
 
 function resetList() {
   // reset preview and check boxes to initial values
   if (document.frm_help.check==undefined) { return; }
-  var to_check;
-  var list = original_field.split(',');
-  writePreview(list);
-  for (box=0; box < document.frm_help.check.length; box++) {
-      check = document.frm_help.check[box];
-      to_check = false;
-      for (val in list) {
-          if (check.value==trim(list[val])) {
-              to_check = true;
-              break;
-          }
-      }
-      check.checked = to_check;
-  }
+  writePreview(original_field);
+  reviseList(original_field);
 }
 
 function writePreview(val) {

Roundup Issue Tracker: http://roundup-tracker.org/