-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (47 loc) · 1.44 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<body>
<h2> Paste the output of "show server list ipv6" from CSCF OA to generate the full length IPv6 List</h2>
<form action="?">
<textarea id="text1" name="text1" placeholder="Enter the IPv6 address(s). If more than one then enter one line each" rows="20" cols="100" ></textarea>
<br><input type="button" id="btn1" value="Submit">
<p class="output" id="out1"> </p>
</form>
<script>
const text1=document.getElementById('text1')
const btn1=document.getElementById('btn1')
const out1=document.getElementById('out1')
btn1.addEventListener('click',func1)
function func1() {
//text2=text1.value
out1.innerHTML= out2ipv6list(text1.value)
}
function out2ipv6list(text){
myArr=text.split("\n")
let text2=""
for (i=0;i<myArr.length;i++) {
if (myArr[i].includes("EBIPA")){
text2=text2+padIPv6( myArr[i].replace("EBIPA","").trim())+" - "+padIPv6(myArr[i].replace("EBIPA","").trim()).replaceAll(":","").split("").reverse().join(".")+"<br>"
}
}
return text2
}
var countColons = function (x) {
var n = 0;
x.replace(/:/g, function (c) { n++; });
return n;
};
var padIPv6 = function (ip) {
return ip
.replace(/::/, function (two) {
return ':' + Array((7 - countColons(ip)) + 1).join(':') + ':';
})
.split(':')
.map(function (x) {
return Array(4-x.length).fill('0').join("") + x;
})
.join(':');
};
</script>
</body>
</html>