This commit is contained in:
Mavis Ou 2013-04-04 15:59:54 -07:00
Родитель df2c397bf0
Коммит 035d6c4c65
2 изменённых файлов: 63 добавлений и 57 удалений

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

@ -6,46 +6,30 @@ var triggerHelp = function(elem, eventname, data){
elem.dispatchEvent(evt);
};
var clearAllBubbles = function(){
var help = document.querySelector("#help");
var clone = help.cloneNode(false);
document.querySelector("body").removeChild(help); //can only remove one at a time
document.querySelector("body").appendChild(clone);
d3.selectAll(".highlighted-elm").classed("highlighted-elm", false);
document.querySelector(".help-mode").checked = false;
}
global.clearAllBubbles = clearAllBubbles;
global.triggerHelp = triggerHelp;
document.querySelector("body").addEventListener("toggleOnHelp", function(event){
var currVisualization = event.detail;
// currVisualization TO BE FIXED
if ( currVisualization == "clock" ){ //if ( randNode.querySelector(".tracker") ){ // clock
createBubble(
findTargetElement(document.querySelectorAll(".node")),
"node",
"each dot represents one third-party connection");
var timehand = document.querySelector("#timerhand");
createBubble(timehand, "timehand", "clock hand points to the current time");
}else if( currVisualization == "graph" ){ // graph
// select a random visited site, if any
if ( document.querySelectorAll(".visitedYes").length > 0 ){
createBubble(
findTargetElement(document.querySelectorAll(".visitedYes")),
"node",
"circles represent visited sites");
}
// select a random third-party site, if any
if ( document.querySelectorAll(".visitedNo").length > 0 ){
createBubble(
findTargetElement(document.querySelectorAll(".visitedNo")),
"node",
"triangles represent third party sites");
}
// select a random third-party site, if any
if ( document.querySelectorAll(".visitedBoth").length > 0 ){
createBubble(
findTargetElement(document.querySelectorAll(".visitedBoth")),
"node",
"rectangles represent sites are both visited and third party");
}
// select a random edge, if any
createBubble(
findTargetElement(document.querySelectorAll(".edge")),
"edge",
"each line represents a connection");
}else{}
//var currVisualization = event.detail;
if ( currentVisualization.name == "clock" ){
clockHelp();
}else if( currentVisualization.name == "graph" ){
graphHelp();
}else{
listHelp();
}
});
@ -84,21 +68,52 @@ function createBubble(target, type, message){
document.querySelector("body #help").appendChild(bubble);
}
var clearAllBubbles = function(){
var help = document.querySelector("#help");
var clone = help.cloneNode(false);
document.querySelector("body").removeChild(help); //can only remove one at a time
document.querySelector("body").appendChild(clone);
d3.selectAll(".highlighted-elm").classed("highlighted-elm", false);
document.querySelector(".help-mode").checked = false;
/* help mode for clock visualization */
function clockHelp(){
createBubble(
findTargetElement(document.querySelectorAll(".node")),
"node",
"each dot represents one third-party connection");
var timehand = document.querySelector("#timerhand");
createBubble(timehand, "timehand", "clock hand points to the current time");
}
global.clearAllBubbles = clearAllBubbles;
/* help mode for graph visualization */
function graphHelp(){
// select a random visited site, if any
if ( document.querySelectorAll(".visitedYes").length > 0 ){
createBubble(
findTargetElement(document.querySelectorAll(".visitedYes")),
"node",
"circles represent visited sites");
}
// select a random third-party site, if any
if ( document.querySelectorAll(".visitedNo").length > 0 ){
createBubble(
findTargetElement(document.querySelectorAll(".visitedNo")),
"node",
"triangles represent third party sites");
}
// select a random third-party site, if any
if ( document.querySelectorAll(".visitedBoth").length > 0 ){
createBubble(
findTargetElement(document.querySelectorAll(".visitedBoth")),
"node",
"rectangles represent sites are both visited and third party");
}
// select a random edge, if any
createBubble(
findTargetElement(document.querySelectorAll(".edge")),
"edge",
"each line represents a connection");
}
/* help mode for list visualization */
function listHelp(){
}
})(this);

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

@ -14,15 +14,6 @@ document.querySelector('#content').addEventListener('click', function(event){
}
},false);
//document.querySelector('.stage').addEventListener('click', function(event){
// console.log("list table clicked");
// if (event.target.mozMatchesSelector('.source-data')){
// console.log("hahahha");
// updateInfo(aggregate.nodeForKey(event.target.getAttribute('filter-url')));
// }
//},false);
// get server info from http://freegeoip.net
function getServerInfo(node, callback){
var info = parseUri(node.name); // uses Steven Levithan's parseUri 1.2.2