Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

Commit

Permalink
Outsource default options JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Croydon committed Apr 30, 2017
1 parent 6dcf9e0 commit 57bca5c
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 139 deletions.
35 changes: 18 additions & 17 deletions webextension/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
});
}

Expand Down Expand Up @@ -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
{
Expand Down
126 changes: 4 additions & 122 deletions webextension/options/options.js
Original file line number Diff line number Diff line change
@@ -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 <b>(**unstable!**)</b>",
"value": false,
"hidden": true
},
];
var settings = main.get_options_object();

main.debug_log("the setting object: ");
main.debug_log(settings);

function setDefaultPrefs()
{
Expand Down
122 changes: 122 additions & 0 deletions webextension/options/options.json
Original file line number Diff line number Diff line change
@@ -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 <b>(**unstable!**)</b>",
"value": false,
"hidden": true
}
}

0 comments on commit 57bca5c

Please sign in to comment.