Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: srikarg/Trackr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: craxrev/Trackr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 20, 2018

  1. Copy the full SHA
    af39c29 View commit details
  2. Copy the full SHA
    fd2b0c1 View commit details

Commits on Sep 7, 2018

  1. Remove debug line

    craxrev committed Sep 7, 2018
    Copy the full SHA
    ae56a84 View commit details
Showing with 49 additions and 3 deletions.
  1. +45 −2 js/override.js
  2. +2 −1 manifest.json
  3. +2 −0 src/override/override.html
47 changes: 45 additions & 2 deletions js/override.js
Original file line number Diff line number Diff line change
@@ -10,18 +10,61 @@ $(function() {
});
};

var exportData = function() {
chrome.storage.local.get('trackr', function(data) {
if (! $.isEmptyObject(data)) {

var result = JSON.stringify(data);
var url = 'data:application/json;base64,' + btoa(result);
chrome.downloads.download({
url: url,
filename: 'trackr_' + (new Date()).getTime() + '.json'
});
}
});
};

var importData = function(res) {
try {
var data = JSON.parse(res);
chrome.storage.local.set(data);
location.reload();
} catch (ex) {
console.error(ex);
}
};

getSettings();

$('.controls #clear').on('click', function() {
$('.container #clear').on('click', function() {
exportData();
chrome.storage.local.remove('trackr');
location.reload();
});

$('.container').on('click', '#import', function() {
$('.container #fileid').click();
});

$('.container').on('change', '#fileid', function() {
var file = $('.container #fileid')[0].files[0];
if (file) {
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = function (evt) {
importData(evt.target.result);
};
reader.onerror = function (evt) {
console.log('error reading file');
};
}
});

chrome.storage.local.get('trackr', function(data) {
if ($.isEmptyObject(data)) {
var $container = $('.container');
$container.empty();
$container.append('<div class="message"><h1>No URLs are tracked yet!</h1></div>');
$container.append('<div class="message"><h1>No URLs are tracked yet!</h1><input id="fileid" type="file" hidden/><button id="import">Import</button></div>');
return;
}

3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
"tabs",
"*://*/*",
"storage",
"unlimitedStorage"
"unlimitedStorage",
"downloads"
]
}
2 changes: 2 additions & 0 deletions src/override/override.html
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@
<canvas class="animated pulse" id="chart"></canvas>
<div class="controls animated fadeIn">
<button id="clear">Clear All</button>
<input id="fileid" type="file" hidden/>
<button id="import">Import</button>
</div>
<div class="legend animated fadeIn"></div>
</div>