Skip to content

Commit

Permalink
Changes for badge number
Browse files Browse the repository at this point in the history
  • Loading branch information
kuryaki committed Nov 11, 2012
1 parent 70e1e47 commit 9d48776
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
11 changes: 11 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ io.sockets.on('connection', function(socket){
socket.emit('update channels', channels);
});

socket.on('get tab users', function(info){
console.log(info);
if(info.status === 'loading'){
var urlObj = parser(info.url);
var channelUsers = io.sockets.manager.rooms[urlObj.host+urlObj.pathname];
channelUsers.tabId = info.tabId;
socket.emit('tab users', channelUsers);
console.log(channelUsers);
}
});

});

httpServer.listen(app.get('port'), function(){
Expand Down
Binary file modified codechat.zip
Binary file not shown.
17 changes: 9 additions & 8 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ var socket = io.connect('http://codechat.jit.su');

chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.getSelected(undefined, function(tab){
chrome.tabs.executeScript(null,{file:"socket.io.js"}); //cargo los js en el ambito de la pagina
chrome.tabs.executeScript(null,{file:"chatroom.js"});
chrome.tabs.executeScript(null,{file:'socket.io.js'}); //cargo los js en el ambito de la pagina
chrome.tabs.executeScript(null,{file:'chatroom.js'});
});
});

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
var x = parseInt(Math.random(100)*100);
x = ""+x;
chrome.browserAction.setBadgeText({text:x,tabId:tabId});
socket.emit("test service", changeInfo);
changeInfo.tabId = tabId;
socket.emit('get tab users', changeInfo);
});

var port = chrome.extension.connect();
socket.on('tab users', function(tabUsers){
console.log(tabUsers);
chrome.browserAction.setBadgeText({text:tabUsers.length,tabId:tabUsers.tabId});
});

console.log("this is running in background");
var port = chrome.extension.connect();
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Codechat",
"version": "2.2.8",
"version": "2.2.13",
"manifest_version": 9,
"description": "Chat over any web resource with other people in the same resource",
"browser_action": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ChatExtension",
"version": "0.0.1-20",
"version": "0.0.1-27",
"private": true,
"scripts": {
"start": "app.js"
Expand Down
2 changes: 1 addition & 1 deletion public/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ socket.on('update channels', function(channels){

for(var i=0 ; i<limit ; i++){
$('#top-sites')
.append('<li><a href=\"http://'+topSites[i].url+'\">('+topSites[i].users+') http:/'+topSites[i].url+'</a></li>');
.append('<li><a target=\”_blank\” href=\"http://'+topSites[i].url+'\">('+topSites[i].users+') http:/'+topSites[i].url+'</a></li>');
}

} else {
Expand Down

0 comments on commit 9d48776

Please sign in to comment.