adding the new view for the requester

git-svn-id: https://beef.googlecode.com/svn/trunk@564 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
mosse.benjamin
2010-11-22 10:10:40 +00:00
parent 0c123b93c7
commit c9946b9e58
5 changed files with 74 additions and 147 deletions

View File

@@ -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' %>

View File

@@ -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
****************************************/

View File

@@ -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);
});

View File

@@ -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 = "<img src='/ui/public/images/icons/"+escape(zombie_array[index]["os_icon"])+"' style='padding-top:3px;' width='13px' height='13px'/> "+text
text = "<img src='/ui/public/images/icons/"+escape(zombie_array[index]["browser_icon"])+"' style='padding-top:3px;' width='13px' height='13px'/> ";
text += "<img src='/ui/public/images/icons/"+escape(zombie_array[index]["os_icon"])+"' style='padding-top:3px;' width='13px' height='13px'/> ";
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);
}
}
}
});

View File

@@ -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);
}
}
}
}
});