Fix the least controversial jshint warnings

To install jshint, simply `npm install jshint` from the root
directory of the project. Then run like it like this:

    node_modules/.bin/jshint data/*.js
This commit is contained in:
Francois Marier 2014-04-25 11:48:33 +12:00
Родитель 088617d834
Коммит de3d0cfd54
19 изменённых файлов: 114 добавлений и 85 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -8,3 +8,4 @@ data/deployment.json
*.xpi *.xpi
exported_graphs exported_graphs
*.swp *.swp
/node_modules

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

@ -1,3 +1,4 @@
/* jshint moz: true */
// Graph Visualization // Graph Visualization
// Visualization of tracking data interconnections // Visualization of tracking data interconnections
@ -50,7 +51,7 @@ aggregate.getBlockedDomains = function () {
return Object.keys(userSettings).filter(function (domain) { return Object.keys(userSettings).filter(function (domain) {
return userSettings[domain] == 'block'; return userSettings[domain] == 'block';
}); });
} };
aggregate.getAllNodes = function () { aggregate.getAllNodes = function () {
var blockedDomains = aggregate.getBlockedDomains(); var blockedDomains = aggregate.getBlockedDomains();
@ -63,7 +64,7 @@ aggregate.getAllNodes = function () {
name: domain name: domain
}; };
})); }));
} };
aggregate.getConnectionCount = function (node) { aggregate.getConnectionCount = function (node) {
if (node.nodeType === 'blocked') if (node.nodeType === 'blocked')
@ -71,11 +72,11 @@ aggregate.getConnectionCount = function (node) {
let connections = Object.keys(aggregate.nodeForKey(node.name)).length; let connections = Object.keys(aggregate.nodeForKey(node.name)).length;
return connections - 1 > 0 ? connections - 1 : 0; return connections - 1 > 0 ? connections - 1 : 0;
} };
aggregate.nodeForKey = function (key) { aggregate.nodeForKey = function (key) {
var result = {}; var result = {};
var linkedNodes = new Array(); var linkedNodes = [];
if (aggregate.nodemap[key]) { if (aggregate.nodemap[key]) {
linkedNodes = aggregate.nodemap[key].linkedFrom.concat(aggregate.nodemap[key].linkedTo); linkedNodes = aggregate.nodemap[key].linkedFrom.concat(aggregate.nodemap[key].linkedTo);
@ -120,7 +121,7 @@ aggregate.connectionAsObject = function (conn) {
} }
return conn; return conn;
} };
// Pass the list of connections to build the graph structure to pass to d3 for // Pass the list of connections to build the graph structure to pass to d3 for
// visualizations. // visualizations.
@ -167,7 +168,7 @@ const CACHEABLE = 13;
// of false positives. // of false positives.
aggregate.isDomainVisited = function isDomainVisited(domain) { aggregate.isDomainVisited = function isDomainVisited(domain) {
return aggregate.recentSites.length && (aggregate.recentSites.indexOf(domain) > -1); return aggregate.recentSites.length && (aggregate.recentSites.indexOf(domain) > -1);
} };
function onConnection(conn) { function onConnection(conn) {
@ -236,7 +237,7 @@ function onConnection(conn) {
aggregate.trackerCount++; aggregate.trackerCount++;
} }
// console.log('new target: %s, now %s nodes', targetnode.name, aggregate.nodes.length); // console.log('new target: %s, now %s nodes', targetnode.name, aggregate.nodes.length);
updated = true updated = true;
} }
// Create edge objects. Could probably do this lazily just for the graph view // Create edge objects. Could probably do this lazily just for the graph view
if (aggregate.edgemap[connection.source + '->' + connection.target]) { if (aggregate.edgemap[connection.source + '->' + connection.target]) {
@ -291,13 +292,13 @@ function GraphEdge(source, target, connection) {
} }
GraphEdge.prototype.lastAccess = function () { GraphEdge.prototype.lastAccess = function () {
return (this.source.lastAccess > this.target.lastAccess) ? this.source.lastAccess : this.target.lastAccess; return (this.source.lastAccess > this.target.lastAccess) ? this.source.lastAccess : this.target.lastAccess;
} };
GraphEdge.prototype.firstAccess = function () { GraphEdge.prototype.firstAccess = function () {
return (this.source.firstAccess < this.target.firstAccess) ? this.source.firstAccess : this.target.firstAccess; return (this.source.firstAccess < this.target.firstAccess) ? this.source.firstAccess : this.target.firstAccess;
} };
GraphEdge.prototype.update = function (connection) { GraphEdge.prototype.update = function (connection) {
this.cookieCount = connection.cookie ? this.cookieCount + 1 : this.cookieCount; this.cookieCount = connection.cookie ? this.cookieCount + 1 : this.cookieCount;
} };
// A graph node represents one end of a connection, either a target or a source // A graph node represents one end of a connection, either a target or a source
// Where a connection is a point in time with a timestamp, a graph node has a time range // Where a connection is a point in time with a timestamp, a graph node has a time range

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

@ -1,3 +1,4 @@
/* jshint moz: true */
/* Dialog / Popup ===================================== */ /* Dialog / Popup ===================================== */
// dialog names (used as dialog identifiers) // dialog names (used as dialog identifiers)
@ -118,7 +119,7 @@ function addDialogEventHandlers(modal, options, callback) {
modal.close(); modal.close();
callback(false); callback(false);
} }
} };
document.addEventListener("keydown", keyDownHandler); document.addEventListener("keydown", keyDownHandler);
modal.onClose(function () { modal.onClose(function () {

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

@ -1,3 +1,4 @@
/* jshint moz: true */
// Graph Visualization (one of 3 views: graph, clock, and list). This is way // Graph Visualization (one of 3 views: graph, clock, and list). This is way
// too heavyweight for mobile right now. // too heavyweight for mobile right now.
@ -70,7 +71,7 @@ function onInit() {
vizcanvas.setAttribute('viewBox', [0, 0, width, height].join(' ')); vizcanvas.setAttribute('viewBox', [0, 0, width, height].join(' '));
// console.log('graph::onInit end'); // console.log('graph::onInit end');
document.querySelector(".filter-display").classList.remove("hidden"); document.querySelector(".filter-display").classList.remove("hidden");
}; }
function onRemove() { function onRemove() {
// var startTime = Date.now(); // var startTime = Date.now();
@ -81,7 +82,7 @@ function onRemove() {
resetCanvas(); resetCanvas();
document.querySelector(".filter-display").classList.add("hidden"); document.querySelector(".filter-display").classList.add("hidden");
// console.log('it took %s ms to remove graph view', Date.now() - startTime); // console.log('it took %s ms to remove graph view', Date.now() - startTime);
}; }
function onReset() { function onReset() {
onRemove(); onRemove();
@ -161,23 +162,24 @@ function charge(d) {
} }
function colourHighlightNodes(highlight) { function colourHighlightNodes(highlight) {
var i;
var watchedSites = document.querySelectorAll(".watched"); var watchedSites = document.querySelectorAll(".watched");
var blockedSites = document.querySelectorAll(".blocked"); var blockedSites = document.querySelectorAll(".blocked");
if (highlight.watched) { if (highlight.watched) {
for (var i = 0; i < watchedSites.length; i++) { for (i = 0; i < watchedSites.length; i++) {
watchedSites[i].classList.add("watchedSites"); watchedSites[i].classList.add("watchedSites");
} }
} else { } else {
for (var i = 0; i < watchedSites.length; i++) { for (i = 0; i < watchedSites.length; i++) {
watchedSites[i].classList.remove("watchedSites"); watchedSites[i].classList.remove("watchedSites");
} }
} }
if (highlight.blocked) { if (highlight.blocked) {
for (var i = 0; i < blockedSites.length; i++) { for (i = 0; i < blockedSites.length; i++) {
blockedSites[i].classList.add("blockedSites"); blockedSites[i].classList.add("blockedSites");
} }
} else { } else {
for (var i = 0; i < blockedSites.length; i++) { for (i = 0; i < blockedSites.length; i++) {
blockedSites[i].classList.remove("blockedSites"); blockedSites[i].classList.remove("blockedSites");
} }
} }
@ -243,7 +245,7 @@ function initGraph() {
}); });
nodes.each(function (d, i) { nodes.each(function (d, i) {
// `this` is the DOM node // `this` is the DOM node
this.setAttribute('transform', 'translate(' + d.x + ',' + d.y + ') scale(' + (1 + .05 * d.weight) + ')'); this.setAttribute('transform', 'translate(' + d.x + ',' + d.y + ') scale(' + (1 + 0.05 * d.weight) + ')');
this.setAttribute('data-timestamp', d.lastAccess.toISOString()); this.setAttribute('data-timestamp', d.lastAccess.toISOString());
if (d.nodeType === 'site' || d.nodeType === 'both') { if (d.nodeType === 'site' || d.nodeType === 'both') {
this.classList.add('visitedYes'); this.classList.add('visitedYes');
@ -317,7 +319,7 @@ function addCircle(selection) {
.append('circle') .append('circle')
.attr('cx', 0) .attr('cx', 0)
.attr('cy', 0) .attr('cy', 0)
.attr('r', graphNodeRadius["graph"]) .attr('r', graphNodeRadius.graph)
.classed('site', true); .classed('site', true);
} }

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

@ -48,7 +48,7 @@ global.initMap = function initMap(mapcanvas, mapDocument) {
if (currentRequest === info.host) { if (currentRequest === info.host) {
callback((request.status === 200) ? JSON.parse(request.responseText) : false); callback((request.status === 200) ? JSON.parse(request.responseText) : false);
} }
} };
request.send(null); request.send(null);
} }
@ -271,7 +271,7 @@ global.initMap = function initMap(mapcanvas, mapDocument) {
}, false); }, false);
} };
/* Info Panel Tabs ======================================== */ /* Info Panel Tabs ======================================== */

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

@ -1,3 +1,4 @@
/* jshint moz: true */
(function (global) { (function (global) {
'use strict'; 'use strict';
@ -66,7 +67,7 @@ global.elem = function elem(name, attributes, children) {
} }
}); });
} }
} catch (e) { } catch (err) {
console.log('attributes: not what we think they are: %o', attributes); console.log('attributes: not what we think they are: %o', attributes);
} }
if (children) { if (children) {
@ -113,7 +114,7 @@ global.switchVisualization = function switchVisualization(name) {
defaultVisualization: name defaultVisualization: name
}); });
// console.log('it took %s ms to switch visualizations', Date.now() - startTime); // console.log('it took %s ms to switch visualizations', Date.now() - startTime);
} };
function resetAdditionalUI() { function resetAdditionalUI() {
// toggle off info panel // toggle off info panel
@ -150,7 +151,7 @@ global.startSharing = function startSharing(askForConfirmation, callback) {
} else { } else {
callback(true); callback(true);
} }
} };
/**************************************** /****************************************
* Format date string * Format date string
@ -164,7 +165,7 @@ global.formattedDate = function formattedDate(date, format) {
formatted = dayInWeek + ", " + formatted + " " + ((d.getHours() == 12) ? 12 : (d.getHours() % 12)) + ':' + d.toLocaleFormat('%M') + ['AM', 'PM'][Math.floor(d.getHours() / 12)]; formatted = dayInWeek + ", " + formatted + " " + ((d.getHours() == 12) ? 12 : (d.getHours() % 12)) + ':' + d.toLocaleFormat('%M') + ['AM', 'PM'][Math.floor(d.getHours() / 12)];
} }
return formatted; return formatted;
} };
global.singularOrPluralNoun = function singularOrPluralNoun(num, str) { global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
@ -172,7 +173,7 @@ global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
num = parseFloat(num); num = parseFloat(num);
} }
return (num !== 1) ? str + "s" : str; return (num !== 1) ? str + "s" : str;
} };
/**************************************** /****************************************
* update Stats Bar * update Stats Bar
@ -185,6 +186,6 @@ global.updateStatsBar = function updateStatsBar() {
document.querySelector(".top-bar .date-gathered").textContent = dateSince; document.querySelector(".top-bar .date-gathered").textContent = dateSince;
document.querySelector(".top-bar .third-party-sites").textContent = aggregate.trackerCount + " " + singularOrPluralNoun(aggregate.trackerCount, "THIRD PARTY SITE"); document.querySelector(".top-bar .third-party-sites").textContent = aggregate.trackerCount + " " + singularOrPluralNoun(aggregate.trackerCount, "THIRD PARTY SITE");
document.querySelector(".top-bar .first-party-sites").textContent = aggregate.siteCount + " " + singularOrPluralNoun(aggregate.siteCount, "SITE"); document.querySelector(".top-bar .first-party-sites").textContent = aggregate.siteCount + " " + singularOrPluralNoun(aggregate.siteCount, "SITE");
} };
})(this); })(this);

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

@ -1,10 +1,10 @@
'use strict'; /* jshint moz: true */
// List Visualization // List Visualization
// Display data in tabular format // Display data in tabular format
(function (visualizations, global) { (function (visualizations, global) {
"use strict";
var list = new Emitter(); var list = new Emitter();
var breadcrumbStack = []; var breadcrumbStack = [];
@ -482,7 +482,7 @@ function sortTableOnColumn(table, n) {
tbody.appendChild(preFrag); tbody.appendChild(preFrag);
tbody.appendChild(frag); tbody.appendChild(frag);
} };
} }
function resetCanvas() { function resetCanvas() {
@ -511,7 +511,7 @@ function getSelectedRows() {
// returns selected rows as an Array // returns selected rows as an Array
return getAllRows().filter(function (item) { return getAllRows().filter(function (item) {
return item.querySelector('.selected-row:checked'); return item.querySelector('.selected-row:checked');
}) });
} }
// Event handlers // Event handlers
@ -539,16 +539,17 @@ function setUserSetting(row, pref) {
// selectAllRows should only select VISIBLE rows // selectAllRows should only select VISIBLE rows
function selectAllRows(flag) { function selectAllRows(flag) {
var i;
// apply flag to ALL rows first // apply flag to ALL rows first
var rows = document.querySelectorAll(".body-table tr"); var rows = document.querySelectorAll(".body-table tr");
for (var i = 0; i < rows.length; i++) { for (i = 0; i < rows.length; i++) {
rows[i].querySelector(".selected-row").checked = flag; rows[i].querySelector(".selected-row").checked = flag;
highlightRow(rows[i], flag); highlightRow(rows[i], flag);
} }
// and then exclude all the hidden rows // and then exclude all the hidden rows
if (document.querySelector(".hide-hidden-rows")) { if (document.querySelector(".hide-hidden-rows")) {
var hiddenRows = document.querySelectorAll(".list-table .body-table tr[data-pref=hide]"); var hiddenRows = document.querySelectorAll(".list-table .body-table tr[data-pref=hide]");
for (var i = 0; i < hiddenRows.length; i++) { for (i = 0; i < hiddenRows.length; i++) {
hiddenRows[i].querySelector(".selected-row").checked = false; // makes sure the hidden rows are always unchecked hiddenRows[i].querySelector(".selected-row").checked = false; // makes sure the hidden rows are always unchecked
highlightRow(hiddenRows[i], false); highlightRow(hiddenRows[i], false);
} }
@ -645,7 +646,7 @@ function initializeHandlers() {
}); });
showFilteredTable(lastFilter); showFilteredTable(lastFilter);
selected = getAllRows().filter(function (row) { selected = getAllRows().filter(function (row) {
return wereSelected.indexOf(row.dataset.name) > -1 return wereSelected.indexOf(row.dataset.name) > -1;
}) })
.map(function (rowToSelect) { .map(function (rowToSelect) {
rowToSelect.querySelector("[type=checkbox]").checked = true; rowToSelect.querySelector("[type=checkbox]").checked = true;

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

@ -16,7 +16,7 @@ function parseUri(str) {
}); });
return uri; return uri;
}; }
parseUri.options = { parseUri.options = {
strictMode: false, strictMode: false,

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

@ -20,7 +20,7 @@ function svgdataset(elem) {
// act as getter // act as getter
value = elem.getAttribute(dataKeyToAttr(key)); value = elem.getAttribute(dataKeyToAttr(key));
try { try {
get get;
return JSON.parse(value); return JSON.parse(value);
} catch (e) { } catch (e) {
return value; return value;

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

@ -1,3 +1,4 @@
/* jshint moz: true */
(function (global) { (function (global) {
// Bunch of utilities related to UI elements. // Bunch of utilities related to UI elements.
const graphNodeRadius = { const graphNodeRadius = {
@ -10,7 +11,7 @@ global.graphNodeRadius = graphNodeRadius;
/* Convert a NodeList to Array */ /* Convert a NodeList to Array */
global.toArray = function toArray(nl) { global.toArray = function toArray(nl) {
return Array.prototype.slice.call(nl, 0); return Array.prototype.slice.call(nl, 0);
} };
/************************************************** /**************************************************
* For accessibility: * For accessibility:
@ -94,7 +95,7 @@ global.confirmStartSharing = function confirmStartSharing(askForConfirmation, el
elmClicked.checked = false; elmClicked.checked = false;
} }
}); });
} };
global.confirmStopSharing = function confirmStopSharing(elmClicked) { global.confirmStopSharing = function confirmStopSharing(elmClicked) {
stopSharingDialog(function (confirmed) { stopSharingDialog(function (confirmed) {
@ -107,7 +108,7 @@ global.confirmStopSharing = function confirmStopSharing(elmClicked) {
elmClicked.checked = true; elmClicked.checked = true;
} }
}); });
} };
function toggleBtnOnEffect(toggleBtn) { function toggleBtnOnEffect(toggleBtn) {
toggleBtn.querySelector(".toggle-btn-innner").classList.add("checked"); toggleBtn.querySelector(".toggle-btn-innner").classList.add("checked");
@ -135,7 +136,7 @@ function downloadAsJson(data, defaultFilename) {
a.target = '_blank'; a.target = '_blank';
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
} };
reader.readAsDataURL(file); reader.readAsDataURL(file);
} }
@ -184,12 +185,12 @@ global.getZoom = function getZoom(canvas) {
console.log('Caller: %o', caller); console.log('Caller: %o', caller);
return null; return null;
} }
} };
global.setZoom = function setZoom(box, canvas) { global.setZoom = function setZoom(box, canvas) {
// TODO: code cleanup if both cases use basically the same code // TODO: code cleanup if both cases use basically the same code
canvas.setAttribute('viewBox', [box.x, box.y, box.w, box.h].join(' ')); canvas.setAttribute('viewBox', [box.x, box.y, box.w, box.h].join(' '));
} };
/* Scroll over visualization to zoom in/out ========================= */ /* Scroll over visualization to zoom in/out ========================= */
@ -244,15 +245,16 @@ function checkWithinZoomLimit(targetSvg, zoomType, zoomLimit) {
// Check to see if the viewBox of the targeting svg is within the limit we define // Check to see if the viewBox of the targeting svg is within the limit we define
// if yes, zoom // if yes, zoom
function zoomWithinLimit(scrollDist, targetSvg, zoomInLimit, zoomOutLimit) { function zoomWithinLimit(scrollDist, targetSvg, zoomInLimit, zoomOutLimit) {
var i;
if (scrollDist >= 1) { // scroll up to zoom out if (scrollDist >= 1) { // scroll up to zoom out
for (var i = 1; i <= scrollDist; i++) { for (i = 1; i <= scrollDist; i++) {
if (checkWithinZoomLimit(targetSvg, "out", zoomOutLimit)) { if (checkWithinZoomLimit(targetSvg, "out", zoomOutLimit)) {
svgZooming(targetSvg, (1 / svgZoomingRatio)); svgZooming(targetSvg, (1 / svgZoomingRatio));
} }
} }
} }
if (scrollDist <= -1) { // scroll down to zoom in if (scrollDist <= -1) { // scroll down to zoom in
for (var i = scrollDist; i <= -1; i++) { for (i = scrollDist; i <= -1; i++) {
if (checkWithinZoomLimit(targetSvg, "in", zoomInLimit)) { if (checkWithinZoomLimit(targetSvg, "in", zoomInLimit)) {
svgZooming(targetSvg, svgZoomingRatio); svgZooming(targetSvg, svgZoomingRatio);
} }
@ -341,13 +343,13 @@ global.toggleLegendSection = function toggleLegendSection(eventTarget, legendElm
elmToToggle.classList.add("hidden"); elmToToggle.classList.add("hidden");
eventTarget.textContent = "Show"; eventTarget.textContent = "Show";
} }
} };
global.toggleVizElements = function toggleVizElements(elements, classToggle) { global.toggleVizElements = function toggleVizElements(elements, classToggle) {
toArray(elements).forEach(function (elm) { toArray(elements).forEach(function (elm) {
elm.classList.toggle(classToggle); elm.classList.toggle(classToggle);
}); });
} };
@ -361,7 +363,7 @@ global.selectedNodeEffect = function selectedNodeEffect(name) {
if (g.currentVisualization.name == "list") { if (g.currentVisualization.name == "list") {
resetHighlightedRow(); resetHighlightedRow();
} }
} };
global.connectedNodeEffect = function connectedNodeEffect(name) { global.connectedNodeEffect = function connectedNodeEffect(name) {
// console.log(name); // console.log(name);
@ -380,7 +382,7 @@ global.connectedNodeEffect = function connectedNodeEffect(name) {
} }
} }
} };
// for Graph & Clock // for Graph & Clock
global.addGlow = function addGlow(name, type) { global.addGlow = function addGlow(name, type) {
@ -398,7 +400,7 @@ global.addGlow = function addGlow(name, type) {
.classed(type, true); .classed(type, true);
}); });
} };
global.calculateGlowSize = function calculateGlowSize(gNode, viz) { global.calculateGlowSize = function calculateGlowSize(gNode, viz) {
var glowProps = {}; var glowProps = {};
@ -416,7 +418,7 @@ global.calculateGlowSize = function calculateGlowSize(gNode, viz) {
glowProps.cy = siteNode.getAttribute("cy") || 0; glowProps.cy = siteNode.getAttribute("cy") || 0;
return glowProps; return glowProps;
} };
// for Graph // for Graph
global.resetAllGlow = function resetAllGlow(type) { global.resetAllGlow = function resetAllGlow(type) {
@ -434,7 +436,7 @@ global.resetAllGlow = function resetAllGlow(type) {
connectedGlow.parentNode.removeChild(connectedGlow); connectedGlow.parentNode.removeChild(connectedGlow);
} }
} }
} };
// for List // for List
global.resetHighlightedRow = function resetHighlightedRow() { global.resetHighlightedRow = function resetHighlightedRow() {
@ -442,7 +444,7 @@ global.resetHighlightedRow = function resetHighlightedRow() {
if (preHighlighted) { if (preHighlighted) {
preHighlighted.classList.remove("selected-connected-row"); preHighlighted.classList.remove("selected-connected-row");
} }
} };
/************************************************** /**************************************************
* Singular / Plural Noun * Singular / Plural Noun
@ -452,12 +454,12 @@ global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
num = parseFloat(num); num = parseFloat(num);
} }
return (num > 1) ? str + "s" : str; return (num > 1) ? str + "s" : str;
} };
function updateUIFromPrefs(event) { function updateUIFromPrefs(event) {
if ("contributeData" in event && event["contributeData"]) { if ("contributeData" in event && event.contributeData) {
var toggleBtn = document.querySelector(".share-btn"); var toggleBtn = document.querySelector(".share-btn");
if (event["contributeData"]) { if (event.contributeData) {
toggleBtn.querySelector("input").checked = true; toggleBtn.querySelector("input").checked = true;
toggleBtnOnEffect(toggleBtn); toggleBtnOnEffect(toggleBtn);
} else { } else {
@ -466,7 +468,7 @@ function updateUIFromPrefs(event) {
} }
} }
if ("defaultVisualization" in event) { if ("defaultVisualization" in event) {
global.currentVisualization = visualizations[event["defaultVisualization"]]; global.currentVisualization = visualizations[event.defaultVisualization];
if (global.currentVisualization) { if (global.currentVisualization) {
console.log("Got viz"); console.log("Got viz");
} else { } else {
@ -475,7 +477,7 @@ function updateUIFromPrefs(event) {
} }
if ("defaultFilter" in event) { if ("defaultFilter" in event) {
aggregate.currentFilter = event["defaultFilter"]; aggregate.currentFilter = event.defaultFilter;
document.querySelector('a[data-value=' + aggregate.currentFilter + ']') document.querySelector('a[data-value=' + aggregate.currentFilter + ']')
.dataset.selected = true; .dataset.selected = true;
document.querySelector(".filter-display header").textContent = document.querySelector(".filter-display header").textContent =

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

@ -1,3 +1,4 @@
/* jshint moz: true */
// Connection object. This module may try to do too many things. // Connection object. This module may try to do too many things.
// //
// Convert an HTTP request (channel) to a loggable, visualizable connection // Convert an HTTP request (channel) to a loggable, visualizable connection
@ -45,7 +46,7 @@ exports.getAllConnections = function getAllConnections() {
console.log("got", connBatch.length, "buffered connections", console.log("got", connBatch.length, "buffered connections",
ss.storage.connections.length, "persisted connections"); ss.storage.connections.length, "persisted connections");
return ss.storage.connections.concat(connBatch); return ss.storage.connections.concat(connBatch);
} };
function excludePrivateConnections(connections) { function excludePrivateConnections(connections) {
return connections.filter(function (connection) { return connections.filter(function (connection) {
@ -80,7 +81,7 @@ function getDomain(host) {
Connection.getDomain = getDomain; // make it part of what we export Connection.getDomain = getDomain; // make it part of what we export
Connection.reset = function () { Connection.reset = function () {
connBatch.length = 0; connBatch.length = 0;
} };
// Get subdomain (e.g., foo from foo.example.com) // Get subdomain (e.g., foo from foo.example.com)
function getSubdomain(host) { function getSubdomain(host) {
@ -88,14 +89,14 @@ function getSubdomain(host) {
return host.slice(0, host.length - domain.length); return host.slice(0, host.length - domain.length);
} }
function Connection() {}; function Connection() {}
// subject comes from events.on("http-on-modify-request"); // subject comes from events.on("http-on-modify-request");
Connection.fromSubject = function (subject) { Connection.fromSubject = function (subject) {
var conn = new Connection(); var conn = new Connection();
conn.restoreFromSubject(subject); conn.restoreFromSubject(subject);
return conn; return conn;
} };
// Functions below may include legacy code from the first version of Collusion. // Functions below may include legacy code from the first version of Collusion.
// Find the page the URL was originally loaded from to determine whether this // Find the page the URL was originally loaded from to determine whether this
@ -142,8 +143,9 @@ Connection.prototype.restoreFromSubject = function (event) {
var source = channel.referrer; var source = channel.referrer;
var target = channel.URI; var target = channel.URI;
var targetDomain = getDomain(target.host); var targetDomain = getDomain(target.host);
var tab = null;
try { try {
var tab = getTabForChannel(channel); tab = getTabForChannel(channel);
} catch (e) { } catch (e) {
console.log('EXCEPTION CAUGHT: No tab for connection'); console.log('EXCEPTION CAUGHT: No tab for connection');
tab = null; tab = null;
@ -154,7 +156,7 @@ Connection.prototype.restoreFromSubject = function (event) {
var browserSpec = browserUri && browserUri.spec; var browserSpec = browserUri && browserUri.spec;
var browserDomain = null; var browserDomain = null;
try { try {
var browserDomain = browserUri && getDomain(browserUri.host); browserDomain = browserUri && getDomain(browserUri.host);
} catch (e) { } catch (e) {
// chances are the URL is about:blank, which has no host and throws an exception // chances are the URL is about:blank, which has no host and throws an exception
// console.error('Error getting host from: ' + browserUri.spec); // console.error('Error getting host from: ' + browserUri.spec);
@ -236,7 +238,7 @@ Connection.prototype.restoreFromSubject = function (event) {
this.isPrivate = isPrivate; this.isPrivate = isPrivate;
this._sourceTab = tab; // Never logged, only for associating data with current tab this._sourceTab = tab; // Never logged, only for associating data with current tab
// console.error((sourceVisited ? 'site: ' : 'tracker: ') + sourceDomain + ' -> ' + targetDomain + ' (' + browserUri.spec + ')'); // console.error((sourceVisited ? 'site: ' : 'tracker: ') + sourceDomain + ' -> ' + targetDomain + ' (' + browserUri.spec + ')');
} };
// Connection - level methods (not on instances) // Connection - level methods (not on instances)
// This may be supported by the addon-sdk events.on now. // This may be supported by the addon-sdk events.on now.

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

@ -1,3 +1,5 @@
/* jshint moz: true */
/* global exports, require */
"use strict"; "use strict";
const events = require("sdk/system/events"); const events = require("sdk/system/events");
@ -66,4 +68,4 @@ exports.main = function (options, callbacks) {
return; return;
} }
tabs.open(data.url(loadURL)); tabs.open(data.url(loadURL));
} };

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

@ -1,3 +1,5 @@
/* jshint moz: true */
/* global console, require, exports */
// All writes to storage and upload logic in the addon process goes here. // All writes to storage and upload logic in the addon process goes here.
"use strict"; "use strict";
@ -11,7 +13,7 @@ var storage = ss.storage;
const STORAGE_KEYS = [ const STORAGE_KEYS = [
"blockmap", "blockmap",
"connections", "connections",
] ];
// Upload logic. // Upload logic.
function serializeConnections(connections) { function serializeConnections(connections) {
@ -20,7 +22,7 @@ function serializeConnections(connections) {
version: '1.1', version: '1.1',
uploadTime: Date.now(), uploadTime: Date.now(),
connections: connections connections: connections
} };
return JSON.stringify(exportSet); return JSON.stringify(exportSet);
} }
@ -63,7 +65,7 @@ exports.storeConnections = function storeConnections(connections) {
if (prefs.contributeData) { if (prefs.contributeData) {
upload(connections); upload(connections);
} }
} };
// Reset stored state, including preferences // Reset stored state, including preferences
exports.reset = function reset() { exports.reset = function reset() {
@ -72,7 +74,7 @@ exports.reset = function reset() {
prefs.contributeData = false; prefs.contributeData = false;
prefs.defaultVisualization = "graph"; prefs.defaultVisualization = "graph";
prefs.defaultFilter = "daily"; prefs.defaultFilter = "daily";
} };
// Initialize all of our storage // Initialize all of our storage
if (!storage.connections) { if (!storage.connections) {

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

@ -1,3 +1,5 @@
/* jshint moz: true */
/* global require, exports */
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -142,7 +144,9 @@ function addMenuitems(self, options) {
// add unloader // add unloader
let unloader = function unloader() { let unloader = function unloader() {
menuitem.parentNode && menuitem.parentNode.removeChild(menuitem); if (menuitem.parentNode) {
menuitem.parentNode.removeChild(menuitem);
}
menuitems[menuitems_i] = null; menuitems[menuitems_i] = null;
}; };
menuitemNS(self).unloaders.push(function () { menuitemNS(self).unloaders.push(function () {
@ -218,17 +222,17 @@ function tryParent(parent, menuitem, before) {
return !!parent; return !!parent;
} }
function insertBefore(parent, insertBefore) { function insertBefore(parent, before) {
if (typeof insertBefore == "number") { if (typeof before == "number") {
switch (insertBefore) { switch (before) {
case MenuitemExport.FIRST_CHILD: case MenuitemExport.FIRST_CHILD:
return parent.firstChild; return parent.firstChild;
} }
return null; return null;
} else if (typeof insertBefore == "string") { } else if (typeof before == "string") {
return parent.querySelector("#" + insertBefore); return parent.querySelector("#" + before);
} }
return insertBefore; return before;
} }
function MenuitemExport(options) { function MenuitemExport(options) {

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

@ -1,3 +1,5 @@
/* jshint moz: true */
/* global require, exports */
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

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

@ -1,3 +1,5 @@
/* jshint moz:true */
/* global require, console, exports */
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -38,7 +40,7 @@ var Unloader = exports.Unloader = Class({
callback = function () { callback = function () {
container.removeEventListener("unload", windowRemover, false); container.removeEventListener("unload", windowRemover, false);
origCallback(); origCallback();
} };
} }
// Wrap the callback in a function that ignores failures // Wrap the callback in a function that ignores failures

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

@ -1,3 +1,5 @@
/* jshint moz: true */
/* global require, exports */
// Simple onTab handler to figure out what tab a connection corresponds to. // Simple onTab handler to figure out what tab a connection corresponds to.
'use strict'; 'use strict';

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

@ -1,3 +1,4 @@
/* jshint moz: true */
// ChromeTab // ChromeTab
// //
// This is a module for getting the tab a channel is loaded in, from the channel // This is a module for getting the tab a channel is loaded in, from the channel
@ -84,14 +85,14 @@ function getLoadContext(aRequest) {
var loadContext = aRequest.QueryInterface(Ci.nsIChannel) var loadContext = aRequest.QueryInterface(Ci.nsIChannel)
.notificationCallbacks.getInterface(Ci.nsILoadContext); .notificationCallbacks.getInterface(Ci.nsILoadContext);
return loadContext; return loadContext;
} catch (ex) { } catch (err1) {
// fail over to trying the load group // fail over to trying the load group
try { try {
if (!aRequest.loadGroup) return null; if (!aRequest.loadGroup) return null;
var loadContext = aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext); var loadContext = aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
return loadContext; return loadContext;
} catch (ex) { } catch (err2) {
return null; return null;
} }
} }

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

@ -1,3 +1,5 @@
/* jshint moz:true */
/* global require, exports, console */
'use strict'; 'use strict';
const { const {
@ -46,13 +48,13 @@ exports.onForWorker = function (eventname, handler) {
} else { } else {
console.log('no uiworker to subscript to order'); console.log('no uiworker to subscript to order');
} }
} };
exports.emitForWorker = function (eventname, obj) { exports.emitForWorker = function (eventname, obj) {
if (uiworker) { if (uiworker) {
uiworker.port.emit(eventname, obj); uiworker.port.emit(eventname, obj);
} }
} };
// Begin tab handlers. These are for sidebar functionality, which is not // Begin tab handlers. These are for sidebar functionality, which is not
// present yet. // present yet.
@ -86,8 +88,9 @@ ContentPolicy({
origin: origin origin: origin
}) { }) {
// ignore URIs with no host // ignore URIs with no host
var topLevelDomain;
try { try {
var topLevelDomain = Connection.getDomain(location.host); topLevelDomain = Connection.getDomain(location.host);
} catch (e) { } catch (e) {
// See Issue 374: https://github.com/mozilla/lightbeam/issues/374 // See Issue 374: https://github.com/mozilla/lightbeam/issues/374
// if there is no host, like in about:what, then the host getter throws // if there is no host, like in about:what, then the host getter throws
@ -152,13 +155,13 @@ function attachToLightbeamPage(worker) {
function onPrefChanged(event) { function onPrefChanged(event) {
if ("contributeData" in event) { if ("contributeData" in event) {
prefs.contributeData = event["contributeData"]; prefs.contributeData = event.contributeData;
} }
if ("defaultVisualization" in event) { if ("defaultVisualization" in event) {
prefs.defaultVisualization = event["defaultVisualization"]; prefs.defaultVisualization = event.defaultVisualization;
} }
if ("defaultFilter" in event) { if ("defaultFilter" in event) {
prefs.defaultFilter = event["defaultFilter"]; prefs.defaultFilter = event.defaultFilter;
} }
} }