summaryrefslogtreecommitdiffstats
path: root/tinydns-edit-html.lsp
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-06-20 19:46:54 +0000
committerTed Trask <ttrask01@yahoo.com>2008-06-20 19:46:54 +0000
commit0ef2d768dcf5a12cf90ed8fa5193fb9382947173 (patch)
tree9a88411564e715e64c55e8bf6b4cece10c55148e /tinydns-edit-html.lsp
parentd2dab8685a8aef5a773ab088f4a5c926c673e0df (diff)
downloadacf-tinydns-0ef2d768dcf5a12cf90ed8fa5193fb9382947173.tar.bz2
acf-tinydns-0ef2d768dcf5a12cf90ed8fa5193fb9382947173.tar.xz
Cleaned up tinydns javascript and made it work on Firefox.
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1221 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'tinydns-edit-html.lsp')
-rw-r--r--tinydns-edit-html.lsp91
1 files changed, 46 insertions, 45 deletions
diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp
index f1a2f50..6a19c65 100644
--- a/tinydns-edit-html.lsp
+++ b/tinydns-edit-html.lsp
@@ -4,32 +4,17 @@
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript">
var editEntry = '<td> \
- <a href="javascript:;"><img src="/skins/static/tango/16x16/actions/list-add.png" width="16" height="16" title="Add item below this record"></a> \
- <a href="javascript:;"><img src="/skins/static/tango/16x16/actions/list-remove.png" width="16" height="16" title="Remove this record"></a> \
- <a href="javascript:;"><img src="/skins/static/tango/16x16/actions/document-properties.png" width="16" height="16" title="Edit this record"></a> \
+ <a href="javascript:;"><img src="/skins/static/tango/16x16/actions/list-add.png" width="16" height="16" title="Insert record"></a> \
+ <a href="javascript:;"><img src="/skins/static/tango/16x16/actions/list-remove.png" width="16" height="16" title="Remove record"></a> \
+ <a href="javascript:;"><img src="/skins/static/tango/16x16/actions/document-properties.png" width="16" height="16" title="Edit record"></a> \
</td>';
- addLinks = function(rows){
- rows.each(function(){
- $(this).prepend(editEntry);
- $(this).find("td > a:eq(0)").click(addLine);
- $(this).find("td > a:eq(1)").click(deleteLine);
- $(this).find("td > a:eq(2)").click(editLine);
- $(this).find("td:eq(1)").dblclick(editLine);
- });
- }
- addLine = function(){
- addLinks($(this).parent().parent().after('<tr><td></td></tr>').next());
- };
- deleteLine = function(){
- $(this).parent().parent().replaceWith();
- };
function Entry(entryType,descr,num,descr0,descr1,descr2,descr3,descr4,descr5,descr6,descr7,descr8,descr9,descr10){
this.entryType=entryType;
this.descr=descr;
- this.num=num;this.descriptions=new Array(11)
+ this.num=num;this.descriptions=new Array(11);
this.descriptions[0]=descr0;this.descriptions[1]=descr1;this.descriptions[2]=descr2;this.descriptions[3]=descr3;this.descriptions[4]=descr4;this.descriptions[5]=descr5;this.descriptions[6]=descr6;this.descriptions[7]=descr7;this.descriptions[8]=descr8;this.descriptions[9]=descr9;this.descriptions[10]=descr10;
- };
+ }
var entryTypes = new Array(14);
entryTypes[0]=new Entry("","Empty line",0);
@@ -47,27 +32,33 @@
entryTypes[12]=new Entry(":","Generic record",6,"Domain","Record type","Record data","Time to live","Timestamp","Location");
entryTypes[13]=new Entry("%","Client location",2,"Location","IP prefix");
- createForm = function(entry){
+ function finishForm(entry){
+ var entrytext = entry.find("select").val() + entry.find("input").map(function(){
+ return $(this).val();
+ }).get().join(":");
+ entry.empty().append(entrytext);
+ }
+ function createForm(entry){
var entrytext = entry.text();
var entryType = entryTypes[0];
var form = '<select>';
var typechar = entrytext.charAt(0);
- if (typechar == null) typechar = "";
+ if (typechar === null) { typechar = ""; }
for (i=0; i<14; i++) {
form = form + '<option ';
if (typechar == entryTypes[i].entryType){
entryType=entryTypes[i];
form = form + 'selected ';
- };
+ }
form = form + 'value="' + entryTypes[i].entryType + '">' + entryTypes[i].entryType + ' (' + entryTypes[i].descr + ')</option>';
- };
+ }
form = form + "</select><br><dl>";
- entrytext = entrytext.substring(1,entrytext.length);
+ entrytext = entrytext.substring(1,entrytext.length) + "::::::::::";
var entries = entrytext.split(":");
for (i=0; i<entryType.num; i++){
- if (entries[i] == null) entries[i] = "";
+ if (entries[i] === null) { entries[i] = ""; }
form = form + '<dt>' + entryType.descriptions[i] + '</dt><dd><input type="text" value="' + entries[i] + '"></dd>';
- };
+ }
form = form + "</dl>";
entry.empty().append(form);
entry.find("select").change(function(){
@@ -75,41 +66,51 @@
finishForm(entry);
createForm(entry);
});
- };
- finishForm = function(entry){
- var entrytext = entry.find("select").val() + entry.find("input").map(function(){
- return $(this).val();
- }).get().join(":");
- entry.empty().append(entrytext);
- };
- editLine = function(){
- var parent = $(this).parent()
+ }
+ function editLine(){
+ var parent = $(this).parent();
if (parent.is("td")) {
parent = parent.parent();
- };
+ }
var entry = parent.find("td:eq(1)");
if (entry.find("select").is("select")){
finishForm(entry);
} else {
createForm(entry);
}
- };
- submitFile = function(){
- var file = ""
+ }
+ function deleteLine(){
+ $(this).parent().parent().replaceWith();
+ }
+ function addLine(){
+ addLinks($(this).parent().parent().before('<tr><td></td></tr>').prev());
+ }
+ function addLinks(rows){
+ rows.each(function(){
+ $(this).prepend(editEntry);
+ $(this).find("td > a:eq(0)").click(addLine);
+ $(this).find("td > a:eq(1)").click(deleteLine);
+ $(this).find("td > a:eq(2)").click(editLine);
+ $(this).find("td:eq(1)").dblclick(editLine);
+ });
+ }
+ function submitFile(){
+ var file = "";
var lines = $("#entries").find("tr").find("td:eq(1)");
lines.each(function(){
- if (jQuery(this).find("select").is("select")){
- finishForm(jQuery(this));
+ var elem = jQuery(this);
+ if (elem.find("select").is("select")){
+ finishForm(elem);
}
- file = file + this.innerText + "\n";
+ file = file + elem.text() + "\n";
});
$("input:eq(1)").val(file);
- };
+ }
$(function(){
addLinks($("#entries").find("tr"));
$("input.submit").click(submitFile);
- })
+ });
</script>
<?