2017-11-12 22:00:40 +01:00
|
|
|
// Copyright (c) 2017 kroppy. All rights reserved.
|
|
|
|
// Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license
|
|
|
|
// that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/
|
|
|
|
|
|
|
|
// ********** OPTIONS ***************
|
|
|
|
|
2018-01-01 19:50:56 +01:00
|
|
|
var current_theme = "";
|
2017-11-12 22:00:40 +01:00
|
|
|
var themes = [];
|
|
|
|
var SelectedTheme = Object.assign({}, DefaultTheme);
|
|
|
|
var dragged_button;
|
|
|
|
active_group = "tab_list";
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
// options for all drop down menus
|
|
|
|
let DropDownList = ["dbclick_folder", "midclick_folder", "midclick_tab", "dbclick_group", "midclick_group", "dbclick_tab", "append_child_tab", "append_child_tab_after_limit", "append_orphan_tab", "after_closing_active_tab"];
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
document.title = "Tree Tabs";
|
2018-01-01 19:50:56 +01:00
|
|
|
chrome.runtime.sendMessage({command: "get_preferences"}, function(response) {
|
|
|
|
opt = Object.assign({}, response);
|
|
|
|
chrome.storage.local.get(null, function(items) {
|
|
|
|
if (items["themes"]) {
|
|
|
|
for (var themeName in items["themes"]) {
|
|
|
|
themes.push(themeName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (items["current_theme"]) {
|
|
|
|
current_theme = items["current_theme"];
|
|
|
|
LoadTheme(items["current_theme"]);
|
|
|
|
}
|
|
|
|
GetOptions();
|
|
|
|
RefreshFields();
|
|
|
|
SetEvents();
|
2018-03-13 14:39:34 +01:00
|
|
|
AppendGroupToList("tab_list", caption_ungrouped_group, "", false);
|
|
|
|
AppendGroupToList("tab_list2", caption_noname_group, "", false);
|
2018-01-01 19:50:56 +01:00
|
|
|
AppendSampleTabs();
|
|
|
|
});
|
|
|
|
});
|
2017-11-12 22:00:40 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// document events
|
|
|
|
function GetOptions() {
|
|
|
|
// get language labels
|
2018-03-13 14:39:34 +01:00
|
|
|
document.querySelectorAll(".label, .set_button, .bg_opt_drop_down_menu").forEach(function(s){
|
|
|
|
s.textContent = chrome.i18n.getMessage(s.id);
|
|
|
|
});
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
// get language for menu labels
|
2018-03-13 14:39:34 +01:00
|
|
|
document.querySelectorAll(".menu_item").forEach(function(s){
|
|
|
|
s.textContent = chrome.i18n.getMessage("options_example_menu_item");
|
|
|
|
});
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// get checkboxes from saved states
|
2018-03-13 14:39:34 +01:00
|
|
|
document.querySelectorAll(".opt_checkbox").forEach(function(s){
|
|
|
|
s.checked = opt[s.id];
|
|
|
|
if (s.checked) {
|
|
|
|
if (s.id == "never_show_close") {
|
|
|
|
document.getElementById("always_show_close").disabled = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (s.id == "promote_children") {
|
|
|
|
document.getElementById("promote_children_in_first_child").disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
// get language labels
|
|
|
|
document.querySelectorAll(".pick_col, #close_x, #close_hover_x, .options_button_minus, .options_button_plus, .tabs_margin_spacing").forEach(function(s){
|
|
|
|
s.title = chrome.i18n.getMessage(s.id);
|
2017-11-12 22:00:40 +01:00
|
|
|
});
|
2018-03-13 14:39:34 +01:00
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
|
|
|
|
// get options for all drop down menus (loop through all drop down items that are in DropDownList array)
|
|
|
|
for (let i = 0; i < DropDownList.length; i++) {
|
|
|
|
let DropDownOption = document.getElementById(DropDownList[i]);
|
|
|
|
for (let j = 0; j < DropDownOption.options.length; j++) {
|
|
|
|
if (DropDownOption.options[j].value == opt[DropDownList[i]]) {
|
|
|
|
DropDownOption.selectedIndex = j;
|
|
|
|
break;
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get options for tabs tree depth option
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("max_tree_depth").value = opt.max_tree_depth;
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// append themes to dropdown menu
|
2018-03-13 14:39:34 +01:00
|
|
|
let ThemeList = document.getElementById("theme_list");
|
2017-11-12 22:00:40 +01:00
|
|
|
for (var i = 0; i < themes.length; i++) {
|
2018-03-13 14:39:34 +01:00
|
|
|
let theme_name = document.createElement("option");
|
|
|
|
theme_name.value = themes[i];
|
|
|
|
theme_name.text = themes[i];
|
|
|
|
ThemeList.add(theme_name);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
|
|
|
// select current theme in dropdown list
|
2018-03-13 14:39:34 +01:00
|
|
|
for (var i = 0; i < ThemeList.options.length; i++) {
|
|
|
|
if (ThemeList.options[i].value == current_theme) {
|
|
|
|
ThemeList.selectedIndex = i;
|
2017-11-12 22:00:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
function RemovePreview() {
|
2017-11-12 22:00:40 +01:00
|
|
|
if (document.styleSheets[document.styleSheets.length-1].cssRules.length) {
|
|
|
|
document.styleSheets[document.styleSheets.length-1].deleteRule(document.styleSheets[document.styleSheets.length-1].cssRules.length-1);
|
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
document.querySelectorAll(".hover_blinking").forEach(function(s){s.classList.remove("hover_blinking");});
|
|
|
|
document.querySelectorAll(".hover_border_blinking").forEach(function(s){s.classList.remove("hover_border_blinking");});
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// document events
|
|
|
|
function SetEvents() {
|
2018-03-13 14:39:34 +01:00
|
|
|
// --------------------------------DONATIONS-----------------------------------------------------------------------------
|
2018-01-01 19:50:56 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("donate_paypal").onclick = function(event) {if (event.which == 1) {
|
2017-11-12 22:00:40 +01:00
|
|
|
chrome.tabs.create({url: "https://www.paypal.me/KarolJagiello/1"});
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
|
|
|
document.getElementById("donate_litecoin").onclick = function(event) {if (event.which == 1) {
|
|
|
|
copyStringToClipboard("LdQ1ZH1CgSneBbmmVBFrg5BFDFHZMa6h76");
|
|
|
|
alert(chrome.i18n.getMessage("options_copied_wallet_address"));
|
|
|
|
}}
|
|
|
|
document.getElementById("donate_bitcoin").onclick = function(event) {if (event.which == 1) {
|
2017-11-12 22:00:40 +01:00
|
|
|
copyStringToClipboard("19Z8w1RJEcBQpKSdiWa3UTBuKRJUkr96nJ");
|
|
|
|
alert(chrome.i18n.getMessage("options_copied_wallet_address"));
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
|
|
|
document.getElementById("donate_ethereum").onclick = function(event) {if (event.which == 1) {
|
2017-11-12 22:00:40 +01:00
|
|
|
copyStringToClipboard("0x70B05eAD03bF08220d5aF4E1E868C351bfe145D6");
|
|
|
|
alert(chrome.i18n.getMessage("options_copied_wallet_address"));
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// --------------------------------COPY VIVALDI LINK----------------------------------------------------------------------
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("copy_vivaldi_url_for_web_panel").onclick = function(event) {if (event.which == 1) {
|
|
|
|
copyStringToClipboard(chrome.runtime.getURL("sidebar.html"));
|
|
|
|
alert(chrome.i18n.getMessage("options_vivaldi_copied_url"));
|
|
|
|
}}
|
|
|
|
|
|
|
|
// --------------------------------ADD RED AND BLUE PREVIEWS---------------------------------------------------------------
|
|
|
|
// document.body.onmousedown = function(event) {
|
|
|
|
// if (event.which == 1 && (event.target.id || event.target.classList)) {
|
|
|
|
// console.log(event.target);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
document.querySelectorAll(".pick_col, #filter_box_font").forEach(function(s){s.onmouseenter = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": red; }", document.styleSheets[document.styleSheets.length-1].cssRules.length);
|
2018-03-13 14:39:34 +01:00
|
|
|
}});
|
|
|
|
document.querySelectorAll(".font_weight_normal").forEach(function(s){s.onmouseenter = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": normal; }", document.styleSheets[document.styleSheets.length-1].cssRules.length);
|
2018-03-13 14:39:34 +01:00
|
|
|
}});
|
|
|
|
document.querySelectorAll(".font_weight_bold").forEach(function(s){s.onmouseenter = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": bold; }", document.styleSheets[document.styleSheets.length-1].cssRules.length);
|
2018-03-13 14:39:34 +01:00
|
|
|
}});
|
|
|
|
document.querySelectorAll(".font_style_normal").forEach(function(s){s.onmouseenter = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": normal; }", document.styleSheets[document.styleSheets.length-1].cssRules.length);
|
2018-03-13 14:39:34 +01:00
|
|
|
}});
|
|
|
|
document.querySelectorAll(".font_style_italic").forEach(function(s){s.onmouseenter = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": italic; }", document.styleSheets[document.styleSheets.length-1].cssRules.length);
|
2018-03-13 14:39:34 +01:00
|
|
|
}});
|
|
|
|
document.querySelectorAll(".pick_col, .font_weight_normal, .font_weight_bold, .font_style_normal, .font_style_italic, #filter_box_font").forEach(function(s){s.onmouseleave = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
}});
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
|
|
|
|
document.getElementById("group_list_default_font_color").onmouseenter = function(event) {
|
|
|
|
document.getElementById("_gtetab_list").style.color = "red";
|
|
|
|
document.getElementById("_gtetab_list2").style.color = "red";
|
|
|
|
|
|
|
|
}
|
|
|
|
document.getElementById("group_list_default_font_color").onmouseleave = function(event) {
|
|
|
|
document.getElementById("_gtetab_list").style.color = "";
|
|
|
|
document.getElementById("_gtetab_list2").style.color = "";
|
|
|
|
}
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("scrollbar_thumb_hover").onmouseenter = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
document.getElementById("group_scrollbar_thumb").classList.add("hover_blinking");
|
|
|
|
document.getElementById("pin_list_scrollbar_thumb").classList.add("hover_blinking");
|
|
|
|
}
|
|
|
|
document.getElementById("scrollbar_thumb_hover").onmouseleave = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
|
|
|
|
document.getElementById("group_list_button_hover_background").onmouseenter = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
document.getElementById("_tab_list2").classList.add("hover_blinking");
|
|
|
|
}
|
|
|
|
document.getElementById("group_list_button_hover_background").onmouseleave = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("button_hover_background").onmouseenter = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
document.querySelectorAll(".button").forEach(function(s){s.classList.add("hover_blinking");});
|
|
|
|
}
|
|
|
|
document.getElementById("button_hover_background").onmouseleave = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("button_icons_hover").onmouseenter = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
document.querySelectorAll(".button_img").forEach(function(s){s.classList.remove("hover_blinking");});
|
|
|
|
}
|
|
|
|
document.getElementById("button_icons_hover").onmouseleave = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("button_hover_border").onmouseenter = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
document.querySelectorAll(".button").forEach(function(s){s.classList.add("hover_border_blinking");});
|
|
|
|
}
|
|
|
|
document.getElementById("button_hover_border").onmouseleave = function(event) {
|
|
|
|
RemovePreview();
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_width_up").onmouseenter = function(event) {
|
|
|
|
document.getElementById("group_scrollbar").style.backgroundColor = "red";
|
|
|
|
document.getElementById("group_scrollbar_thumb").style.backgroundColor = "red";
|
|
|
|
}
|
|
|
|
document.getElementById("options_tab_list_scrollbar_width_down").onmouseenter = function(event) {
|
|
|
|
document.getElementById("group_scrollbar").style.backgroundColor = "red";
|
|
|
|
document.getElementById("group_scrollbar_thumb").style.backgroundColor = "red";
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_width_up").onmouseleave = function(event) {
|
|
|
|
document.getElementById("group_scrollbar").style.backgroundColor = "";
|
|
|
|
document.getElementById("group_scrollbar_thumb").style.backgroundColor = "";
|
|
|
|
}
|
|
|
|
document.getElementById("options_tab_list_scrollbar_width_down").onmouseleave = function(event) {
|
|
|
|
document.getElementById("group_scrollbar").style.backgroundColor = "";
|
|
|
|
document.getElementById("group_scrollbar_thumb").style.backgroundColor = "";
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_height_up").onmouseenter = function(event) {
|
|
|
|
document.getElementById("pin_list_scrollbar").style.backgroundColor = "red";
|
|
|
|
document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = "red";
|
|
|
|
}
|
|
|
|
document.getElementById("options_tab_list_scrollbar_height_down").onmouseenter = function(event) {
|
|
|
|
document.getElementById("pin_list_scrollbar").style.backgroundColor = "red";
|
|
|
|
document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = "red";
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_height_up").onmouseleave = function(event) {
|
|
|
|
document.getElementById("pin_list_scrollbar").style.backgroundColor = "";
|
|
|
|
document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = "";
|
|
|
|
}
|
|
|
|
document.getElementById("options_tab_list_scrollbar_height_down").onmouseleave = function(event) {
|
|
|
|
document.getElementById("pin_list_scrollbar").style.backgroundColor = "";
|
|
|
|
document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = "";
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------COLOR PICKER---------------------------------------------------------------------
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
// change fonts weight && style
|
|
|
|
document.querySelectorAll(".font_weight_normal, .font_weight_bold, .font_style_normal, .font_style_italic").forEach(function(s){s.onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
event.stopPropagation();
|
2018-03-13 14:39:34 +01:00
|
|
|
// if this.classList.contains("font_weight_normal") || this.classList.contains("font_style_normal")
|
|
|
|
let FontStyle = "normal";
|
|
|
|
if (this.classList.contains("font_weight_bold")) {
|
|
|
|
FontStyle = "bold";
|
|
|
|
}
|
|
|
|
if (this.classList.contains("font_style_italic")) {
|
|
|
|
FontStyle = "italic";
|
|
|
|
}
|
|
|
|
SelectedTheme["ColorsSet"][this.id] = FontStyle;
|
2017-11-12 22:00:40 +01:00
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
}});
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
// show color picker
|
2018-03-13 14:39:34 +01:00
|
|
|
document.querySelectorAll(".pick_col").forEach(function(s){s.onclick = function(event) {if (event.which == 1) {
|
|
|
|
RemovePreview();
|
2017-11-12 22:00:40 +01:00
|
|
|
event.stopPropagation();
|
|
|
|
let bod = document.getElementById("body");
|
|
|
|
let color = window.getComputedStyle(bod, null).getPropertyValue("--"+this.id);
|
2018-03-13 14:39:34 +01:00
|
|
|
let ColorPicker = document.getElementById("color_picker");
|
|
|
|
ColorPicker.setAttribute("PickColor", this.id);
|
|
|
|
ColorPicker.value = color.replace(" ", "");
|
|
|
|
ColorPicker.click();
|
|
|
|
}}});
|
|
|
|
|
|
|
|
document.getElementById("color_picker").oninput = function(event) {
|
|
|
|
let ColorPicker = document.getElementById("color_picker");
|
|
|
|
SelectedTheme["ColorsSet"][this.getAttribute("PickColor")] = ColorPicker.value;
|
2017-11-12 22:00:40 +01:00
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
// SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
}
|
|
|
|
document.getElementById("color_picker").onchange = function(event) {
|
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
// ----------------------------------EVENTS FOR CHECKBOXES AND DROPDOWN MENUS---------------------------------------------
|
2018-03-13 14:39:34 +01:00
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
// set checkbox options on/off and save
|
2018-03-13 14:39:34 +01:00
|
|
|
document.querySelectorAll(".bg_opt").forEach(function(s){s.onclick = function(event) {if (event.which == 1) {
|
|
|
|
opt[this.id] = this.checked ? true : false;
|
|
|
|
if (this.checked) {
|
|
|
|
if (this.id == "never_show_close") {
|
|
|
|
document.getElementById("always_show_close").disabled = true;
|
|
|
|
}
|
|
|
|
if (this.id == "promote_children") {
|
|
|
|
document.getElementById("promote_children_in_first_child").disabled = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this.id == "never_show_close") {
|
|
|
|
document.getElementById("always_show_close").disabled = false;
|
|
|
|
}
|
|
|
|
if (this.id == "promote_children") {
|
|
|
|
document.getElementById("promote_children_in_first_child").disabled = true;
|
|
|
|
}
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
SavePreferences();
|
2018-03-13 14:39:34 +01:00
|
|
|
}}});
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// options that need reload
|
2018-03-13 14:39:34 +01:00
|
|
|
document.onclick = function(event) {if (event.which == 1) {
|
|
|
|
if (event.target.id == "show_toolbar" || event.target.id == "syncro_tabbar_tabs_order" || event.target.id == "allow_pin_close" || event.target.id == "switch_with_scroll" || event.target.id == "always_show_close" || event.target.id == "never_show_close" ||
|
|
|
|
event.target.id == "collapse_other_trees" || event.target.id == "show_counter_tabs" || event.target.id == "show_counter_tabs_hints" || event.target.id == "syncro_tabbar_tabs_order" || event.target.id == "syncro_tabbar_groups_tabs_order" || event.target.id == "groups_toolbar_default") {
|
|
|
|
chrome.runtime.sendMessage({command: "reload_sidebar"});
|
|
|
|
}
|
|
|
|
if (event.target.id == "groups_toolbar_default") {
|
|
|
|
chrome.runtime.sendMessage({command: "reload"});
|
|
|
|
setTimeout(function() {
|
|
|
|
location.reload();
|
|
|
|
}, 300);
|
|
|
|
}
|
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// set dropdown menu options
|
2018-03-13 14:39:34 +01:00
|
|
|
for (let i = 0; i < DropDownList.length; i++) {
|
|
|
|
document.getElementById(DropDownList[i]).onchange = function(event) {
|
|
|
|
console.log(opt[this.id]);
|
|
|
|
console.log(this.value);
|
|
|
|
opt[this.id] = this.value;
|
|
|
|
SavePreferences();
|
|
|
|
chrome.runtime.sendMessage({command: "reload_sidebar"});
|
|
|
|
}
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// set tabs tree depth option
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("max_tree_depth").oninput = function(event) {
|
|
|
|
opt.max_tree_depth = parseInt(this.value);
|
2017-11-12 22:00:40 +01:00
|
|
|
SavePreferences();
|
2018-03-13 14:39:34 +01:00
|
|
|
chrome.runtime.sendMessage({command: "reload_sidebar"});
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// set toolbar on/off and show/hide all toolbar options
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("show_toolbar").onclick = function(event) {if (event.which == 1) {
|
|
|
|
SelectedTheme.ToolbarShow = this.checked ? true : false;
|
|
|
|
RefreshFields();
|
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------OTHER------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// block system dragging
|
2018-03-13 14:39:34 +01:00
|
|
|
document.ondrop = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
event.preventDefault();
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
|
|
|
document.ondragover = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
// ----------------------------RESET TOOLBAR BUTTON-----------------------------------------------------------------------
|
2017-11-12 22:00:40 +01:00
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_reset_toolbar_button").onclick = function(event) {if (event.which == 1) {
|
|
|
|
SetToolbarEvents(true, false, false, "");
|
|
|
|
RemoveToolbarEditEvents();
|
2017-11-12 22:00:40 +01:00
|
|
|
SelectedTheme["toolbar"] = DefaultToolbar;
|
|
|
|
SelectedTheme["unused_buttons"] = "";
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("toolbar").innerHTML = DefaultToolbar;
|
|
|
|
document.getElementById("toolbar_unused_buttons").innerHTML = "";
|
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
document.querySelectorAll(".on").forEach(function(s){s.classList.remove("on");});
|
2017-11-12 22:00:40 +01:00
|
|
|
RefreshGUI();
|
2018-03-13 14:39:34 +01:00
|
|
|
SetToolbarEvents(false, false, true, "click");
|
|
|
|
AddEditToolbarEditEvents();
|
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------THEME BUTTONS--------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// add new theme preset button
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_add_theme_button").onclick = function(event) {if (event.which == 1) {
|
2017-11-12 22:00:40 +01:00
|
|
|
AddNewTheme();
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// remove theme preset button
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_remove_theme_button").onclick = function(event) {if (event.which == 1) {
|
2017-11-12 22:00:40 +01:00
|
|
|
DeleteSelectedTheme();
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// select theme from list
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("theme_list").onchange = function(event) {
|
|
|
|
LoadTheme(this.value, true);
|
|
|
|
chrome.storage.local.set({current_theme: this.value});
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// import theme preset button
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_import_theme_button").onclick = function(event) {if (event.which == 1) {
|
|
|
|
let inputFile = ShowOpenFileDialog("import_theme", ".tt_theme");
|
|
|
|
inputFile.onchange = function(event) {
|
|
|
|
ImportTheme();
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
// export theme preset button
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_export_theme_button").onclick = function(event) {if (event.which == 1) {
|
|
|
|
if (document.getElementById("theme_list").options.length == 0) {
|
2017-11-12 22:00:40 +01:00
|
|
|
alert(chrome.i18n.getMessage("options_no_theme_to_export"));
|
|
|
|
} else {
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveFile(document.getElementById("theme_list").value + ".tt_theme", SelectedTheme);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// rename theme preset button
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_rename_theme_button").onclick = function(event) {if (event.which == 1) {
|
2017-11-12 22:00:40 +01:00
|
|
|
RenameSelectedTheme();
|
2018-03-13 14:39:34 +01:00
|
|
|
}}
|
|
|
|
// get themes
|
|
|
|
document.getElementById("options_share_theme_link").onclick = function(event) {if (event.which == 1) {
|
|
|
|
chrome.tabs.create({url: "https://drive.google.com/drive/folders/0B3jXQpRtOfvSelFrTEVHZEx3Nms?usp=sharing"});
|
|
|
|
}}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------INDENTATION ADJUSTMENT------------------------------------------------------------------
|
|
|
|
|
|
|
|
// change tabs size preset(down)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tabs_indentation_down").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var indentation = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--children_padding_left")).replace("p","").replace("x",""));
|
|
|
|
if (indentation > 0) {
|
|
|
|
indentation--;
|
|
|
|
SelectedTheme["ColorsSet"]["children_padding_left"] = indentation+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// change tabs size preset(up)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tabs_indentation_up").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var indentation = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--children_padding_left")).replace("p","").replace("x",""));
|
|
|
|
if (indentation < 50) {
|
|
|
|
indentation++;
|
|
|
|
SelectedTheme["ColorsSet"]["children_padding_left"] = indentation+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// --------------------------TABS ROUNDNESS ADJUSTMENT--------------------------------------------------------------------
|
|
|
|
|
|
|
|
// change tabs roundness preset(down)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tabs_roundness_down").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--tab_header_border_radius").replace("p","").replace("x","")));
|
|
|
|
if (border_radius > 0) {
|
|
|
|
border_radius--;
|
|
|
|
SelectedTheme["ColorsSet"]["tab_header_border_radius"] = border_radius+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// change tabs roundness preset(up)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tabs_roundness_up").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--tab_header_border_radius")).replace("p","").replace("x",""));
|
|
|
|
if (border_radius < 25) {
|
|
|
|
border_radius++;
|
|
|
|
SelectedTheme["ColorsSet"]["tab_header_border_radius"] = border_radius+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// -------------------------------SIZE ADJUSTMENT-------------------------------------------------------------------------
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
// set tabs margins
|
|
|
|
document.getElementById("tabs_margin_spacing").onchange = function(event) {
|
|
|
|
let size = "0";
|
|
|
|
if (this[1].checked) {
|
|
|
|
size = "1";
|
|
|
|
} else {
|
|
|
|
if (this[2].checked) {
|
|
|
|
size = "2";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SelectedTheme["TabsMargins"] = size;
|
|
|
|
ApplyTabsMargins(size);
|
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 22:00:40 +01:00
|
|
|
// change tabs size preset(down)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tabs_size_down").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
if (SelectedTheme["TabsSizeSetNumber"] > 0) {
|
|
|
|
SelectedTheme["TabsSizeSetNumber"]--;
|
|
|
|
ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// change tabs size preset(up)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tabs_size_up").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
if (SelectedTheme["TabsSizeSetNumber"] < 4) {
|
|
|
|
SelectedTheme["TabsSizeSetNumber"]++;
|
|
|
|
ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------TABS SCROLLBAR SIZE ADJUSTMENT----------------------------------------------------------
|
|
|
|
|
|
|
|
// change tab list scrollbar preset(down)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_width_down").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_width").replace("p","").replace("x","")));
|
|
|
|
if (border_radius > 0) {
|
|
|
|
border_radius--;
|
|
|
|
SelectedTheme["ColorsSet"]["scrollbar_width"] = border_radius+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// change tab list scrollbar preset(up)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_width_up").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_width")).replace("p","").replace("x",""));
|
|
|
|
if (border_radius < 20) {
|
|
|
|
border_radius++;
|
|
|
|
SelectedTheme["ColorsSet"]["scrollbar_width"] = border_radius+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// change pin list scrollbar preset(down)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_height_down").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_height").replace("p","").replace("x","")));
|
|
|
|
if (border_radius > 0) {
|
|
|
|
border_radius--;
|
|
|
|
SelectedTheme["ColorsSet"]["scrollbar_height"] = border_radius+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
// change pin list scrollbar preset(up)
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_tab_list_scrollbar_height_up").onmousedown = function(event) {
|
2017-11-12 22:00:40 +01:00
|
|
|
let bod = document.getElementById("body");
|
|
|
|
var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_height")).replace("p","").replace("x",""));
|
|
|
|
if (border_radius < 20) {
|
|
|
|
border_radius++;
|
|
|
|
SelectedTheme["ColorsSet"]["scrollbar_height"] = border_radius+"px";
|
|
|
|
ApplyColorsSet(SelectedTheme["ColorsSet"]);
|
2018-03-13 14:39:34 +01:00
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
2017-11-12 22:00:40 +01:00
|
|
|
}
|
2018-03-13 14:39:34 +01:00
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------CLEAR DATA BUTTON--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// clear data
|
2018-03-13 14:39:34 +01:00
|
|
|
document.getElementById("options_clear_data").onclick = function(event) {if (event.which == 1) {
|
2018-01-01 19:50:56 +01:00
|
|
|
chrome.storage.local.clear();
|
2017-11-12 22:00:40 +01:00
|
|
|
chrome.runtime.sendMessage({command: "reload"});
|
|
|
|
chrome.runtime.sendMessage({command: "reload_sidebar"});
|
2018-03-13 14:39:34 +01:00
|
|
|
setTimeout(function() {
|
|
|
|
location.reload();
|
|
|
|
}, 300);
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
function RemoveToolbarEditEvents() {
|
|
|
|
document.querySelectorAll("#button_filter_clear").forEach(function(s){
|
|
|
|
s.style.opacity = "0";
|
|
|
|
});
|
|
|
|
document.querySelectorAll(".button").forEach(function(s){
|
|
|
|
s.removeAttribute("draggable");
|
2017-11-12 22:00:40 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-03-13 14:39:34 +01:00
|
|
|
function AddEditToolbarEditEvents() {
|
|
|
|
document.querySelectorAll("#button_filter_clear").forEach(function(s){
|
|
|
|
s.style.opacity = "1";
|
|
|
|
});
|
|
|
|
document.querySelectorAll(".button_img").forEach(function(s){
|
|
|
|
if (s.parentNode.id != "button_filter_type" || s.parentNode.id != "filter_search_go_prev" || s.parentNode.id != "filter_search_go_next") {
|
|
|
|
s.setAttribute("draggable", true);
|
|
|
|
s.onmousedown = function(event) {
|
|
|
|
if (event.which == 1) {
|
|
|
|
dragged_button = document.getElementById(this.parentNode.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.ondragstart = function(event) {
|
|
|
|
event.dataTransfer.setData(" "," ");
|
|
|
|
event.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0);
|
|
|
|
}
|
|
|
|
// move (flip) buttons
|
|
|
|
s.ondragenter = function(event) {
|
|
|
|
if ((dragged_button.id == "button_tools" || dragged_button.id == "button_search" || dragged_button.id == "button_groups" || dragged_button.id == "button_backup" || dragged_button.id == "button_folders") && this.parentNode.parentNode.classList.contains("toolbar_shelf")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let dragged_buttonIndex = Array.from(dragged_button.parentNode.children).indexOf(dragged_button);
|
|
|
|
let Index = Array.from(this.parentNode.parentNode.children).indexOf(this.parentNode);
|
|
|
|
|
|
|
|
if (Index <= dragged_buttonIndex) {
|
|
|
|
this.parentNode.parentNode.insertBefore(dragged_button, this.parentNode);
|
|
|
|
} else {
|
|
|
|
if (this.parentNode.nextSibling != null) {
|
|
|
|
this.parentNode.parentNode.insertBefore(dragged_button, this.parentNode.nextSibling);
|
|
|
|
} else {
|
|
|
|
this.parentNode.parentNode.appendChild(dragged_button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// save toolbar
|
|
|
|
s.ondragend = function(event) {
|
|
|
|
RemoveToolbarEditEvents();
|
|
|
|
|
|
|
|
SelectedTheme.toolbar = document.getElementById("toolbar").innerHTML;
|
|
|
|
SelectedTheme.unused_buttons = document.getElementById("toolbar_unused_buttons").innerHTML;
|
|
|
|
SaveTheme(document.getElementById("theme_list").value);
|
|
|
|
|
|
|
|
AddEditToolbarEditEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll("#toolbar_main, .toolbar_shelf:not(#toolbar_search), #toolbar_unused_buttons").forEach(function(s){s.ondragenter = function(event) {
|
|
|
|
if ((dragged_button.id == "button_tools" || dragged_button.id == "button_search" || dragged_button.id == "button_groups" || dragged_button.id == "button_backup" || dragged_button.id == "button_folders") && this.classList.contains("toolbar_shelf")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dragged_button.parentNode.id != this.id) {
|
|
|
|
this.appendChild(dragged_button);
|
|
|
|
}
|
|
|
|
|
|
|
|
}});
|
|
|
|
}
|
2017-11-12 22:00:40 +01:00
|
|
|
|
|
|
|
function copyStringToClipboard(string) {
|
|
|
|
function handler (event){
|
|
|
|
event.clipboardData.setData('text/plain', string);
|
|
|
|
event.preventDefault();
|
|
|
|
document.removeEventListener('copy', handler, true);
|
|
|
|
}
|
|
|
|
document.addEventListener('copy', handler, true);
|
|
|
|
document.execCommand('copy');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// dummy functions
|
|
|
|
function BindTabsSwitchingToMouseWheel() {}
|
|
|
|
function GetFaviconAndTitle() {}
|
|
|
|
function RefreshMediaIcon() {}
|