Created
June 17, 2015 05:15
-
-
Save Marahin/45519a0c8c4e75bfd39e to your computer and use it in GitHub Desktop.
bruno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="javascript/jquery-2.1.4.min.js"></script> | |
</head> | |
<body> | |
<h1>sieci</h1> | |
<form> | |
<input type="text" id="ip-address" value="Adres IP"> | |
<input type="text" id="address-mask" value="Adres podsieci"> | |
<input type="button" id="submit" value="Oblicz"> | |
</form> | |
<div id="results"> | |
<label for="result-ip-address">IP binarnie</label> | |
<input style="width:500px;" type="text" id="result-ip-address"> | |
</div> | |
<script> | |
$(document).ready( function(){ | |
function dec2bin(dec){ | |
console.log ("Zwracam " + (dec >>> 0).toString(2) + " z " + dec); | |
return (dec >>> 0).toString(2); | |
} | |
$("#submit").on('click', function(){ | |
var adres_ip = $("#ip-address").val(); | |
var address_splitted = adres_ip.split("."); | |
var result = $("#result-ip-address").html(); | |
for(x=0; x<address_splitted.length; x++) { | |
address_splitted[x] = parseInt(address_splitted[x]); | |
$("#result-ip-address").val($("#result-ip-address").val() + "." + dec2bin(address_splitted[x]) ); | |
} | |
$("#result-ip-address").val($("#result-ip-address").val().substr(1)); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment