Created
July 14, 2012 08:20
-
-
Save kopiro/3110029 to your computer and use it in GitHub Desktop.
Facebook speaks new online friends
This file contains hidden or 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
function in_array (needle, haystack) | |
{ | |
for (var key in haystack) | |
if (haystack[key] == needle) | |
return true; | |
return false; | |
} | |
var initOnline = AvailableList.getOnlineIDs(); | |
setInterval(function(){ | |
console.log(AvailableList.getOnlineIDs()); | |
if (AvailableList.getOnlineIDs().length!=initOnline.length) | |
{ | |
new AsyncRequest().setURI("/ajax/chat/user_info.php").setData({ids:AvailableList.getOnlineIDs()}).setHandler(function(uInfo) | |
{ | |
var i = 0; | |
for (var k in AvailableList.getOnlineIDs()) | |
{ | |
var id = AvailableList.getOnlineIDs()[k]; | |
if (!parseInt(id)) continue; | |
console.log(id, in_array(id, initOnline)); | |
if (!in_array(id, initOnline)) | |
{ | |
console.log("New!", id); | |
var name = uInfo.payload.profiles[id].name; | |
var msg = encodeURIComponent(name+' è online'); | |
setTimeout(function(){ new Audio("http://translate.google.com/translate_tts?tl=it&q="+msg).play(); }, 1500*(i++)); | |
} | |
} | |
initOnline = AvailableList.getOnlineIDs(); | |
}).send(); | |
} | |
}, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment