-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bcdc36
commit 88b9b7e
Showing
14 changed files
with
865 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>tab-data-firefox</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
</buildSpec> | ||
<natures> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
</head> | ||
<body> | ||
<label>Global count: </label><input type="text" id="globalCount" disabled="true" size="5"></input><br/> | ||
<label>Session count: </label><input type="text" id="sessionCount" disabled="true" size="5"></input><br/> | ||
<label>Current count: </label><input type="text" id="currentCount" disabled="true" size="5"></input> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
self.port.on("stats", function (stats) { | ||
var parsedStats = JSON.parse(stats); | ||
|
||
document.getElementById("globalCount").value = parsedStats.globalCount; | ||
document.getElementById("sessionCount").value = parsedStats.sessionCount; | ||
document.getElementById("currentCount").value = parsedStats.currentCount; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var data = require("sdk/self").data; | ||
|
||
exports.get = function(content) { | ||
|
||
return data.url(content); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var Panel = require("sdk/panel"), | ||
Tab = require("./Tab"), | ||
Data = require("./Data"), | ||
Button = require("./ToggleButton"), | ||
panel; | ||
|
||
exports.init = function() { | ||
|
||
panel = Panel.Panel({ | ||
width: 225, | ||
height: 100, | ||
contentURL: Data.get("html/view.html"), | ||
contentScriptFile: Data.get("js/controller.js"), | ||
onShow: function() { | ||
|
||
var stats = JSON.stringify({ | ||
globalCount: Tab.getGlobalCount(), | ||
sessionCount: Tab.getSessionCount(), | ||
currentCount: Tab.getCurrentCount() | ||
}); | ||
|
||
panel.port.emit("stats", stats); | ||
}, | ||
onHide: function() { | ||
Button.get().state('window', {checked: false}); | ||
} | ||
}); | ||
}; | ||
|
||
exports.get = function() { | ||
|
||
return panel; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var ss = require("sdk/simple-storage"); | ||
|
||
exports.init = function(){ | ||
ss.storage.globalCount = []; | ||
} | ||
|
||
function getGlobalCount(){ | ||
return ss.storage.globalCount; | ||
} | ||
|
||
exports.getGlobalCount = function(){ | ||
return getGlobalCount(); | ||
} | ||
|
||
function setGlobalCount(globalCount){ | ||
ss.storage.globalCount = globalCount; | ||
} | ||
|
||
exports.setGlobalCount = function(globalCount){ | ||
setGlobalCount(globalCount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var tabs = require("sdk/tabs"), | ||
ss = require("./SimpleStorage"), | ||
sessionCount = 0, | ||
currentCount = 0; | ||
|
||
exports.init = function(){ | ||
|
||
if (typeof ss.getGlobalCount() === 'undefined'){ | ||
ss.setGlobalCount(0); | ||
} | ||
|
||
for each (var tab in tabs){ | ||
|
||
ss.setGlobalCount(ss.getGlobalCount() + 1, new Date().getTime()); | ||
sessionCount++; | ||
currentCount++; | ||
} | ||
|
||
|
||
// Listen for tab openings. | ||
tabs.on('open', function onOpen(tab) { | ||
|
||
ss.setGlobalCount(ss.getGlobalCount() + 1, new Date().getTime()); | ||
sessionCount++; | ||
currentCount++; | ||
console.log('Global: ' + ss.getGlobalCount()); | ||
console.log('Session: ' + sessionCount); | ||
console.log('Current: ' + currentCount); | ||
}); | ||
|
||
//Listen for tab closes. | ||
tabs.on('close', function onOpen(tab) { | ||
|
||
currentCount--; | ||
console.log('Global: ' + ss.getGlobalCount()); | ||
console.log('Session: ' + sessionCount); | ||
console.log('Current: ' + currentCount); | ||
}); | ||
} | ||
|
||
|
||
exports.getGlobalCount = function(){ | ||
return ss.getGlobalCount(); | ||
} | ||
|
||
exports.getSessionCount = function(){ | ||
return sessionCount; | ||
} | ||
|
||
exports.getCurrentCount = function(){ | ||
return currentCount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var { ToggleButton } = require("sdk/ui/button/toggle"), | ||
Data = require("./Data"), | ||
Panel = require("./Panel"), | ||
button; | ||
|
||
exports.init = function() { | ||
|
||
button = ToggleButton({ | ||
id: "tab-data-widget", | ||
label: 'Tab Data', | ||
icon: Data.get("images/tabs-64.png"), | ||
onChange: handleChange | ||
}); | ||
} | ||
|
||
exports.get = function() { | ||
return button; | ||
} | ||
|
||
function handleChange(state) { | ||
if (state.checked) { | ||
Panel.get().show({ | ||
position: button | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require("./Tab").init(); | ||
require("./ToggleButton").init(); | ||
require("./Panel").init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "tab-data-addon", | ||
"title": "Tab Data", | ||
"id": "jid1-4ogjq7MUzAiCOw", | ||
"description": "Provides user with tab related stats/data", | ||
"author": "Robert Byrne", | ||
"license": "GNU GPL v3", | ||
"version": "0.1", | ||
"permissions": {"private-browsing": true} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var main = require("./main"); | ||
|
||
exports["test main"] = function(assert) { | ||
assert.pass("Unit test running!"); | ||
}; | ||
|
||
exports["test main async"] = function(assert, done) { | ||
assert.pass("async Unit test running!"); | ||
done(); | ||
}; | ||
|
||
require("sdk/test").run(exports); |