Skip to content

Commit

Permalink
Network calculator, bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Dec 5, 2024
1 parent cf083b6 commit 95fbc25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Protest/Front/ipbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class IpBox {
}

SetEnabled(option) {
for (let i = 0; i < 4; i++) {
for (let i=0; i<4; i++) {
this.textBoxes[i].disabled = !option;
}
}
Expand Down
26 changes: 5 additions & 21 deletions Protest/Front/netcalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class NetCalc extends Window {
this.ipMask.SetIp(255,255,255,0);
this.ipMask.Attach(maskBox);

this.ipMask.textBoxes[0].readOnly = true;
this.ipMask.textBoxes[1].readOnly = true;
this.ipMask.textBoxes[2].readOnly = true;
this.ipMask.textBoxes[3].readOnly = true;

let slashLabel = document.createElement("div");
slashLabel.textContent = "/";
slashLabel.style.display = "inline-block";
Expand Down Expand Up @@ -216,27 +221,6 @@ class NetCalc extends Window {
this.Calculate();
};

this.ipMask.textBoxes[0].onkeyup = this.ipMask.textBoxes[0].oninput =
this.ipMask.textBoxes[1].onkeyup = this.ipMask.textBoxes[1].oninput =
this.ipMask.textBoxes[2].onkeyup = this.ipMask.textBoxes[2].oninput =
this.ipMask.textBoxes[3].onkeyup = this.ipMask.textBoxes[3].oninput = ()=> {
let bits = parseInt(this.ipMask.textBoxes[0].value).toString(2) +
parseInt(this.ipMask.textBoxes[1].value).toString(2) +
parseInt(this.ipMask.textBoxes[2].value).toString(2) +
parseInt(this.ipMask.textBoxes[3].value).toString(2);

let bitCount = 0;
for (let i = 0; i < bits; i++) {
if (bits[i] == "0") break;
bitCount++;
}

this.cidrRange.value = bitCount;
this.cidrInput.value = bitCount;

this.Calculate();
};

this.Calculate();
}

Expand Down
6 changes: 2 additions & 4 deletions Protest/Tools/MacLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public static string LookupToString(string mac) {
mac = mac.Replace("-", String.Empty);
mac = mac.Replace(":", String.Empty);
mac = mac.Replace(" ", String.Empty);
if (mac.Length < 6)
return null;
if (mac.Length < 6) return null;

byte[] t = new byte[4];
try {
Expand All @@ -41,8 +40,7 @@ public static string LookupToString(string mac) {

try {
FileInfo file = new FileInfo(Data.FILE_MAC);
if (!file.Exists)
return null;
if (!file.Exists) return null;

FileStream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);

Expand Down

0 comments on commit 95fbc25

Please sign in to comment.