Added button for enabling disabling logging.

This commit is contained in:
Mario Basic
2015-06-07 23:42:14 +02:00
parent 8c300f6e4e
commit 2d3d888125
9 changed files with 639 additions and 257 deletions

View File

@@ -2,6 +2,7 @@ import UrlHelper from './UrlHelper.js';
import $ from 'jquery';
import currentTimestamp from './helpers/currentTimestamp.js';
import changeExtensionIcon from './helpers/changeExtensionIcon.js';
import devtools from './libs/devtools-detect.js';
class WakaTime {
@@ -49,20 +50,26 @@ class WakaTime {
if (data !== false) {
// User is logged in.
// Change extension icon to default color.
changeExtensionIcon();
chrome.storage.sync.get({
loggingEnabled: false
}, (items) => {
if (items.loggingEnabled === true) {
changeExtensionIcon();
chrome.idle.queryState(this.detectionIntervalInSeconds, (newState) => {
chrome.idle.queryState(this.detectionIntervalInSeconds, (newState) => {
if (newState === 'active') {
// Get current tab URL.
chrome.tabs.query({active: true}, (tabs) => {
this.sendHeartbeat(tabs[0].url);
if (newState === 'active') {
// Get current tab URL.
chrome.tabs.query({active: true}, (tabs) => {
this.sendHeartbeat(tabs[0].url);
});
}
});
}
else {
changeExtensionIcon('red');
}
});
}
else {
@@ -120,6 +127,9 @@ class WakaTime {
var payload = null;
// TODO: Detect if devTools are open
console.log(devtools.open);
this._getLoggingType().done((loggingType) => {
// Get only the domain from the entity.