Added list of attacks on click for sidenav

Semantical fixes

Code fixes, stricter checking
This commit is contained in:
Avijit Gupta 2016-01-05 22:28:26 +05:30 коммит произвёл Yash Mehrotra
Родитель 6bdecca457
Коммит 5da3f8bfe4
2 изменённых файлов: 41 добавлений и 41 удалений

Просмотреть файл

@ -25,7 +25,13 @@ Avijit Gupta 526avijit@gmail.com
<h3>Summary</h3>
<a><em>{{attackDetails.region}}</em></a>
<a>Rank <em># {{attackDetails.rank}}</em></a>
<a class="text-left attacks-list">List of attacks <span class="pull-right glyphicon glyphicon-arrow-right"></span></a>
<!-- <a class="text-left attacks-list" id="show-attacks-list">List of attacks <span class="pull-right glyphicon glyphicon-arrow-right"></span></a> -->
<ul class="text-center" id="attacks-list" style="list-style: none; color: white;">
{{#each attackDetails.attacks}}
<li class="text-center">{{name}}</li>
{{/each}}
</ul>
</nav>
</template>

Просмотреть файл

@ -52,6 +52,13 @@ if (Meteor.isClient) {
{x: -992, z: -962},
{x: -754, z: -1087}
];
var ATTACKANIMATIONS = {
'broxss': Examples.fireball,
'bro_notice': Examples.smoke,
'brosqli': Examples.candle,
'brotunnel': Examples.rain,
'brointel': Examples.clouds
};
var WIDTH = window.innerWidth;
var HEIGHT = window.innerHeight;
var SPEED = 0.01;
@ -185,20 +192,6 @@ if (Meteor.isClient) {
restartEngine(Examples.rain,200,-300);
else if(evt.keyCode === 50)
restartEngine(Examples.fountain);
else if(evt.keyCode === 51)
sphereMake(10,15,35);
else if(evt.keyCode === 52)
sphereMake(15,15,-30);
else if(evt.keyCode === 53)
sphereMake(-5,20,-65);
}
attack_animation_mapping = {
'broxss': Examples.fireball,
'bro_notice': Examples.smoke,
'brosqli': Examples.candle,
'brotunnel': Examples.rain,
'brointel': Examples.clouds
}
function parsedb() {
@ -206,29 +199,25 @@ if (Meteor.isClient) {
attackers.find().forEach(function(element) {
// TODO: Take care of timestamp
for(ev in element.events) {
var evt = element.events[ev];
if (world[evt.documentsource.details.host]) {
world[evt.documentsource.details.host].push(evt.documentsource);
element.events.forEach(function(evt) {
var evtHost = evt.documentsource.details.host;
if (world[evtHost]) {
world[evtHost].push(evt.documentsource);
} else {
world[evt.documentsource.details.host] = [evt.documentsource];
world[evt.documentsource.details.host].rank = attackedIds++;
world[evtHost] = [evt.documentsource];
world[evtHost].rank = attackedIds++;
}
}
});
});
var attacks = Object.keys(world).map(function(key) {
return [key, world[key].length];
}).sort(function(first, second) {
return second[1] - first[1];
}).map(function(arr){
return arr[0];
var attacks = Object.keys(world).sort(function(prev, current) {
return world[current].length - world[prev].length;
});
for (att in attacks) {
var attackRank = world[attacks[att]].rank;
attacks.forEach(function(host) {
var attackRank = world[host].rank;
// Create enclosing transparent sphere
var sphereGeometry = new THREE.SphereGeometry(80);
var sphereGeometry = new THREE.SphereGeometry(70);
var sphereMaterial = new THREE.MeshBasicMaterial({ transparent: true, opacity: 0 });
// var sphereMaterial = new THREE.MeshBasicMaterial();
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
@ -239,15 +228,16 @@ if (Meteor.isClient) {
sceneObjects.push(sphere);
scene.add(sphere);
var service = attacks[att];
for (i in world[service]) {
attack_type = world[service][i].category;
if (Object.keys(attack_animation_mapping).indexOf(attack_type) > -1) {
attack = attack_animation_mapping[attack_type];
restartEngine(attack, RANKCOORDINATES[att].x, RANKCOORDINATES[att].z);
world[host].forEach(function(attack, index) {
if (typeof attack === "object") {
attackType = attack.category;
if (Object.keys(ATTACKANIMATIONS).indexOf(attackType) > -1) {
mappedAttack = ATTACKANIMATIONS[attackType];
restartEngine(mappedAttack, RANKCOORDINATES[index].x, RANKCOORDINATES[index].z);
}
}
}
}
});
});
});
}
@ -264,7 +254,7 @@ if (Meteor.isClient) {
};//end template.attackers.rendered
Template.vr.attackDetails = function() {
return { region: 'MozWiki', rank: '1' }
return { region: 'MozWiki', rank: '1', attacks: [ {name: 'broxss'}, {name: 'brosqli'}] }
}
Template.vr.events({
@ -289,7 +279,7 @@ if (Meteor.isClient) {
intersects.forEach(function(intersect) {
// console.log(intersect);
if (intersect.object.rank) {
if (typeof intersect.object.rank !== "undefined") {
// Open the nav if not already opened
if (!sideNav.hasClass(OPENNAV)) {
sideNav.addClass(OPENNAV);
@ -299,6 +289,10 @@ if (Meteor.isClient) {
}
}
// "click #show-attacks-list": function() {
// }
});
Template.vr.destroyed = function () {