diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2004-12-22 19:33:27 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2004-12-22 19:33:27 +0000 |
commit | eec70f2143b8726f905d44d3eef564a977fb1149 (patch) | |
tree | 54a1f800a120fda565c38d3ce263d5bbe7373424 /usr/local/www/row_helper_dynamic.js | |
parent | 2a520a0a1bc2bd9df601d828f84b9dc17da28147 (diff) | |
download | pfsense-eec70f2143b8726f905d44d3eef564a977fb1149.zip pfsense-eec70f2143b8726f905d44d3eef564a977fb1149.tar.gz |
Add rowhelper type which will place add and delete row items on a form. This can be used to group like items together on the web gui. First package employing this neat feature is pfStat
Diffstat (limited to 'usr/local/www/row_helper_dynamic.js')
-rwxr-xr-x | usr/local/www/row_helper_dynamic.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/usr/local/www/row_helper_dynamic.js b/usr/local/www/row_helper_dynamic.js new file mode 100755 index 0000000..10caca4 --- /dev/null +++ b/usr/local/www/row_helper_dynamic.js @@ -0,0 +1,66 @@ +// Global Variables +var rowname = new Array(99); +var rowtype = new Array(99); +var newrow = new Array(99); + +for (i = 0; i < 99; i++) { + rowname[i] = ''; + rowtype[i] = ''; + newrow[i] = ''; +} + +var field_counter_js = 0; +var loaded = 0; +var is_streaming_progress_bar = 0; +var temp_streaming_text = ""; + +var addRowTo = (function() { + return (function (tableId) { + var d, tbody, tr, td, bgc, i, ii, j; + d = document; + tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0); + tr = d.createElement("tr"); + totalrows++; + for (i = 0; i < field_counter_js; i++) { + td = d.createElement("td"); + if(rowtype[i] == 'textbox') { + td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input name='" + rowname[i] + totalrows + "'></input> "; + } else if(rowtype[i] == 'select') { + td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select name='" + rowname[i] + totalrows + "'>" + newrow[i] + "</select> "; + } else if(rowtype[i] == 'checkbox') { + td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input type='checkbox' name='" + rowname[i] + totalrows + "'></input> "; + } + tr.appendChild(td); + } + td = d.createElement("td"); + td.rowSpan = "1"; + td.innerHTML = '<input type="button" value="Delete" onclick="removeRow(this)">'; + tr.appendChild(td); + tbody.appendChild(tr); + }); +})(); + +function removeRow(el) { + var cel; + while (el && el.nodeName.toLowerCase() != "tr") + el = el.parentNode; + + if (el && el.parentNode) { + cel = el.getElementsByTagName("td").item(0); + el.parentNode.removeChild(el); + } +} + +function find_unique_field_name(field_name) { + // loop through field_name and strip off -NUMBER + var last_found_dash = 0; + for (var i = 0; i < field_name.length; i++) { + // is this a dash, if so, update + // last_found_dash + if (field_name.substr(i,1) == "-" ) + last_found_dash = i; + } + if (last_found_dash < 1) + return field_name; + return(field_name.substr(0,last_found_dash)); +} |