Ind.ie is now Small Technology Foundation.
Commit eed1bcc9 authored by Aral Balkan's avatar Aral Balkan

All friends timeline now scrolls to show you the latest tweet that is received.

parent efbde781
......@@ -15,6 +15,42 @@ window.addEventListener('load', function(){
messageRepeater.parentNode.removeChild(messageRepeater);
}
//
// Listen for mutations on messages so that we can intelligently respond to them.
// e.g., scroll to show a message when one arrives.
//
var mutationObserver = new MutationObserver(function(mutations){
console.log("Mutations received:");
console.log(mutations);
mutations.forEach(function(mutation){
console.log("Mutation: " + mutation.type);
console.log("Mutation target: ");
console.log(mutation.target);
if(mutation.type == "childList") {
console.log("Added nodes:");
var addedNodes = mutation.addedNodes;
// Because, JavaScript, innit?
// Some working group somewhere thought, hey, why the fuck not?
var forEach = Array.prototype.forEach;
forEach.call(addedNodes, function(node){
console.log(node);
node.scrollIntoView();
});
}
});
});
// Currently, we only care when the child list changes.
var mutationObserverOptions = {childList: true};
mutationObserver.observe(messages, mutationObserverOptions);
//
// Poll every two seconds for new messages.
//
setInterval(function(){
// console.log("Polling server for new public posts…")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment