Skip to content

Commit

Permalink
Debug-Option per Einstellungsoberfläche konfigurierbar gemacht
Browse files Browse the repository at this point in the history
  • Loading branch information
cadeyrn committed Jan 11, 2017
1 parent ea1342e commit 20fd790
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
"omnibox_command_check_unknowns": {
"message": "Prüfe deine Lesezeichen nur auf welche, deren Status nicht ermittelt werden kann"
},
"option_debug_label": {
"message": "Debug-Option aktivieren"
},
"search_label": {
"message" : "Titel oder URL…"
}
Expand Down
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
"omnibox_command_check_unknowns": {
"message": "Prüfe deine Lesezeichen nur auf welche, deren Status nicht ermittelt werden kann"
},
"option_debug_label": {
"message": "Debug-Option aktivieren"
},
"search_label": {
"message" : "Titel oder URL…"
}
Expand Down
9 changes: 9 additions & 0 deletions src/css/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ footer a {
display: none;
}

.vertical-align > div {
display: table-cell;
vertical-align: middle;
}

.vertical-align label {
margin-left: 5px;
}

#counters {
margin-bottom: 20px;
font-weight: bold;
Expand Down
32 changes: 32 additions & 0 deletions src/html/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>__MSG_extension_name__</title>
<link rel='stylesheet' href='../css/ui.css' />
<link rel='icon' type='image/png' href='../images/icon-32.png'>
</head>
<body>
<header>
<a href='ui.html'><h1>__MSG_extension_name__</h1></a>
</header>
<progress id='progress' value='0'></progress>
<main>
<section>
<form>
<div class='vertical-align'>
<div><input type='checkbox' name='debug' id='debug'></div>
<div><label for='debug'>__MSG_option_debug_label__</label></div>
</div>
</form>
</section>
</main>
<footer>
<a href='https://www.soeren-hentzschel.at' target='_blank' rel='noopener'>
__MSG_extension_name__ © 2017, soeren-hentzschel.at
</a>
</footer>
<script src='../js/i18n.js'></script>
<script src='../js/options.js'></script>
</body>
</html>
10 changes: 7 additions & 3 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

const bookmarkchecker = {
UI_PAGE : 'html/ui.html',
DEBUG_MODE : false,
LIMIT : 0,
TIMEOUT : 0,
ATTEMPTS : 2,
debug_enabled : false,
inProgress : false,
internalCounter : 0,
totalBookmarks : 0,
Expand Down Expand Up @@ -109,6 +109,10 @@ const bookmarkchecker = {
bookmarkchecker.bookmarksResult = [];
bookmarkchecker.debug = [];

browser.storage.local.get('debug_enabled', function (result) {
bookmarkchecker.debug_enabled = result.debug_enabled;
});

browser.bookmarks.getTree().then((bookmarks) => {
bookmarkchecker.checkBookmarks(bookmarks[0], 'check', type);
});
Expand Down Expand Up @@ -233,7 +237,7 @@ const bookmarkchecker = {
bookmark.status = response.status;
}

if (bookmarkchecker.DEBUG_MODE) {
if (bookmarkchecker.debug_enabled) {
bookmarkchecker.debug.push({
bookmark : {
id : bookmark.id,
Expand Down Expand Up @@ -262,7 +266,7 @@ const bookmarkchecker = {
bookmark.status = STATUS.NOT_FOUND;
}

if (bookmarkchecker.DEBUG_MODE) {
if (bookmarkchecker.debug_enabled) {
bookmarkchecker.debug.push({
bookmark : {
id : bookmark.id,
Expand Down
20 changes: 20 additions & 0 deletions src/js/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const elDebug = document.querySelector('#debug');

const options = {
load : function () {
function setDebugOption(result) {
elDebug.checked = result.debug_enabled || false;
}

let debug = browser.storage.local.get('debug_enabled');
debug.then(setDebugOption);
}
};

document.addEventListener('DOMContentLoaded', options.load);

elDebug.addEventListener('change', function () {
browser.storage.local.set({ 'debug_enabled' : this.checked });
});
9 changes: 7 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@
"omnibox": {
"keyword" : "bookmarks"
},
"options_ui": {
"page": "html/options.html",
"open_in_tab": true
},
"permissions": [
"<all_urls>",
"bookmarks",
"tabs",
"<all_urls>"
"storage",
"tabs"
],
"default_locale": "en",
"applications": {
Expand Down

0 comments on commit 20fd790

Please sign in to comment.