Files
beef/public/javascript/ui/panel/ZombiesMgr.js
wade@bindshell.net e8ea9008f2 http requests changed to POST
git-svn-id: https://beef.googlecode.com/svn/trunk@523 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
2010-11-14 16:37:36 +00:00

84 lines
2.0 KiB
JavaScript

var ZombiesMgr = function(zombies) {
var selectedZombie = null;
var addZombie = function(zombie){
selectedZombie = zombie;
}
var delZombie = function(zombie){
if (selectedZombie.session == zombie.session) {
selectedZombie = null;
}
return null;
}
var getZombie = function(){
return selectedZombie;
}
// 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
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"]),
'domain' : zombie_array[index]["domain"]
};
return new_zombie;
}
var updateZombies = function(){
Ext.Ajax.request({
url: '/ui/zombies/select/offline/simple.json',
method: 'POST',
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);
}
}
});
Ext.Ajax.request({
url: '/ui/zombies/select/online/simple.json',
method: 'POST',
success: function(response){
var online_zombies = Ext.util.JSON.decode(response.responseText);
zombies.compareAndRemove(online_zombies, true);
for(var i in online_zombies) {
var zombie = zombieFactory(i, online_zombies);
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);
}
}
});
}
Ext.TaskMgr.start({
run: updateZombies,
interval: 8000
});
}