Skip to content

Instantly share code, notes, and snippets.

@RyanHarijanto
Last active October 3, 2015 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanHarijanto/d38522dbe04b5697132e to your computer and use it in GitHub Desktop.
Save RyanHarijanto/d38522dbe04b5697132e to your computer and use it in GitHub Desktop.
BlockThem Javascript/jQuery (Browser) Example
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