Last active
October 3, 2015 18:32
-
-
Save RyanHarijanto/d38522dbe04b5697132e to your computer and use it in GitHub Desktop.
BlockThem Javascript/jQuery (Browser) Example
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
var json = null; | |
$.ajax({ | |
'global': false, | |
'url': '//api.blockthem.io/v1/blacklist.json', | |
'dataType': "json", | |
'success': function (data) { | |
json = data; | |
} | |
}); | |
$("#your-text-input-box").keyup(function() { | |
checkDomain($("#your-text-input-box").val()); | |
}); | |
function checkDomain (domain) { | |
var domain = domain.replace(/\s/g, ''); | |
if (/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/.test(domain)){ | |
if (json.indexOf(domain) > -1) { | |
// Blocked | |
}else { | |
// Not Blocked | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment