JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-md-12">
<textarea id="ranges" class="form-control" placeholder="Ranges List"></textarea>
<button class="btn btn-success">BUZ</button> <a href="https://4it.me/getlistip" class="pull-right" title="List of range ip for your city">Get IP Ranges for My city</a>
</div>
</div>
<div class="row">
<div class="col-md-12">
<textarea id="result" class="form-control" disabled="disabled" placeholder="IP List"></textarea> <a href="http://angryip.org/download/#windows" class="pull-right" title="List of range ip for your city">Angry IP Scanner</a>
</div>
</div>
JavaScript
var ip = {};
ip.toLong = function toInt(ip) {
var ipl = 0;
ip.split('.').forEach(function (octet) {
ipl <<= 8;
ipl += parseInt(octet);
});
return (ipl >>> 0);
};
ip.fromLong = function fromInt(ipl) {
return ((ipl >>> 24) + '.' + (ipl >> 16 & 255) + '.' + (ipl >> 8 & 255) + '.' + (ipl & 255));
};
ip.getList = function (start, end) {
var startIp = ip.toLong(start),
endIp = ip.toLong(end);
var temp, list = [],
str;
for (var i = startIp; i <= endIp; i++) {
temp = (i).toString(16);
str = '';
if (temp.length == 7) {
temp = "0" + temp;
}
for (var k = temp.length - 1; k >= 0; k -= 2) {
str = parseInt(temp[k - 1] + "" + temp[k], 16) + "." + str;
}
$('#result').append(str.substring(0, str.length - 1) + '\n');
list.push(str.substring(0, str.length - 1));
}
};
ip.getStartEnd = function (str) {
var startEnd = str.replace(/[\s,]+/g, '').split('-');
return startEnd;
}
$('.btn').on('click', function () {
console.log('BUZ');
var $ranges = $('#ranges').val().split(/\n/),
$result = $('#result');
$result.html();
$ranges.forEach(function (strRange) {
$result.prop('disabled', false);
//console.log(strRange);
var range = ip.getStartEnd(strRange);
//console.log(range);
ip.getList(range[0], range[1]);
});
});