Skip to content

Commit

Permalink
Only set timestamp if option is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
adlawson committed Apr 9, 2017
1 parent e183f77 commit a4e4a5d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tracklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ function fetchData(location, fn) {
"json": true
}, (error, response, data) => {
if (!error && response.statusCode === 200 && data.cloudcast.sections.length > 0) {
fn(insertTimestamp(insertTrackNumber(data)));
chrome.storage.sync.get({
timestamp: false
}, (options) => {
fn(insertTimestamp(insertTrackNumber(data), options));
});
} else {
console.error(error);
}
});
}

function insertTimestamp(data) {
function insertTimestamp(data, options) {
data.cloudcast.sections.forEach((section, i) => {
if (section.start_time !== null) {
if (section.start_time !== null && options.timestamp === true) {
const minutes = Math.floor(section.start_time / 60);
const seconds = ("0" + section.start_time % 60).slice(-2);
section.timestamp = `${minutes}:${seconds}`;
Expand Down

0 comments on commit a4e4a5d

Please sign in to comment.