I need to be able to convert a string (IP address) such as this 10.120.0.1
to a string (ISIS Network ID) such as this 49.0001.0101.2000.0001.00
. The middle section 010 1.20 00.0 001
corresponds to the first string (I've spaced them out to show the IP address is inside it). You can see that there are 4 digits in each ISIS Network ID hextet that need to correspond to 3 digits in the IP Address octet. A number of 53
for example would have a leading 0
to make 3 digits.
All the IP addresses start with 10.120.
so I just need to inject the last 2 octets from the IP Address into the ISIS Network ID.
I need this to be dynamic so when someone types in another ip address into a loopbackIP
input, it automatically updates the isisNetworkID
field.
I have this:
49.0001.0101.{{ isisNetworkID }}.00
This needs to take the value from an input v-model="loopbackIP"
that I have and translate the remaining values to sit in the middle of that isisNetworkID
following this format - xxxx.xxxx
.
I've got this computed calculation but I'm not sure how to make 4 digits equal 3...
const loopbackIP = '10.120.0.1';
const isisNetworkID = computed(() => {
let idaho = '10.120.';
if (loopbackIP.indexOf(idaho)) {
return loopbackIP.slice(7);
} else {
console.log('Nothing is happening');
}
});
I hope this makes sense...