introduce mac generator
This commit is contained in:
@@ -215,3 +215,34 @@ function createimg(){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function genmac(field){
|
||||
freemacfound = "no";
|
||||
while (freemacfound == "no"){
|
||||
var text = "";
|
||||
var possible = "abcdef0123456789";
|
||||
for (j=0; j < 4; j++){
|
||||
text += ":";
|
||||
for (var i = 0; i < 2; i++)
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
var newmac = "52:54:00"+ text;
|
||||
freemacfound = checkmac(newmac, field);
|
||||
}
|
||||
}
|
||||
|
||||
function checkmac(newmac,field){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "?rand="+ makeid(),
|
||||
data: "checkmac="+ newmac,
|
||||
success: function(response){
|
||||
if (response == "mac is free"){
|
||||
$('#'+ field).val(newmac);
|
||||
return newmac;
|
||||
} else {
|
||||
return "no";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user