From: richard Date: Thu, 6 Nov 2003 07:17:43 +0000 (+0000) Subject: fixed javascript for help window for only one checkbox case X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f7108f5a72a1af9db3ac8be3c88cf4db8d38a2d5;p=roundup.git fixed javascript for help window for only one checkbox case git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1968 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 7ef8fda..4e1a4ae 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -45,6 +45,7 @@ Fixed: - added script to help migrating queries from pre-0.6 trackers - Fixed "documentation" of getnodeids in roundup.hyperdb - added flush() to DevNull (sf bug #835365) +- fixed javascript for help window for only one checkbox case 2003-09-29 0.6.2 diff --git a/templates/classic/html/help_controls.js b/templates/classic/html/help_controls.js index 199cb1f..c2a84e4 100644 --- a/templates/classic/html/help_controls.js +++ b/templates/classic/html/help_controls.js @@ -51,29 +51,34 @@ function trim(value) { return temp; } -function updateList() { - // write back to opener window +function determineList() { + // generate a comma-separated list of the checked items 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); + 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); + } } } - window.opener.document.itemSynopsis[field].value = list.join(","); + return new String(list.join(',')); +} + +function updateList() { + // write back to opener window + if (document.frm_help.check==undefined) { return; } + 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,8 +94,8 @@ function reviseList(vals) { if (document.frm_help.check==undefined) { return; } var to_check; var list = vals.split(","); - for (box=0; box < document.frm_help.check.length; box++) { - check = document.frm_help.check[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])) { @@ -99,16 +104,8 @@ function reviseList(vals) { } } 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++) { + } else { + for (box=0; box < document.frm_help.check.length; box++) { check = document.frm_help.check[box]; to_check = false; for (val in list) { @@ -118,9 +115,17 @@ function resetList() { } } check.checked = to_check; + } } } +function resetList() { + // reset preview and check boxes to initial values + if (document.frm_help.check==undefined) { return; } + writePreview(original_field); + reviseList(original_field); +} + function writePreview(val) { // writes a value to the text_preview document.frm_help.text_preview.value = val;