diff --git a/lib/ui/panel/index.html b/lib/ui/panel/index.html index 866a87f86..b9c0e694c 100644 --- a/lib/ui/panel/index.html +++ b/lib/ui/panel/index.html @@ -23,7 +23,8 @@ <%= script_tag 'ui/panel/DataGrid.js' %> <%= script_tag 'ui/panel/MainPanel.js' %> <%= script_tag 'ui/panel/ZombieTab.js' %> - <%= script_tag 'ui/panel/ZombiesPanel.js' %> + <%= script_tag 'ui/panel/ZombieTabs.js' %> + <%= script_tag 'ui/panel/zombiesTreeList.js' %> <%= script_tag 'ui/panel/ZombiesMgr.js' %> <%= script_tag 'ui/panel/AboutWindow.js' %> diff --git a/public/css/base.css b/public/css/base.css index 95d376f9d..db1310bf2 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -14,6 +14,17 @@ text-align:center; } +.feed-icon { + display: none; +} + +#zombie-tree-tabs-panel .x-tab-panel-header { + font: 11px tahoma,arial,helvetica,sans-serif; + padding: 0 0 0 0; + border-bottom: none; + text-align: center; +} + /* * Status bar ****************************************/ diff --git a/public/javascript/ui/panel/PanelViewer.js b/public/javascript/ui/panel/PanelViewer.js index b8793984e..57127c03d 100644 --- a/public/javascript/ui/panel/PanelViewer.js +++ b/public/javascript/ui/panel/PanelViewer.js @@ -1,11 +1,16 @@ PanelViewer = {}; -var mainPanel, zombiesPanel; +var mainPanel, zombiesTreeLists, zombieTabs; Ext.onReady(function() { Ext.QuickTips.init(); - zombiesPanel = new ZombiesPanel(); + zombiesTreeLists = { + 'basic' : new zombiesTreeList('basic'), + 'requester' : new zombiesTreeList('requester') + }; + + zombieTabs = new ZombieTabs(zombiesTreeLists); mainPanel = new MainPanel(); var viewport = new Ext.Viewport({ @@ -16,12 +21,12 @@ Ext.onReady(function() { el: 'header', height: 32 }), - zombiesPanel, + zombieTabs, mainPanel ] }); new DoLogout(); new AboutWindow(); - new ZombiesMgr(zombiesPanel); + new ZombiesMgr(zombiesTreeLists); }); \ No newline at end of file diff --git a/public/javascript/ui/panel/ZombiesMgr.js b/public/javascript/ui/panel/ZombiesMgr.js index 06b68226a..f2c9cd393 100644 --- a/public/javascript/ui/panel/ZombiesMgr.js +++ b/public/javascript/ui/panel/ZombiesMgr.js @@ -1,4 +1,4 @@ -var ZombiesMgr = function(zombies) { +var ZombiesMgr = function(zombies_tree_lists) { var selectedZombie = null; @@ -19,15 +19,16 @@ var ZombiesMgr = function(zombies) { // this is a helper class to create a zombie object from a JSON hash index var zombieFactory = function(index, zombie_array){ - text = zombie_array[index]["ip"] - text = " "+text + text = " "; + text += " "; + text += zombie_array[index]["ip"]; var new_zombie = { 'id' : index, 'ip' : zombie_array[index]["ip"], 'session' : zombie_array[index]["session"], 'text': text, - 'icon': '/ui/public/images/icons/'+escape(zombie_array[index]["browser_icon"]), + 'check' : false, 'domain' : zombie_array[index]["domain"] }; @@ -41,15 +42,27 @@ var ZombiesMgr = function(zombies) { success: function(response) { var offline_zombies = Ext.util.JSON.decode(response.responseText); - zombies.compareAndRemove(offline_zombies, false); - - for(var i in offline_zombies) { - - var zombie = zombieFactory(i, offline_zombies); - - zombies.addZombie(zombie, false); + for(tree_type in zombies_tree_lists) { + zombies = zombies_tree_lists[tree_type]; + zombies.compareAndRemove(offline_zombies, false); + } + + for(tree_type in zombies_tree_lists) { + zombies = zombies_tree_lists[tree_type]; + + for(var i in offline_zombies) { + var zombie = zombieFactory(i, offline_zombies); + + if(tree_type=='requester') { + //TODO logic for the requester starts here + zombie['checked'] = true; + } + + window.console.log(zombie['checked']); + zombies.addZombie(zombie, false); + } + } } - } }); Ext.Ajax.request({ @@ -58,20 +71,36 @@ var ZombiesMgr = function(zombies) { success: function(response){ var online_zombies = Ext.util.JSON.decode(response.responseText); - zombies.compareAndRemove(online_zombies, true); - for(var i in online_zombies) { + for(tree_type in zombies_tree_lists) { + zombies = zombies_tree_lists[tree_type]; + zombies.compareAndRemove(online_zombies, true); + } + for(tree_type in zombies_tree_lists) { + zombies = zombies_tree_lists[tree_type]; - var zombie = zombieFactory(i, online_zombies); - - zombies.addZombie(zombie, true); + for(var i in online_zombies) { + var zombie = zombieFactory(i, online_zombies); + + if(tree_type=='requester') { + //TODO logic for the requester starts here + zombie['checked'] = true; + } + + zombies.addZombie(zombie, true); + } } - if(zombies.online_zombies.childNodes.length > 0) { - zombies.online_zombies.expand(true); - } - - if(zombies.offline_zombies.childNodes.length > 0) { - zombies.offline_zombies.expand(true); + for(tree_type in zombies_tree_lists) { + + zombies = Ext.getCmp(zombies_tree_lists[tree_type].id); + + if(zombies.online_zombies.childNodes.length > 0) { + zombies.online_zombies.expand(true); + } + + if(zombies.offline_zombies.childNodes.length > 0) { + zombies.offline_zombies.expand(true); + } } } }); diff --git a/public/javascript/ui/panel/ZombiesPanel.js b/public/javascript/ui/panel/ZombiesPanel.js deleted file mode 100644 index 7382c1442..000000000 --- a/public/javascript/ui/panel/ZombiesPanel.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The zombie panel located on the left hand side of the interface. - */ -ZombiesPanel = function() { - - ZombiesPanel.superclass.constructor.call(this, { - id:'zombie-tree', - region:'west', - title:'Hooked Browsers', - split:true, - width: 225, - minSize: 175, - maxSize: 400, - collapsible: true, - margins:'0 0 5 5', - cmargins:'0 5 5 5', - rootVisible:false, - lines:false, - autoScroll:true, - root: new Ext.tree.TreeNode('My Zombies'), - collapseFirst:false - }); - - this.online_zombies = this.root.appendChild( - new Ext.tree.TreeNode({ - text:'Online Browsers', - cls:'online-zombies-node', - expanded:true - }) - ); - - this.offline_zombies = this.root.appendChild( - new Ext.tree.TreeNode({ - text:'Offline Browsers', - cls:'offline-zombies-node', - expanded:false - }) - ); - -}; - -/* - * The Tree panel that contains the zombie list. - */ -Ext.extend(ZombiesPanel, Ext.tree.TreePanel, { - - listeners: { - click: function(node, e) { - if(!node.leaf) return; - - if(!mainPanel.get(node.attributes.session)) { - mainPanel.add(new ZombieTab(node.attributes)); - } - - mainPanel.activate(node.attributes.session); - } - }, - - selectZombie: function(url){ - this.getNodeById(url).select(); - }, - - addZombie : function(attrs, online){ - if(online) { - var z_id = 'zombie-online-' + attrs.session; - } else { - var z_id = 'zombie-offline-' + attrs.session; - } - - var exists = this.getNodeById(z_id); - - if(exists){ - return; - } - - Ext.apply(attrs, { - iconCls: 'feed-icon', - leaf:true, - id: z_id - }); - - var node = new Ext.tree.TreeNode(attrs); - - if(online) { - Ext.apply(attrs, {cls: 'zombie-online'}); - this.online_zombies.appendChild(node); - } else { - Ext.apply(attrs, {cls: 'zombie-offline'}); - this.offline_zombies.appendChild(node); - } - - return node; - }, - - removeAll : function(){ - this.online_zombies.removeAll(); - this.offline_zombies.removeAll(); - }, - - compareAndRemove : function(zombies, online) { - for(var i in zombies) { - if(online) { - var z = 'zombie-offline-' + zombies[i].session;; - } else { - var z = 'zombie-online-' + zombies[i].session;; - } - - var exists = this.getNodeById(z); - - if(exists) { - if(!online) { - this.online_zombies.removeChild(exists); - } else { - this.offline_zombies.removeChild(exists); - } - } - } - } -}); \ No newline at end of file