Sha256: 766032b6da6c4a88dd134c38261eee41f122996f085c63b8c9ed1b07e96708e8

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

////////////////////
//Test functions
////////////////////

function log(msg) {
    //console.log(msg)
}


////////////////////
//Blink page title when focus lost on new messages
////////////////////

var chatFocus;

function onChatBlur() {
  chatFocus = false;
};

function onChatFocus(){
  stopBlink();
  titles = []; //Remove titles after StopBlink!
  chatFocus = true;
};

function initFocusListeners(){
  if (/*@cc_on!@*/false) { // check for Internet Explorer
    document.onfocusin = onFocus;
    document.onfocusout = onBlur;
  } else {
    window.onfocus = onChatFocus;
    window.onblur =  onChatBlur;
  }
}


var blinkTimer;
var titles=[];

function blinkTitle(titles,index){
  $(document).attr("title", titles[index]);
  index = (index+1)%titles.length
  blinkTimer=setTimeout(function(){blinkTitle(titles,index)}, 2000);
}

function stopBlink(){
  clearTimeout(blinkTimer);
  if (titles.length > 0) {
    $(document).attr("title", titles[0]);
  }
}

function blinkTitleOnMessage(username){
  if (!chatFocus){
    if (titles.length==0){
      titles.push($(document).attr("title"))
    }
    if (titles.indexOf(username) == -1){
      titles.push(username + " says...")
    }
    stopBlink();
    blinkTitle(titles,titles.length-1);
  }
}


////////////////////
//Next features...
////////////////////


Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
social_stream-0.12.12 presence/app/assets/javascripts/chat_utilities.js
social_stream-presence-0.1.0 app/assets/javascripts/chat_utilities.js
social_stream-0.12.11 presence/app/assets/javascripts/chat_utilities.js
social_stream-0.12.10 presence/app/assets/javascripts/chat_utilities.js
social_stream-0.12.9 presence/app/assets/javascripts/chat_utilities.js