-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optional logging and no more speedlimits
- Loading branch information
Schwab Lukas
committed
Aug 16, 2019
1 parent
4722976
commit 2c6d23d
Showing
7 changed files
with
70 additions
and
28 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,22 +1,35 @@ | ||
const getLoggingState = () => localStorage.getItem('logging'); | ||
const setLoggingState = state => localStorage.setItem('logging', state); | ||
const getLoggingState = () => { | ||
return new Promise((resolve, reject) => { | ||
chrome.storage.local.get(['logging'], result => { | ||
resolve(result); | ||
}); | ||
}); | ||
}; | ||
|
||
const toggleLoggingState = () => { | ||
let state = getLoggingState(); | ||
if (!state || state === '') { | ||
setLoggingState('off'); | ||
} else { | ||
state === 'off' ? setLoggingState('on') : setLoggingState('off'); | ||
} | ||
const setLoggingState = state => { | ||
chrome.storage.local.set({ logging: state }, () => { | ||
console.log(`chrome.storage API -> logging was turned ${state}`); | ||
}); | ||
}; | ||
|
||
const updateSpan = () => { | ||
let state = getLoggingState(); | ||
if (!state || state === '') { | ||
setLoggingState('off'); | ||
} | ||
document.getElementById('onoff').innerText = state; | ||
const toggleLoggingState = () => { | ||
getLoggingState().then(result => { | ||
if (result.logging === 'off') { | ||
setLoggingState('on'); | ||
} else { | ||
setLoggingState('off'); | ||
} | ||
updateSpan(); | ||
}); | ||
}; | ||
|
||
document.addEventListener('DOMContentLoaded', updateSpan); | ||
document.getElementById('toggleLogging').addEventListener('click', toggleLoggingState); | ||
const updateSpan = () => getLoggingState().then(result => $('#onoff').text(result.logging)); | ||
|
||
$(document).ready(function() { | ||
$('#toggleLogging').click(() => { | ||
toggleLoggingState(); | ||
}); | ||
|
||
updateSpan(); | ||
$('.tooltipped').tooltip(); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.