summaryrefslogtreecommitdiffstats
path: root/interfaces-update-html.lsp
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-06-30 17:19:43 +0000
committerTed Trask <ttrask01@yahoo.com>2008-06-30 17:19:43 +0000
commit105b8e5ea1aa3cf0f7c3101cffc30727cc3ed70f (patch)
treee96c0151b86f8a693edee2de575055608a8bc9b9 /interfaces-update-html.lsp
parentb3fd56ef548acf58fcbdb2d565030a487826ccf0 (diff)
downloadacf-alpine-baselayout-105b8e5ea1aa3cf0f7c3101cffc30727cc3ed70f.tar.bz2
acf-alpine-baselayout-105b8e5ea1aa3cf0f7c3101cffc30727cc3ed70f.tar.xz
Added javascript to interfaces update/create pages. Minor changes to tinydns and viewfunctions.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1264 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'interfaces-update-html.lsp')
-rw-r--r--interfaces-update-html.lsp150
1 files changed, 147 insertions, 3 deletions
diff --git a/interfaces-update-html.lsp b/interfaces-update-html.lsp
index 453afe9..13e7181 100644
--- a/interfaces-update-html.lsp
+++ b/interfaces-update-html.lsp
@@ -1,6 +1,148 @@
-<? local form = ...
+<? local form, viewlibrary, page_info = ...
require("viewfunctions")
?>
+
+<script type="text/javascript" src="/js/jquery-latest.js"></script>
+<script type="text/javascript">
+ // Here are the optional form entries
+ <? -- I'm going to temporarily override the io.write function so I can remove \n from the form items
+ local tmpwrite = io.write
+ local buffer = {}
+ io.write = function(...)
+ for i,item in ipairs{...} do
+ buffer[#buffer+1] = item
+ end
+ end
+ function outputbuffer()
+ print((table.concat(buffer,""):gsub("\n","")))
+ buffer = {}
+ end
+ ?>
+ var _address = '<? displayformitem({ name="address", label="Address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _netmask = '<? displayformitem({ name="netmask", label="Netmask", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _broadcast = '<? displayformitem({ name="broadcast", label="Broadcast address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _network = '<? displayformitem({ name="network", label="Network address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _metric = '<? displayformitem({ name="metric", label="Routing metric", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _gateway = '<? displayformitem({ name="gateway", label="Default gateway", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _pointopoint = '<? displayformitem({ name="pointopoint", label="Point-to-point address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _media = '<? displayformitem({ name="media", label="Medium type", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _hwaddress = '<? displayformitem({ name="hwaddress", label="Hardware address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _mtu = '<? displayformitem({ name="mtu", label="MTU size", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _hostname = '<? displayformitem({ name="hostname", label="Hostname", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _leasehours = '<? displayformitem({ name="leasehours", label="Preferred lease time (hours)", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _leasetime = '<? displayformitem({ name="leasetime", label="Preferred lease time (seconds)", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _vendor = '<? displayformitem({ name="vendor", label="Vendor class identifier", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _client = '<? displayformitem({ name="client", label="Client identifier", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _bootfile = '<? displayformitem({ name="bootfile", label="Boot file", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _server = '<? displayformitem({ name="server", label="Server address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _hwaddr = '<? displayformitem({ name="hwaddr", label="Hardware address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _provider = '<? displayformitem({ name="provider", label="Provider name", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _frame = '<? displayformitem({ name="frame", label="Ethernet frame type", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _netnum = '<? displayformitem({ name="netnum", label="Network number", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _endpoint = '<? displayformitem({ name="endpoint", label="Endpoint address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _local = '<? displayformitem({ name="local", label="Local address", value="", type="text" }) ?>';<? outputbuffer() ?>
+ var _ttl = '<? displayformitem({ name="ttl", label="TTL setting", value="", type="text" }) ?>';<? outputbuffer() ?>
+ // Finally, add the different types of method inputs<? outputbuffer() ?>
+ var _inetmethod = '<? displayformitem({ name="method", type="select", value="", label="Method", errtxt="Must define method", option={"loopback", "static", "manual", "dhcp", "bootp", "ppp", "wvdial"} }) ?>';<? outputbuffer() ?>
+ var _ipxmethod = '<? displayformitem({ name="method", type="select", value="", label="Method", errtxt="Must define method", option={"static", "dynamic"} }) ?>';<? outputbuffer() ?>
+ var _inet6method = '<? displayformitem({ name="method", type="select", value="", label="Method", errtxt="Must define method", option={"loopback", "static", "manual", "v4tunnel"} }) ?>';<? outputbuffer() ?>
+ <? io.write = tmpwrite ?>
+
+ var optionalfields = "address,netmask,broadcast,network,metric,gateway,pointopoint,media,hwaddress,mtu,hostname,leasehours,leasetime,vendor,client,bootfile,server,hwaddr,provider,frame,netnum,endpoint,local,ttl";
+ var inetstaticfields = "address,netmask,broadcast,network,metric,gateway,pointopoint,media,hwaddress,mtu";
+ var inetdhcpfields = "hostname,leasehours,leasetime,vendor,client,hwaddress";
+ var inetbootpfields = "bootfile,server,hwaddr";
+ var inetpppfields = "provider";
+ var inetwvdialfields = "provider";
+ var ipxstaticfields = "frame,netnum";
+ var ipxdynamicfields = "frame";
+ var inet6staticfields = "address,netmask,gateway,media,hwaddress,mtu";
+ var inet6v4tunnelfields = "address,netmask,endpoint,local,gateway,ttl";
+
+ function showoptionalfields() {
+ var family = $("select[name='family']").val();
+ var method = $("select[name='method']").val();
+ var fieldstable = ""
+ if (family == "inet" && method == "static") fieldstable = inetstaticfields;
+ if (family == "inet" && method == "dhcp") fieldstable = inetdhcpfields;
+ if (family == "inet" && method == "bootp") fieldstable = inetbootpfields;
+ if (family == "inet" && method == "ppp") fieldstable = inetpppfields;
+ if (family == "inet" && method == "wvdial") fieldstable = inetwvdialfields;
+ if (family == "ipx" && method == "static") fieldstable = ipxstaticfields;
+ if (family == "ipx" && method == "dynamic") fieldstable = ipxdynamicfields;
+ if (family == "inet6" && method == "static") fieldstable = inet6staticfields;
+ if (family == "inet6" && method == "v4tunnel") fieldstable = inet6v4tunnelfields;
+
+ // show / hide all of the optional inputs
+ var visiblearray = fieldstable.split(',');
+ var optionalarray = optionalfields.split(',');
+ $("input").each(function() {
+ if (jQuery.inArray($(this).attr('name'), optionalarray)!=-1) {
+ if (jQuery.inArray($(this).attr('name'), visiblearray)==-1) {
+ $(this).parent().hide().prev().hide();
+ } else {
+ $(this).parent().show().prev().show();
+ }
+ }
+ });
+ }
+ function methodchange() {
+ $(this).removeClass('error').siblings().remove();
+ $(this).parent().prev().removeClass('error');
+ $(this).find("option").remove("*:contains('[')");
+ //$(this).remove("option:contains('[')");
+ showoptionalfields();
+ }
+ function familychange() {
+ $(this).removeClass('error').siblings().remove();
+ $(this).parent().prev().removeClass('error');
+ $(this).find("option").remove("*:contains('[')");
+ //$(this).remove("option:contains('[')");
+ var method = $("select[name='method']");
+ var newmethod = ""
+ if ($(this).val() == "inet") { newmethod = _inetmethod; }
+ if ($(this).val() == "ipx") { newmethod = _ipxmethod; }
+ if ($(this).val() == "inet6") { newmethod = _inet6method; }
+ if (method.length == 1) {
+ method.parent().prev().remove().end().replaceWith(newmethod);
+ } else {
+ $(this).parent().after(newmethod);
+ }
+ $("select[name='method']").change(methodchange);
+ showoptionalfields();
+ }
+ $(function(){
+ $("select[name='family']").change(familychange);
+ $("select[name='method']").change(methodchange);
+ var end = $(".submit").parent().prev();
+ if($("input[name='address']").length==0) end.before(_address);
+ if($("input[name='netmask']").length==0) end.before(_netmask);
+ if($("input[name='broadcast']").length==0) end.before(_broadcast);
+ if($("input[name='network']").length==0) end.before(_network);
+ if($("input[name='metric']").length==0) end.before(_metric);
+ if($("input[name='gateway']").length==0) end.before(_gateway);
+ if($("input[name='pointopoint']").length==0) end.before(_pointopoint);
+ if($("input[name='media']").length==0) end.before(_media);
+ if($("input[name='hwaddress']").length==0) end.before(_hwaddress);
+ if($("input[name='mtu']").length==0) end.before(_mtu);
+ if($("input[name='hostname']").length==0) end.before(_hostname);
+ if($("input[name='leasehours']").length==0) end.before(_leasehours);
+ if($("input[name='leasetime']").length==0) end.before(_leasetime);
+ if($("input[name='vendor']").length==0) end.before(_vendor);
+ if($("input[name='client']").length==0) end.before(_client);
+ if($("input[name='bootfile']").length==0) end.before(_bootfile);
+ if($("input[name='server']").length==0) end.before(_server);
+ if($("input[name='hwaddr']").length==0) end.before(_hwaddr);
+ if($("input[name='provider']").length==0) end.before(_provider);
+ if($("input[name='frame']").length==0) end.before(_frame);
+ if($("input[name='netnum']").length==0) end.before(_netnum);
+ if($("input[name='endpoint']").length==0) end.before(_endpoint);
+ if($("input[name='local']").length==0) end.before(_local);
+ if($("input[name='ttl']").length==0) end.before(_ttl);
+ showoptionalfields();
+ });
+</script>
+
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -9,9 +151,11 @@ io.write("</span>")
--]]
?>
-<h1><?= form.label ?> - <?= form.value.name.value ?></h1>
+<h1><?= form.label ?><? if page_info.action == "update" then io.write(" - "..form.value.name.value) end ?></h1>
<?
- form.value.name.contenteditable = false
+ if page_info.action == "update" then
+ form.value.name.contenteditable = false
+ end
local order = {"name", "comment", "auto", "family", "method", "pre-up", "up", "down", "post-down"}
displayform(form, order)
?>