Skip to content

Instantly share code, notes, and snippets.

View remibreton's full-sized avatar
🤖

Rémi Breton remibreton

🤖
  • Ubisoft
  • Montréal
View GitHub Profile
function getPosition(element){
for(var lx = 0, ly = 0; element != null; lx += element.offsetLeft, ly += element.offsetTop, element = element.offsetParent);
return {x: lx, y: ly};
}
'AF','AX','AL','DZ','AS','AD','AO','AI','AQ','AG','AR','AM','AW','AU','AT','AZ','BS','BH','BD','BB','BY','BE','BZ','BJ','BM','BT','BO','BA','BW','BV','BR','IO','BN','BG','BF','BI','KH','CM','CA','CV','KY','CF','TD','CL','CN','CX','CC','CO','KM','CG','CD','CK','CR','CI','HR','CU','CY','CZ','DK','DJ','DM','DO','EC','EG','SV','GQ','ER','EE','ET','FK','FO','FJ','FI','FR','GF','PF','TF','GA','GM','GE','DE','GH','GI','GR','GL','GD','GP','GU','GT','GG','GN','GW','GY','HT','HM','VA','HN','HK','HU','IS','IN','ID','IR','IQ','IE','IM','IL','IT','JM','JP','JE','JO','KZ','KE','KI','KR','KW','KG','LA','LV','LB','LS','LR','LY','LI','LT','LU','MO','MK','MG','MW','MY','MV','ML','MT','MH','MQ','MR','MU','YT','MX','FM','MD','MC','MN','ME','MS','MA','MZ','MM','NA','NR','NP','NL','AN','NC','NZ','NI','NE','NG','NU','NF','MP','NO','OM','PK','PW','PS','PA','PG','PY','PE','PH','PN','PL','PT','PR','QA','RE','RO','RU','RW','BL','SH','KN','LC','MF','PM','VC','WS','SM','ST','SA','SN','RS','SC','SL','SG','SK','SI','SB','SO','ZA','GS','ES'
// Change 15 to the password length
(function(e){var t="abcdefghijklmnopqrstuvwxz1234567890!@#$%?".split(""),n="";do{var r=t[Math.floor(Math.random()*t.length)];n+=Math.random()>.5?r.toUpperCase():r.toLowerCase()}while(n.length<e);return n})(15)
var get = function(url, callback, error, format){
if(!format) format = "json";
var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
if(typeof callback === "function") callback(format == "json" ? JSON.parse(xmlhttp.responseText) : xmlhttp.responseText);
} else {
if(typeof error === "function") error(format == "json" ? JSON.parse(xmlhttp.responseText) : xmlhttp.responseText);
$.getJSON('//country-finder.herokuapp.com/?callback=?', function (data) {
return data.geo.country.toLowerCase()
});