|
1 | | -// Compute and Check the input data |
2 | | -function plugaddr_Compute(msg) { |
3 | | - |
4 | | - var ipdeb = new Array(); |
5 | | - var ipfin = new Array(); |
6 | | - var subnet = new Array(); |
7 | | - var netmask = new Array(); |
8 | | - var i; |
9 | | - var val; |
10 | | - |
11 | | - document.getElementById("plugaddr_range").innerHTML = ""; |
12 | | - document.getElementById("plugaddr_ipdeb").value = ""; |
13 | | - document.getElementById("plugaddr_ipfin").value = ""; |
14 | | - |
15 | | - for (var i = 0; i < 4; i++) { |
16 | | - val=document.getElementById("plugaddr_ipdeb"+i).value; |
17 | | - if (val=='' || isNaN(val) || parseInt(val)<0 || parseInt(val)>255) { |
18 | | - document.getElementById("plugaddr_range").innerHTML=msg+" ("+val+")"; |
19 | | - return false; |
20 | | - } |
21 | | - ipdeb[i]=parseInt(val); |
22 | | - |
23 | | - val=document.getElementById("plugaddr_ipfin"+i).value; |
24 | | - if (val=='' || isNaN(val) || parseInt(val)<0 || parseInt(val)>255) { |
25 | | - document.getElementById("plugaddr_range").innerHTML=msg+" ("+val+")"; |
26 | | - return false; |
27 | | - } |
28 | | - ipfin[i]=parseInt(val); |
29 | | - } |
30 | | - |
31 | | - if (ipdeb[0]>ipfin[0]) { |
32 | | - document.getElementById("plugaddr_range").innerHTML=msg+" ("+ipdeb[0]+">"+ipfin[0]+")"; |
33 | | - return false; |
34 | | - } |
35 | | - if (ipdeb[0]==ipfin[0] && ipdeb[1]>ipfin[1]) { |
36 | | - document.getElementById("plugaddr_range").innerHTML=msg+" ("+ipdeb[1]+">"+ipfin[1]+")"; |
37 | | - return false; |
38 | | - } |
39 | | - if (ipdeb[0]==ipfin[0] && ipdeb[1]==ipfin[1] && ipdeb[2]>ipfin[2]) { |
40 | | - document.getElementById("plugaddr_range").innerHTML=msg+" ("+ipdeb[2]+">"+ipfin[2]+")"; |
41 | | - return false; |
42 | | - } |
43 | | - if (ipdeb[0]==ipfin[0] && ipdeb[1]==ipfin[1] && ipdeb[2]==ipfin[2] && ipdeb[3]>ipfin[3]) { |
44 | | - document.getElementById("plugaddr_range").innerHTML=msg+" ("+ipdeb[3]+">"+ipfin[3]+")"; |
45 | | - return false; |
46 | | - } |
47 | | - document.getElementById("plugaddr_range").innerHTML=""+ipdeb[0]+"."+ipdeb[1]+"."+ipdeb[2]+"."+ipdeb[3]+" - "+ipfin[0]+"."+ipfin[1]+"."+ipfin[2]+"."+ipfin[3]; |
48 | | - document.getElementById("plugaddr_ipdeb").value=""+ipdeb[0]+"."+ipdeb[1]+"."+ipdeb[2]+"."+ipdeb[3]; |
49 | | - document.getElementById("plugaddr_ipfin").value=""+ipfin[0]+"."+ipfin[1]+"."+ipfin[2]+"."+ipfin[3]; |
50 | | - return true; |
51 | | -} |
52 | | - |
53 | | -// Check the input data (from onSubmit) |
54 | | -function plugaddr_Check(msg) { |
55 | | - |
56 | | - if (plugaddr_Compute(msg)) { |
57 | | - return true; |
58 | | - } |
59 | | - alert(msg); |
60 | | - return false; |
61 | | -} |
62 | | - |
63 | 1 | // Display initial values |
64 | 2 | function plugaddr_Init(msg) { |
65 | 3 |
|
66 | | - var ipdeb = new Array(); |
67 | | - var ipfin = new Array(); |
| 4 | + var ipdeb; |
| 5 | + var ipfin; |
68 | 6 |
|
69 | | - var ipdebstr = document.getElementById("plugaddr_ipdeb").value; |
70 | | - var ipfinstr = document.getElementById("plugaddr_ipfin").value; |
| 7 | + var ipdebstr = document.getElementById("plugaddr_ipdeb").value; |
| 8 | + var ipfinstr = document.getElementById("plugaddr_ipfin").value; |
71 | 9 |
|
72 | | - document.getElementById("plugaddr_range").innerHTML=""+ipdebstr+" - "+ipfinstr; |
73 | | - |
74 | | - ipdeb=ipdebstr.split("."); |
75 | | - ipfin=ipfinstr.split("."); |
76 | | - for (i=0;i<4;i++) { |
77 | | - document.getElementById("plugaddr_ipdeb"+i).value=ipdeb[i]; |
78 | | - document.getElementById("plugaddr_ipfin"+i).value=ipfin[i]; |
79 | | - } |
| 10 | + document.getElementById("plugaddr_range").innerHTML = "" + ipdebstr + " - " + ipfinstr; |
80 | 11 | } |
81 | 12 |
|
82 | | -// Refresh the check message after onChange (from text input) |
83 | | -// function plugaddr_ChangeNumber(msg) { |
84 | | -// |
85 | | -// var lst=document.getElementById("plugaddr_subnet"); |
86 | | -// if (lst!=null) { |
87 | | -// lst.selectedIndex=0; |
88 | | -// } |
89 | | -// |
90 | | -// plugaddr_Compute(msg); |
91 | | -// } |
92 | | - |
93 | | -// Refresh the check message after onChange (from list) |
94 | | -// function plugaddr_ChangeList(id,msg) { |
95 | | -// |
96 | | -// var i; |
97 | | -// var lst=document.getElementById(id); |
98 | | -// if (lst.value == "0") { |
99 | | -// return; |
100 | | -// } |
101 | | -// var champ=lst.value.split("/"); |
102 | | -// var subnet=champ[0].split("."); |
103 | | -// var netmask=champ[1].split(".", 4); |
104 | | -// var ipdeb = new Array(); |
105 | | -// var ipfin = new Array(); |
106 | | -// |
107 | | -// netmask[3] = parseInt(netmask[3]).toString(); |
108 | | -// if (lst.selectedIndex>0) { |
109 | | -// for (var i=0;i<4;i++) { |
110 | | -// ipdeb[i]=subnet[i]&netmask[i]; |
111 | | -// ipfin[i]=ipdeb[i]|(255-netmask[i]); |
112 | | -// if (i==3) { |
113 | | -// ipdeb[3]++; |
114 | | -// ipfin[3]--; |
115 | | -// } |
116 | | -// document.getElementById("plugaddr_ipdeb"+i).value=ipdeb[i]; |
117 | | -// document.getElementById("plugaddr_ipfin"+i).value=ipfin[i]; |
118 | | -// } |
119 | | -// plugaddr_Compute(msg); |
120 | | -// } |
121 | | -// } |
122 | | - |
123 | 13 | function nameIsThere(params) { |
124 | 14 | var root_doc = params; |
125 | 15 | var nameElm = $('input[id*="name_reserveip"]'); |
126 | 16 | var typeElm = $('select[name="type"]'); |
127 | 17 | var divNameItemElm = $('div[id="nameItem"]'); |
128 | 18 | $.ajax({ |
129 | | - url: root_doc + '/front/addressing.php', |
130 | | - type: "GET", |
131 | | - dataType: "json", |
132 | | - data: { |
| 19 | + url: root_doc + '/front/addressing.php', |
| 20 | + type: "GET", |
| 21 | + dataType: "json", |
| 22 | + data: { |
133 | 23 | action: 'isName', |
134 | 24 | name: (nameElm.length != 0) ? nameElm.val() : '0', |
135 | 25 | type: (typeElm.length != 0) ? typeElm.val() : '0', |
136 | | - }, |
137 | | - success: function (json) { |
| 26 | + }, |
| 27 | + success: function (json) { |
138 | 28 | if (json) { |
139 | 29 | divNameItemElm.show(); |
140 | 30 | } else { |
141 | | - divNameItemElm.hide(); |
| 31 | + divNameItemElm.hide(); |
142 | 32 | } |
143 | | - } |
144 | | - }); |
| 33 | + } |
| 34 | + }); |
145 | 35 | } |
0 commit comments