diff options
| -rw-r--r-- | index.js | 22 | ||||
| -rw-r--r-- | style.scss | 5 |
2 files changed, 24 insertions, 3 deletions
@@ -34,9 +34,22 @@ class IPAddress extends React.Component { } } - render() { - var pretty = this.state.octets.join('.') + '/' + this.state.cidr + getPretty = () => { + return this.state.octets.join('.') + '/' + this.state.cidr + } + getNetmask = () => { + if (this.state.cidr == 0) { + return '0.0.0.0' + } + else { + return [...Array(4)].map((x, octet) => + ((((0xFFFFFFFF << (32 - this.state.cidr)) >>> 0) >>> (3-octet)*8) & 0xFF) + ).join('.') + } + } + + render() { return <div className="ip-address"> <div className="address"> {[...Array(4)].map((x, octet) => @@ -61,6 +74,11 @@ class IPAddress extends React.Component { )} </ol> </div> + + <div className="details"> + <span className="netmask">Netmask: {this.getNetmask()}</span> + </div> + </div> } } @@ -63,7 +63,10 @@ body { &:nth-child(2) ol li.bit.unmasked { background-color: lighten($color_b, $octet_lighten); } &:nth-child(3) ol li.bit.unmasked { background-color: lighten($color_c, $octet_lighten); } &:nth-child(4) ol li.bit.unmasked { background-color: lighten($color_d, $octet_lighten); } - ol li.bit.masked { background-color: lighten($color_e, $octet_lighten); } + ol li.bit.masked { + background-color: lighten($color_e, $octet_lighten); + color: lighten($color_e, 22%); + } } } } |
