diff --git a/webextension/main.js b/webextension/main.js
index 1ae6fb2..7665a80 100644
--- a/webextension/main.js
+++ b/webextension/main.js
@@ -6,26 +6,27 @@ var port = browser.runtime.connect({name: "connection-to-legacy"});
//
// Handle addon settings
//
-var defaultSettings = {
- right: false,
- hideInFullscreen: true,
- compact: false,
- "style.tab.status": false,
- theme: "dark",
- tabtoolbarPosition: "top",
- toggleDisplayHotkey: "control-alt-v",
- width: 250,
- debug: false,
- showHiddenSettings: false,
- experiment: false
+var settings;
+var xhr = new XMLHttpRequest();
+xhr.onreadystatechange = function()
+{
+ settings = JSON.parse(xhr.responseText);
+}
+xhr.open("GET", "options/options.json", true);
+xhr.send();
+
+
+function get_options_object()
+{
+ return settings;
}
function restore_default_settings()
{
- Object.keys(defaultSettings).forEach(function(k)
+ Object.keys(settings).forEach(function(optionsElement)
{
- save_setting(k, defaultSettings[k]);
- sdk_send_changed_setting(k);
+ save_setting(settings[optionsElement]["name"], settings[optionsElement]["value"]);
+ sdk_send_changed_setting(settings[optionsElement]["name"]);
});
}
@@ -54,9 +55,9 @@ function get_setting(name)
if (!results.hasOwnProperty(name))
{
debug_log("VTR WebExt setting '"+ name +"': not saved use default value.");
- if(defaultSettings.hasOwnProperty(name))
+ if(settings.hasOwnProperty(name))
{
- results[name] = defaultSettings[name];
+ results[name] = settings[name]["value"];
}
else
{
diff --git a/webextension/options/options.js b/webextension/options/options.js
index c984678..48cb6e2 100644
--- a/webextension/options/options.js
+++ b/webextension/options/options.js
@@ -1,128 +1,10 @@
var main = browser.extension.getBackgroundPage();
var blockSaveEvent = false;
-var settings = [
- {
- "name": "right",
- "type": "bool",
- "title": "Display tabs on the right",
- "value": false
- },
- {
- "name": "hideInFullscreen",
- "type": "bool",
- "title": "Hide tabs in fullscreen",
- "value": true
- },
- {
- "name": "compact",
- "type": "bool",
- "title": "Compact Mode (hides text labels)",
- "value": false
- },
- {
- "name": "style.tab.status",
- "type": "bool",
- "title": "Show Tab Status on Text Label",
- "description": "Unloaded: strike-through; Unread/busy: underline",
- "value": false
- },
- {
- "name": "theme",
- "type": "menulist",
- "title": "Theme",
- "value": "dark",
- "options": [
- {
- "value": "none",
- "label": "None / Firefox default"
- },
- {
- "value": "dark",
- "label": "Dark (recommended)"
- },
- {
- "value": "light",
- "label": "Light (recommended)"
- },
- {
- "value": "windows",
- "label": "Windows"
- },
- {
- "value": "darwin",
- "label": "Darwin"
- },
- {
- "value": "linux",
- "label": "Linux"
- }
- ]
- },
- {
- "name": "tabtoolbarPosition",
- "type": "menulist",
- "title": "Toolbar Position",
- "value": "top",
- "options": [
- {
- "value": "top",
- "label": "Top"
- },
- {
- "value": "bottom",
- "label": "Bottom"
- }
- ]
- },
- {
- "name": "toggleDisplayHotkey",
- "type": "string",
- "title": "Hotkey for hiding/showing tabbar",
- "value": "control-shift-v"
- },
- {
- "name": "toggleDrawInTitlebar",
- "type": "control",
- "title": "Enable/Disable titlebar",
- "label": "Toggle titlebar",
- "description": "Enable the titlebar if the window control buttons are overlapping with Firefox elements"
- },
- {
- "name": "setDefaultPrefs",
- "type": "control",
- "title": "Reset preferences of VTR",
- "label": "Restore default preferences"
- },
- {
- "name": "showHiddenSettings",
- "type": "bool",
- "title": "Display hidden settings",
- "value": false,
- "hidden": true
- },
- {
- "name": "width",
- "type": "integer",
- "title": "Width of the tab sidebar",
- "value": 250,
- "hidden": true
- },
- {
- "name": "debug",
- "type": "bool",
- "title": "Enable console logging for debugging",
- "value": false,
- "hidden": true
- },
- {
- "name": "experiment",
- "type": "bool",
- "title": "Enable VTR experimental features (**unstable!**)",
- "value": false,
- "hidden": true
- },
-];
+var settings = main.get_options_object();
+
+main.debug_log("the setting object: ");
+main.debug_log(settings);
function setDefaultPrefs()
{
diff --git a/webextension/options/options.json b/webextension/options/options.json
new file mode 100644
index 0000000..e02eac0
--- /dev/null
+++ b/webextension/options/options.json
@@ -0,0 +1,122 @@
+{
+ "right": {
+ "name": "right",
+ "type": "bool",
+ "title": "Display tabs on the right",
+ "value": false
+ },
+ "hideInFullscreen": {
+ "name": "hideInFullscreen",
+ "type": "bool",
+ "title": "Hide tabs in fullscreen",
+ "value": true
+ },
+ "compact": {
+ "name": "compact",
+ "type": "bool",
+ "title": "Compact Mode (hides text labels)",
+ "value": false
+ },
+ "style.tab.status": {
+ "name": "style.tab.status",
+ "type": "bool",
+ "title": "Show Tab Status on Text Label",
+ "description": "Unloaded: strike-through; Unread/busy: underline",
+ "value": false
+ },
+ "theme": {
+ "name": "theme",
+ "type": "menulist",
+ "title": "Theme",
+ "value": "dark",
+ "options": [
+ {
+ "value": "none",
+ "label": "None / Firefox default"
+ },
+ {
+ "value": "dark",
+ "label": "Dark (recommended)"
+ },
+ {
+ "value": "light",
+ "label": "Light (recommended)"
+ },
+ {
+ "value": "windows",
+ "label": "Windows"
+ },
+ {
+ "value": "darwin",
+ "label": "Darwin"
+ },
+ {
+ "value": "linux",
+ "label": "Linux"
+ }
+ ]
+ },
+ "tabtoolbarPosition": {
+ "name": "tabtoolbarPosition",
+ "type": "menulist",
+ "title": "Toolbar Position",
+ "value": "top",
+ "options": [
+ {
+ "value": "top",
+ "label": "Top"
+ },
+ {
+ "value": "bottom",
+ "label": "Bottom"
+ }
+ ]
+ },
+ "toggleDisplayHotkey": {
+ "name": "toggleDisplayHotkey",
+ "type": "string",
+ "title": "Hotkey for hiding/showing tabbar",
+ "value": "control-alt-v"
+ },
+ "toggleDrawInTitlebar": {
+ "name": "toggleDrawInTitlebar",
+ "type": "control",
+ "title": "Enable/Disable titlebar",
+ "label": "Toggle titlebar",
+ "description": "Enable the titlebar if the window control buttons are overlapping with Firefox elements"
+ },
+ "setDefaultPrefs": {
+ "name": "setDefaultPrefs",
+ "type": "control",
+ "title": "Reset preferences of VTR",
+ "label": "Restore default preferences"
+ },
+ "showHiddenSettings": {
+ "name": "showHiddenSettings",
+ "type": "bool",
+ "title": "Display hidden settings",
+ "value": false,
+ "hidden": true
+ },
+ "width": {
+ "name": "width",
+ "type": "integer",
+ "title": "Width of the tab sidebar",
+ "value": 250,
+ "hidden": true
+ },
+ "debug": {
+ "name": "debug",
+ "type": "bool",
+ "title": "Enable console logging for debugging",
+ "value": false,
+ "hidden": true
+ },
+ "experiment": {
+ "name": "experiment",
+ "type": "bool",
+ "title": "Enable VTR experimental features (**unstable!**)",
+ "value": false,
+ "hidden": true
+ }
+}