-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to toggle debug mode (#213)
This PR adds a checkbox which allows you to toggle the debug mode. The debug mode basically just adds a css class on every OctoLinker link so you easily spot all links. On Firefox and Opera the settings are stored locally. Chrome stores the settings within the users account, if available.
- Loading branch information
1 parent
85a46b4
commit 706be13
Showing
12 changed files
with
113 additions
and
6 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
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,5 +1,8 @@ | ||
import 'babel-polyfill'; | ||
import OctoLinker from './octo-linker.js'; | ||
import * as storage from './options/storage.js'; | ||
|
||
const octoLinker = new OctoLinker(); | ||
octoLinker.init(); | ||
storage.load(() => { | ||
const octoLinker = new OctoLinker(); | ||
octoLinker.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
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,9 @@ | ||
export default ({ name, label, value, defaultValue }) => { | ||
const val = (value === undefined) ? defaultValue : value; | ||
|
||
return `<section> | ||
<label> | ||
<input type="checkbox" name="${name}" ${val ? 'checked' : ''} /> ${label} | ||
</label> | ||
</section>`; | ||
}; |
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 @@ | ||
import checkbox from './checkbox'; | ||
|
||
export default function ({ type, ...rest }) { | ||
if (type === 'checkbox') { | ||
return checkbox(rest); | ||
} | ||
} |
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,9 @@ | ||
export const options = [ | ||
{ | ||
type: 'checkbox', | ||
name: 'debugMode', | ||
label: 'Debug mode', | ||
value: undefined, | ||
defaultValue: false, | ||
}, | ||
]; |
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,22 @@ | ||
import components from './components'; | ||
import * as storage from './storage'; | ||
import { options } from './options'; | ||
|
||
const formEl = document.querySelector('#options'); | ||
|
||
storage.load(() => { | ||
options.forEach((item) => { | ||
formEl.innerHTML += components({ | ||
...item, | ||
value: storage.get(item.name), | ||
}); | ||
}); | ||
}); | ||
|
||
formEl.addEventListener('click', ({ target }) => { | ||
const tag = target.tagName.toLowerCase(); | ||
|
||
if (tag === 'input' && target.type === 'checkbox') { | ||
storage.set(target.name, target.checked); | ||
} | ||
}); |
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,24 @@ | ||
import { options } from './options'; | ||
|
||
const store = {}; | ||
const defaults = {}; | ||
|
||
options.forEach((item) => { | ||
defaults[item.name] = item.defaultValue; | ||
}); | ||
|
||
export const load = (cb) => { | ||
(chrome.storage.sync || chrome.storage.local).get(null, (data) => { | ||
Object.assign(store, defaults, data); | ||
|
||
cb(); | ||
}); | ||
}; | ||
|
||
export const get = key => store[key]; | ||
|
||
export const set = (key, value) => { | ||
(chrome.storage.sync || chrome.storage.local).set({ | ||
[key]: value, | ||
}); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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