зеркало из https://github.com/mozilla/lightbeam.git
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:
Родитель
088617d834
Коммит
de3d0cfd54
|
@ -8,3 +8,4 @@ data/deployment.json
|
|||
*.xpi
|
||||
exported_graphs
|
||||
*.swp
|
||||
/node_modules
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
// Graph Visualization
|
||||
|
||||
// Visualization of tracking data interconnections
|
||||
|
@ -50,7 +51,7 @@ aggregate.getBlockedDomains = function () {
|
|||
return Object.keys(userSettings).filter(function (domain) {
|
||||
return userSettings[domain] == 'block';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
aggregate.getAllNodes = function () {
|
||||
var blockedDomains = aggregate.getBlockedDomains();
|
||||
|
@ -63,7 +64,7 @@ aggregate.getAllNodes = function () {
|
|||
name: domain
|
||||
};
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
aggregate.getConnectionCount = function (node) {
|
||||
if (node.nodeType === 'blocked')
|
||||
|
@ -71,11 +72,11 @@ aggregate.getConnectionCount = function (node) {
|
|||
|
||||
let connections = Object.keys(aggregate.nodeForKey(node.name)).length;
|
||||
return connections - 1 > 0 ? connections - 1 : 0;
|
||||
}
|
||||
};
|
||||
|
||||
aggregate.nodeForKey = function (key) {
|
||||
var result = {};
|
||||
var linkedNodes = new Array();
|
||||
var linkedNodes = [];
|
||||
|
||||
if (aggregate.nodemap[key]) {
|
||||
linkedNodes = aggregate.nodemap[key].linkedFrom.concat(aggregate.nodemap[key].linkedTo);
|
||||
|
@ -120,7 +121,7 @@ aggregate.connectionAsObject = function (conn) {
|
|||
}
|
||||
return conn;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Pass the list of connections to build the graph structure to pass to d3 for
|
||||
// visualizations.
|
||||
|
@ -167,7 +168,7 @@ const CACHEABLE = 13;
|
|||
// of false positives.
|
||||
aggregate.isDomainVisited = function isDomainVisited(domain) {
|
||||
return aggregate.recentSites.length && (aggregate.recentSites.indexOf(domain) > -1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function onConnection(conn) {
|
||||
|
@ -236,7 +237,7 @@ function onConnection(conn) {
|
|||
aggregate.trackerCount++;
|
||||
}
|
||||
// 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
|
||||
if (aggregate.edgemap[connection.source + '->' + connection.target]) {
|
||||
|
@ -291,13 +292,13 @@ function GraphEdge(source, target, connection) {
|
|||
}
|
||||
GraphEdge.prototype.lastAccess = function () {
|
||||
return (this.source.lastAccess > this.target.lastAccess) ? this.source.lastAccess : this.target.lastAccess;
|
||||
}
|
||||
};
|
||||
GraphEdge.prototype.firstAccess = function () {
|
||||
return (this.source.firstAccess < this.target.firstAccess) ? this.source.firstAccess : this.target.firstAccess;
|
||||
}
|
||||
};
|
||||
GraphEdge.prototype.update = function (connection) {
|
||||
this.cookieCount = connection.cookie ? this.cookieCount + 1 : this.cookieCount;
|
||||
}
|
||||
};
|
||||
|
||||
// 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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
/* Dialog / Popup ===================================== */
|
||||
|
||||
// dialog names (used as dialog identifiers)
|
||||
|
@ -118,7 +119,7 @@ function addDialogEventHandlers(modal, options, callback) {
|
|||
modal.close();
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", keyDownHandler);
|
||||
|
||||
modal.onClose(function () {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
// Graph Visualization (one of 3 views: graph, clock, and list). This is way
|
||||
// too heavyweight for mobile right now.
|
||||
|
||||
|
@ -70,7 +71,7 @@ function onInit() {
|
|||
vizcanvas.setAttribute('viewBox', [0, 0, width, height].join(' '));
|
||||
// console.log('graph::onInit end');
|
||||
document.querySelector(".filter-display").classList.remove("hidden");
|
||||
};
|
||||
}
|
||||
|
||||
function onRemove() {
|
||||
// var startTime = Date.now();
|
||||
|
@ -81,7 +82,7 @@ function onRemove() {
|
|||
resetCanvas();
|
||||
document.querySelector(".filter-display").classList.add("hidden");
|
||||
// console.log('it took %s ms to remove graph view', Date.now() - startTime);
|
||||
};
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
onRemove();
|
||||
|
@ -161,23 +162,24 @@ function charge(d) {
|
|||
}
|
||||
|
||||
function colourHighlightNodes(highlight) {
|
||||
var i;
|
||||
var watchedSites = document.querySelectorAll(".watched");
|
||||
var blockedSites = document.querySelectorAll(".blocked");
|
||||
if (highlight.watched) {
|
||||
for (var i = 0; i < watchedSites.length; i++) {
|
||||
for (i = 0; i < watchedSites.length; i++) {
|
||||
watchedSites[i].classList.add("watchedSites");
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < watchedSites.length; i++) {
|
||||
for (i = 0; i < watchedSites.length; i++) {
|
||||
watchedSites[i].classList.remove("watchedSites");
|
||||
}
|
||||
}
|
||||
if (highlight.blocked) {
|
||||
for (var i = 0; i < blockedSites.length; i++) {
|
||||
for (i = 0; i < blockedSites.length; i++) {
|
||||
blockedSites[i].classList.add("blockedSites");
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < blockedSites.length; i++) {
|
||||
for (i = 0; i < blockedSites.length; i++) {
|
||||
blockedSites[i].classList.remove("blockedSites");
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +245,7 @@ function initGraph() {
|
|||
});
|
||||
nodes.each(function (d, i) {
|
||||
// `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());
|
||||
if (d.nodeType === 'site' || d.nodeType === 'both') {
|
||||
this.classList.add('visitedYes');
|
||||
|
@ -317,7 +319,7 @@ function addCircle(selection) {
|
|||
.append('circle')
|
||||
.attr('cx', 0)
|
||||
.attr('cy', 0)
|
||||
.attr('r', graphNodeRadius["graph"])
|
||||
.attr('r', graphNodeRadius.graph)
|
||||
.classed('site', true);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ global.initMap = function initMap(mapcanvas, mapDocument) {
|
|||
if (currentRequest === info.host) {
|
||||
callback((request.status === 200) ? JSON.parse(request.responseText) : false);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ global.initMap = function initMap(mapcanvas, mapDocument) {
|
|||
}, false);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Info Panel Tabs ======================================== */
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
(function (global) {
|
||||
|
||||
'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);
|
||||
}
|
||||
if (children) {
|
||||
|
@ -113,7 +114,7 @@ global.switchVisualization = function switchVisualization(name) {
|
|||
defaultVisualization: name
|
||||
});
|
||||
// console.log('it took %s ms to switch visualizations', Date.now() - startTime);
|
||||
}
|
||||
};
|
||||
|
||||
function resetAdditionalUI() {
|
||||
// toggle off info panel
|
||||
|
@ -150,7 +151,7 @@ global.startSharing = function startSharing(askForConfirmation, callback) {
|
|||
} else {
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/****************************************
|
||||
* 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)];
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
|
||||
|
@ -172,7 +173,7 @@ global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
|
|||
num = parseFloat(num);
|
||||
}
|
||||
return (num !== 1) ? str + "s" : str;
|
||||
}
|
||||
};
|
||||
|
||||
/****************************************
|
||||
* update Stats Bar
|
||||
|
@ -185,6 +186,6 @@ global.updateStatsBar = function updateStatsBar() {
|
|||
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 .first-party-sites").textContent = aggregate.siteCount + " " + singularOrPluralNoun(aggregate.siteCount, "SITE");
|
||||
}
|
||||
};
|
||||
|
||||
})(this);
|
||||
|
|
15
data/list.js
15
data/list.js
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
/* jshint moz: true */
|
||||
// List Visualization
|
||||
|
||||
// Display data in tabular format
|
||||
|
||||
(function (visualizations, global) {
|
||||
"use strict";
|
||||
|
||||
var list = new Emitter();
|
||||
var breadcrumbStack = [];
|
||||
|
@ -482,7 +482,7 @@ function sortTableOnColumn(table, n) {
|
|||
|
||||
tbody.appendChild(preFrag);
|
||||
tbody.appendChild(frag);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function resetCanvas() {
|
||||
|
@ -511,7 +511,7 @@ function getSelectedRows() {
|
|||
// returns selected rows as an Array
|
||||
return getAllRows().filter(function (item) {
|
||||
return item.querySelector('.selected-row:checked');
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Event handlers
|
||||
|
@ -539,16 +539,17 @@ function setUserSetting(row, pref) {
|
|||
|
||||
// selectAllRows should only select VISIBLE rows
|
||||
function selectAllRows(flag) {
|
||||
var i;
|
||||
// apply flag to ALL rows first
|
||||
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;
|
||||
highlightRow(rows[i], flag);
|
||||
}
|
||||
// and then exclude all the hidden rows
|
||||
if (document.querySelector(".hide-hidden-rows")) {
|
||||
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
|
||||
highlightRow(hiddenRows[i], false);
|
||||
}
|
||||
|
@ -645,7 +646,7 @@ function initializeHandlers() {
|
|||
});
|
||||
showFilteredTable(lastFilter);
|
||||
selected = getAllRows().filter(function (row) {
|
||||
return wereSelected.indexOf(row.dataset.name) > -1
|
||||
return wereSelected.indexOf(row.dataset.name) > -1;
|
||||
})
|
||||
.map(function (rowToSelect) {
|
||||
rowToSelect.querySelector("[type=checkbox]").checked = true;
|
||||
|
|
|
@ -16,7 +16,7 @@ function parseUri(str) {
|
|||
});
|
||||
|
||||
return uri;
|
||||
};
|
||||
}
|
||||
|
||||
parseUri.options = {
|
||||
strictMode: false,
|
||||
|
|
|
@ -20,7 +20,7 @@ function svgdataset(elem) {
|
|||
// act as getter
|
||||
value = elem.getAttribute(dataKeyToAttr(key));
|
||||
try {
|
||||
get
|
||||
get;
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
return value;
|
||||
|
|
44
data/ui.js
44
data/ui.js
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
(function (global) {
|
||||
// Bunch of utilities related to UI elements.
|
||||
const graphNodeRadius = {
|
||||
|
@ -10,7 +11,7 @@ global.graphNodeRadius = graphNodeRadius;
|
|||
/* Convert a NodeList to Array */
|
||||
global.toArray = function toArray(nl) {
|
||||
return Array.prototype.slice.call(nl, 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**************************************************
|
||||
* For accessibility:
|
||||
|
@ -94,7 +95,7 @@ global.confirmStartSharing = function confirmStartSharing(askForConfirmation, el
|
|||
elmClicked.checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
global.confirmStopSharing = function confirmStopSharing(elmClicked) {
|
||||
stopSharingDialog(function (confirmed) {
|
||||
|
@ -107,7 +108,7 @@ global.confirmStopSharing = function confirmStopSharing(elmClicked) {
|
|||
elmClicked.checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function toggleBtnOnEffect(toggleBtn) {
|
||||
toggleBtn.querySelector(".toggle-btn-innner").classList.add("checked");
|
||||
|
@ -135,7 +136,7 @@ function downloadAsJson(data, defaultFilename) {
|
|||
a.target = '_blank';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
|
@ -184,12 +185,12 @@ global.getZoom = function getZoom(canvas) {
|
|||
console.log('Caller: %o', caller);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global.setZoom = function setZoom(box, canvas) {
|
||||
// TODO: code cleanup if both cases use basically the same code
|
||||
canvas.setAttribute('viewBox', [box.x, box.y, box.w, box.h].join(' '));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* 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
|
||||
// if yes, zoom
|
||||
function zoomWithinLimit(scrollDist, targetSvg, zoomInLimit, zoomOutLimit) {
|
||||
var i;
|
||||
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)) {
|
||||
svgZooming(targetSvg, (1 / svgZoomingRatio));
|
||||
}
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
svgZooming(targetSvg, svgZoomingRatio);
|
||||
}
|
||||
|
@ -341,13 +343,13 @@ global.toggleLegendSection = function toggleLegendSection(eventTarget, legendElm
|
|||
elmToToggle.classList.add("hidden");
|
||||
eventTarget.textContent = "Show";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global.toggleVizElements = function toggleVizElements(elements, classToggle) {
|
||||
toArray(elements).forEach(function (elm) {
|
||||
elm.classList.toggle(classToggle);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -361,7 +363,7 @@ global.selectedNodeEffect = function selectedNodeEffect(name) {
|
|||
if (g.currentVisualization.name == "list") {
|
||||
resetHighlightedRow();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global.connectedNodeEffect = function connectedNodeEffect(name) {
|
||||
// console.log(name);
|
||||
|
@ -380,7 +382,7 @@ global.connectedNodeEffect = function connectedNodeEffect(name) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// for Graph & Clock
|
||||
global.addGlow = function addGlow(name, type) {
|
||||
|
@ -398,7 +400,7 @@ global.addGlow = function addGlow(name, type) {
|
|||
.classed(type, true);
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
global.calculateGlowSize = function calculateGlowSize(gNode, viz) {
|
||||
var glowProps = {};
|
||||
|
@ -416,7 +418,7 @@ global.calculateGlowSize = function calculateGlowSize(gNode, viz) {
|
|||
glowProps.cy = siteNode.getAttribute("cy") || 0;
|
||||
|
||||
return glowProps;
|
||||
}
|
||||
};
|
||||
|
||||
// for Graph
|
||||
global.resetAllGlow = function resetAllGlow(type) {
|
||||
|
@ -434,7 +436,7 @@ global.resetAllGlow = function resetAllGlow(type) {
|
|||
connectedGlow.parentNode.removeChild(connectedGlow);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// for List
|
||||
global.resetHighlightedRow = function resetHighlightedRow() {
|
||||
|
@ -442,7 +444,7 @@ global.resetHighlightedRow = function resetHighlightedRow() {
|
|||
if (preHighlighted) {
|
||||
preHighlighted.classList.remove("selected-connected-row");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**************************************************
|
||||
* Singular / Plural Noun
|
||||
|
@ -452,12 +454,12 @@ global.singularOrPluralNoun = function singularOrPluralNoun(num, str) {
|
|||
num = parseFloat(num);
|
||||
}
|
||||
return (num > 1) ? str + "s" : str;
|
||||
}
|
||||
};
|
||||
|
||||
function updateUIFromPrefs(event) {
|
||||
if ("contributeData" in event && event["contributeData"]) {
|
||||
if ("contributeData" in event && event.contributeData) {
|
||||
var toggleBtn = document.querySelector(".share-btn");
|
||||
if (event["contributeData"]) {
|
||||
if (event.contributeData) {
|
||||
toggleBtn.querySelector("input").checked = true;
|
||||
toggleBtnOnEffect(toggleBtn);
|
||||
} else {
|
||||
|
@ -466,7 +468,7 @@ function updateUIFromPrefs(event) {
|
|||
}
|
||||
}
|
||||
if ("defaultVisualization" in event) {
|
||||
global.currentVisualization = visualizations[event["defaultVisualization"]];
|
||||
global.currentVisualization = visualizations[event.defaultVisualization];
|
||||
if (global.currentVisualization) {
|
||||
console.log("Got viz");
|
||||
} else {
|
||||
|
@ -475,7 +477,7 @@ function updateUIFromPrefs(event) {
|
|||
}
|
||||
|
||||
if ("defaultFilter" in event) {
|
||||
aggregate.currentFilter = event["defaultFilter"];
|
||||
aggregate.currentFilter = event.defaultFilter;
|
||||
document.querySelector('a[data-value=' + aggregate.currentFilter + ']')
|
||||
.dataset.selected = true;
|
||||
document.querySelector(".filter-display header").textContent =
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
// Connection object. This module may try to do too many things.
|
||||
//
|
||||
// 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",
|
||||
ss.storage.connections.length, "persisted connections");
|
||||
return ss.storage.connections.concat(connBatch);
|
||||
}
|
||||
};
|
||||
|
||||
function excludePrivateConnections(connections) {
|
||||
return connections.filter(function (connection) {
|
||||
|
@ -80,7 +81,7 @@ function getDomain(host) {
|
|||
Connection.getDomain = getDomain; // make it part of what we export
|
||||
Connection.reset = function () {
|
||||
connBatch.length = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Get subdomain (e.g., foo from foo.example.com)
|
||||
function getSubdomain(host) {
|
||||
|
@ -88,14 +89,14 @@ function getSubdomain(host) {
|
|||
return host.slice(0, host.length - domain.length);
|
||||
}
|
||||
|
||||
function Connection() {};
|
||||
function Connection() {}
|
||||
|
||||
// subject comes from events.on("http-on-modify-request");
|
||||
Connection.fromSubject = function (subject) {
|
||||
var conn = new Connection();
|
||||
conn.restoreFromSubject(subject);
|
||||
return conn;
|
||||
}
|
||||
};
|
||||
|
||||
// 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
|
||||
|
@ -142,8 +143,9 @@ Connection.prototype.restoreFromSubject = function (event) {
|
|||
var source = channel.referrer;
|
||||
var target = channel.URI;
|
||||
var targetDomain = getDomain(target.host);
|
||||
var tab = null;
|
||||
try {
|
||||
var tab = getTabForChannel(channel);
|
||||
tab = getTabForChannel(channel);
|
||||
} catch (e) {
|
||||
console.log('EXCEPTION CAUGHT: No tab for connection');
|
||||
tab = null;
|
||||
|
@ -154,7 +156,7 @@ Connection.prototype.restoreFromSubject = function (event) {
|
|||
var browserSpec = browserUri && browserUri.spec;
|
||||
var browserDomain = null;
|
||||
try {
|
||||
var browserDomain = browserUri && getDomain(browserUri.host);
|
||||
browserDomain = browserUri && getDomain(browserUri.host);
|
||||
} catch (e) {
|
||||
// chances are the URL is about:blank, which has no host and throws an exception
|
||||
// console.error('Error getting host from: ' + browserUri.spec);
|
||||
|
@ -236,7 +238,7 @@ Connection.prototype.restoreFromSubject = function (event) {
|
|||
this.isPrivate = isPrivate;
|
||||
this._sourceTab = tab; // Never logged, only for associating data with current tab
|
||||
// console.error((sourceVisited ? 'site: ' : 'tracker: ') + sourceDomain + ' -> ' + targetDomain + ' (' + browserUri.spec + ')');
|
||||
}
|
||||
};
|
||||
|
||||
// Connection - level methods (not on instances)
|
||||
// This may be supported by the addon-sdk events.on now.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* jshint moz: true */
|
||||
/* global exports, require */
|
||||
"use strict";
|
||||
|
||||
const events = require("sdk/system/events");
|
||||
|
@ -66,4 +68,4 @@ exports.main = function (options, callbacks) {
|
|||
return;
|
||||
}
|
||||
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.
|
||||
"use strict";
|
||||
|
||||
|
@ -11,7 +13,7 @@ var storage = ss.storage;
|
|||
const STORAGE_KEYS = [
|
||||
"blockmap",
|
||||
"connections",
|
||||
]
|
||||
];
|
||||
|
||||
// Upload logic.
|
||||
function serializeConnections(connections) {
|
||||
|
@ -20,7 +22,7 @@ function serializeConnections(connections) {
|
|||
version: '1.1',
|
||||
uploadTime: Date.now(),
|
||||
connections: connections
|
||||
}
|
||||
};
|
||||
return JSON.stringify(exportSet);
|
||||
}
|
||||
|
||||
|
@ -63,7 +65,7 @@ exports.storeConnections = function storeConnections(connections) {
|
|||
if (prefs.contributeData) {
|
||||
upload(connections);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Reset stored state, including preferences
|
||||
exports.reset = function reset() {
|
||||
|
@ -72,7 +74,7 @@ exports.reset = function reset() {
|
|||
prefs.contributeData = false;
|
||||
prefs.defaultVisualization = "graph";
|
||||
prefs.defaultFilter = "daily";
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize all of our storage
|
||||
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
|
||||
* 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/. */
|
||||
|
@ -142,7 +144,9 @@ function addMenuitems(self, options) {
|
|||
|
||||
// add unloader
|
||||
let unloader = function unloader() {
|
||||
menuitem.parentNode && menuitem.parentNode.removeChild(menuitem);
|
||||
if (menuitem.parentNode) {
|
||||
menuitem.parentNode.removeChild(menuitem);
|
||||
}
|
||||
menuitems[menuitems_i] = null;
|
||||
};
|
||||
menuitemNS(self).unloaders.push(function () {
|
||||
|
@ -218,17 +222,17 @@ function tryParent(parent, menuitem, before) {
|
|||
return !!parent;
|
||||
}
|
||||
|
||||
function insertBefore(parent, insertBefore) {
|
||||
if (typeof insertBefore == "number") {
|
||||
switch (insertBefore) {
|
||||
function insertBefore(parent, before) {
|
||||
if (typeof before == "number") {
|
||||
switch (before) {
|
||||
case MenuitemExport.FIRST_CHILD:
|
||||
return parent.firstChild;
|
||||
}
|
||||
return null;
|
||||
} else if (typeof insertBefore == "string") {
|
||||
return parent.querySelector("#" + insertBefore);
|
||||
} else if (typeof before == "string") {
|
||||
return parent.querySelector("#" + before);
|
||||
}
|
||||
return insertBefore;
|
||||
return before;
|
||||
}
|
||||
|
||||
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
|
||||
* 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/. */
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* jshint moz:true */
|
||||
/* global require, console, exports */
|
||||
/* 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
@ -38,7 +40,7 @@ var Unloader = exports.Unloader = Class({
|
|||
callback = function () {
|
||||
container.removeEventListener("unload", windowRemover, false);
|
||||
origCallback();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 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.
|
||||
'use strict';
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint moz: true */
|
||||
// ChromeTab
|
||||
//
|
||||
// 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)
|
||||
.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
||||
return loadContext;
|
||||
} catch (ex) {
|
||||
} catch (err1) {
|
||||
// fail over to trying the load group
|
||||
try {
|
||||
if (!aRequest.loadGroup) return null;
|
||||
|
||||
var loadContext = aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
||||
return loadContext;
|
||||
} catch (ex) {
|
||||
} catch (err2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
15
lib/ui.js
15
lib/ui.js
|
@ -1,3 +1,5 @@
|
|||
/* jshint moz:true */
|
||||
/* global require, exports, console */
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
|
@ -46,13 +48,13 @@ exports.onForWorker = function (eventname, handler) {
|
|||
} else {
|
||||
console.log('no uiworker to subscript to order');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.emitForWorker = function (eventname, obj) {
|
||||
if (uiworker) {
|
||||
uiworker.port.emit(eventname, obj);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Begin tab handlers. These are for sidebar functionality, which is not
|
||||
// present yet.
|
||||
|
@ -86,8 +88,9 @@ ContentPolicy({
|
|||
origin: origin
|
||||
}) {
|
||||
// ignore URIs with no host
|
||||
var topLevelDomain;
|
||||
try {
|
||||
var topLevelDomain = Connection.getDomain(location.host);
|
||||
topLevelDomain = Connection.getDomain(location.host);
|
||||
} catch (e) {
|
||||
// See Issue 374: https://github.com/mozilla/lightbeam/issues/374
|
||||
// if there is no host, like in about:what, then the host getter throws
|
||||
|
@ -152,13 +155,13 @@ function attachToLightbeamPage(worker) {
|
|||
|
||||
function onPrefChanged(event) {
|
||||
if ("contributeData" in event) {
|
||||
prefs.contributeData = event["contributeData"];
|
||||
prefs.contributeData = event.contributeData;
|
||||
}
|
||||
if ("defaultVisualization" in event) {
|
||||
prefs.defaultVisualization = event["defaultVisualization"];
|
||||
prefs.defaultVisualization = event.defaultVisualization;
|
||||
}
|
||||
if ("defaultFilter" in event) {
|
||||
prefs.defaultFilter = event["defaultFilter"];
|
||||
prefs.defaultFilter = event.defaultFilter;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче