diff --git a/..Screenshots/001.png b/..Screenshots/001.png new file mode 100644 index 0000000..470feff Binary files /dev/null and b/..Screenshots/001.png differ diff --git a/..Screenshots/002.png b/..Screenshots/002.png new file mode 100644 index 0000000..caff097 Binary files /dev/null and b/..Screenshots/002.png differ diff --git a/..Screenshots/003.png b/..Screenshots/003.png new file mode 100644 index 0000000..79fdfa9 Binary files /dev/null and b/..Screenshots/003.png differ diff --git a/..Screenshots/004.png b/..Screenshots/004.png new file mode 100644 index 0000000..66eff7d Binary files /dev/null and b/..Screenshots/004.png differ diff --git a/..Screenshots/005.png b/..Screenshots/005.png new file mode 100644 index 0000000..f292a10 Binary files /dev/null and b/..Screenshots/005.png differ diff --git a/..Screenshots/006.png b/..Screenshots/006.png new file mode 100644 index 0000000..4dac8ce Binary files /dev/null and b/..Screenshots/006.png differ diff --git a/Screenshots/Options.png b/..Screenshots/Options.png similarity index 100% rename from Screenshots/Options.png rename to ..Screenshots/Options.png diff --git a/Screenshots/Options_FF.png b/..Screenshots/Options_FF.png similarity index 100% rename from Screenshots/Options_FF.png rename to ..Screenshots/Options_FF.png diff --git a/Screenshots/Options_FF_1.png b/..Screenshots/Options_FF_1.png similarity index 100% rename from Screenshots/Options_FF_1.png rename to ..Screenshots/Options_FF_1.png diff --git a/Screenshots/Options_FF_2.png b/..Screenshots/Options_FF_2.png similarity index 100% rename from Screenshots/Options_FF_2.png rename to ..Screenshots/Options_FF_2.png diff --git a/Screenshots/Options_FF_3.png b/..Screenshots/Options_FF_3.png similarity index 100% rename from Screenshots/Options_FF_3.png rename to ..Screenshots/Options_FF_3.png diff --git a/Screenshots/Options_FF_4.png b/..Screenshots/Options_FF_4.png similarity index 100% rename from Screenshots/Options_FF_4.png rename to ..Screenshots/Options_FF_4.png diff --git a/Screenshots/Options_FF_5.png b/..Screenshots/Options_FF_5.png similarity index 100% rename from Screenshots/Options_FF_5.png rename to ..Screenshots/Options_FF_5.png diff --git a/Screenshots/Sidebar.png b/..Screenshots/Sidebar.png similarity index 100% rename from Screenshots/Sidebar.png rename to ..Screenshots/Sidebar.png diff --git a/..Screenshots/toolbar/F1Search.png b/..Screenshots/toolbar/F1Search.png new file mode 100644 index 0000000..5517132 Binary files /dev/null and b/..Screenshots/toolbar/F1Search.png differ diff --git a/..Screenshots/toolbar/F1Search.psd b/..Screenshots/toolbar/F1Search.psd new file mode 100644 index 0000000..8df84db Binary files /dev/null and b/..Screenshots/toolbar/F1Search.psd differ diff --git a/..Screenshots/toolbar/F2Settings.png b/..Screenshots/toolbar/F2Settings.png new file mode 100644 index 0000000..c3851a2 Binary files /dev/null and b/..Screenshots/toolbar/F2Settings.png differ diff --git a/..Screenshots/toolbar/F2Settings.psd b/..Screenshots/toolbar/F2Settings.psd new file mode 100644 index 0000000..ecc3b06 Binary files /dev/null and b/..Screenshots/toolbar/F2Settings.psd differ diff --git a/..Screenshots/toolbar/F3Groups.png b/..Screenshots/toolbar/F3Groups.png new file mode 100644 index 0000000..b753d3c Binary files /dev/null and b/..Screenshots/toolbar/F3Groups.png differ diff --git a/..Screenshots/toolbar/F3Groups.psd b/..Screenshots/toolbar/F3Groups.psd new file mode 100644 index 0000000..6cbcb93 Binary files /dev/null and b/..Screenshots/toolbar/F3Groups.psd differ diff --git a/..Screenshots/toolbar/F4Sessions.png b/..Screenshots/toolbar/F4Sessions.png new file mode 100644 index 0000000..463756d Binary files /dev/null and b/..Screenshots/toolbar/F4Sessions.png differ diff --git a/..Screenshots/toolbar/F4Sessions.psd b/..Screenshots/toolbar/F4Sessions.psd new file mode 100644 index 0000000..0ada65a Binary files /dev/null and b/..Screenshots/toolbar/F4Sessions.psd differ diff --git a/..Screenshots/toolbar/F5Folders.png b/..Screenshots/toolbar/F5Folders.png new file mode 100644 index 0000000..746dff1 Binary files /dev/null and b/..Screenshots/toolbar/F5Folders.png differ diff --git a/..Screenshots/toolbar/F5Folders.psd b/..Screenshots/toolbar/F5Folders.psd new file mode 100644 index 0000000..af2af97 Binary files /dev/null and b/..Screenshots/toolbar/F5Folders.psd differ diff --git a/TODO.txt b/..TODO/TODO.txt similarity index 84% rename from TODO.txt rename to ..TODO/TODO.txt index 4c3b44e..4e2bdfd 100644 --- a/TODO.txt +++ b/..TODO/TODO.txt @@ -32,6 +32,7 @@ menu: copy urls of the selected tabs menu: bookmark selected tabs/tree menu: select all menu: invert selection +menu: close above/close below options: Customising the context menu diff --git a/Themes/dark by cvvar00.tt_theme b/..Themes/dark by cvvar00.tt_theme similarity index 100% rename from Themes/dark by cvvar00.tt_theme rename to ..Themes/dark by cvvar00.tt_theme diff --git a/Themes/dark by dzodzu.tt_theme b/..Themes/dark by dzodzu.tt_theme similarity index 79% rename from Themes/dark by dzodzu.tt_theme rename to ..Themes/dark by dzodzu.tt_theme index 17c8561..13cf8bd 100644 --- a/Themes/dark by dzodzu.tt_theme +++ b/..Themes/dark by dzodzu.tt_theme @@ -1 +1 @@ -{"ToolbarShow":true,"ColorsSet":{"toolbar_border_bottom":"#909090","attention_background":"#c68100","tab_active_hover_title_font_weight":"bold","tab_title_font_weight":"normal","button_icons":"#bebebe","scrollbar_width":"20px","scrollbar_height":"16px","scrollbar_thumb":"#484848","scrollbar_thumb_hover":"#353535","scrollbar_track":"#3c3c3c","toolbar_background":"#515151","button_border":"#515151","button_background":"#515151","button_hover_border":"#515151","button_hover_background":"#515151","filter_box_background":"#626262","filter_box_border":"#515151","filter_box_font":"#ffffff","filter_clear_icon":"#aeaeae","pin_list_border_bottom":"#0b0b0b","pin_list_background":"#0b0b0b","tab_list_background":"#373737","tab_background":"#484848","tab_border":"#373737","tab_hover_background":"#535353","tab_hover_border":"#535353","tab_selected_background":"#535353","tab_selected_border":"#d8d8d8","tab_selected_hover_border":"#dddddd","tab_selected_hover_background":"#535353","tab_filtered":"#827e00","tab_filtered_highlighted":"#b37400","tab_filtered_selected":"#0f8079","tab_filtered_selected_active":"#1299a9","active_font_weight":"normal","tab_title":"#adadad","tab_title_active":"#cacaca","tab_title_discarded":"#7e7e7e","drag_indicator":"#d8d8d8","close_x":"#c4c4c4","close_hover_x":"#fbfcfe","close_hover_border":"#3f3f3f","close_hover_background":"#3f3f3f","expand_open_border":"#339bf3","expand_open_background":"#b4b4b4","expand_closed_border":"#818181","expand_closed_background":"#b4b4b4","expand_lines":"#9d9d9d","tabs_menu_font":"#333333","tabs_menu_background":"#fafafa","tabs_menu_border":"#bebebe","tabs_menu_hover_background":"#efefef","tabs_menu_hover_border":"#bebebe","tabs_menu_separator":"#efefef","group_list_background":"#0b0b0b","group_list_borders":"#373737","group_list_button_hover_background":"#242424","tab_title_font_color":"#9b9b9b","tab_hover_title_font_color":"#c7c7c7","tab_selected_title_font_color":"#c7c7c7","tab_selected_hover_title_font_color":"#dbdbdb","tab_selected_discarded_background":"#535353","tab_selected_discarded_border":"#d8d8d8","tab_discarded_background":"#444444","tab_discarded_border":"#373737","tab_discarded_hover_background":"#535353","tab_discarded_hover_border":"#535353","tab_selected_discarded_hover_background":"#535353","tab_selected_discarded_hover_border":"#dddddd","button_icons_hover":"#ffffff","tab_title_font_style":"normal","tab_header_border_radius":"3px","tab_filtered_selected_active_highlighted_search_hover_border":"#eafeba","tab_filtered_selected_active_highlighted_search_hover_background":"#8ea303","tab_filtered_border":"#373737","tab_filtered_hover_border":"#c68100","tab_filtered_active_border":"#c68100","tab_filtered_active_hover_border":"#ea9800","tab_hover_title_font_weight":"bold","tab_selected_title_font_weight":"normal","tab_selected_hover_title_font_weight":"bold","tab_active_title_font_weight":"normal","tab_active_background":"#737373","tab_active_title_font_color":"#e2e2e2","tab_active_hover_border":"#737373","tab_active_border":"#373737","tab_active_hover_background":"#737373","tab_active_hover_title_font_color":"#ffffff","tab_active_selected_background":"#737373","tab_active_selected_border":"#dddddd","tab_active_selected_title_font_color":"#dddddd","tab_selected_active_hover_background":"#737373","tab_selected_active_hover_border":"#dddddd","tab_selected_active_hover_title_font_color":"#ffffff","attention_border":"#adadad","tab_discarded_title_font_color":"#a2a2a2","group_list_default_font_color":"#9e9e9e","tab_discarded_title_font_style":"italic","tab_discarded_hover_title_font_color":"#c7c7c7","tab_discarded_hover_title_font_weight":"bold","tab_discarded_hover_title_font_style":"italic","tab_selected_discarded_hover_title_font_color":"#dbdbdb","tab_selected_discarded_hover_title_font_weight":"bold","tab_selected_discarded_title_font_color":"#c7c7c7","expand_hover_background":"#f7f7f7","tab_selected_title_font_style":"normal","tab_selected_hover_title_font_style":"normal","tab_selected_active_hover_title_font_style":"normal","tab_selected_active_hover_title_font_weight":"bold","tab_active_selected_title_font_style":"normal","children_padding_left":"15px","tab_filtered_background":"#c68100","tab_filtered_hover_background":"#c68100","tab_filtered_active_background":"#ea9800","tab_filtered_active_hover_background":"#ea9800","tab_filtered_selected_background":"#c68100","tab_filtered_selected_hover_background":"#c68100","tab_filtered_selected_active_background":"#ea9800","tab_filtered_selected_active_hover_background":"#ea9800","tab_filtered_highlighted_search_background":"#687702","tab_filtered_active_highlighted_search_background":"#8ea303","tab_filtered_selected_highlighted_search_background":"#687702","tab_filtered_selected_active_highlighted_search_background":"#8ea303","tab_filtered_selected_border":"#ffce5b","tab_filtered_selected_active_border":"#ffce5b","tab_filtered_selected_active_hover_border":"#ffce5b","tab_filtered_highlighted_search_border":"#373737","tab_filtered_highlighted_search_hover_border":"#687702","tab_filtered_active_highlighted_search_border":"#8ea303","tab_filtered_active_highlighted_search_hover_border":"#8ea303","tab_filtered_selected_highlighted_search_border":"#eafeba","tab_filtered_selected_highlighted_search_hover_border":"#eafeba","tab_filtered_selected_active_highlighted_search_border":"#eafeba","tab_filtered_selected_hover_border":"#ffce5b","tab_filtered_hover_title_font_weight":"bold","tab_filtered_active_title_font_color":"#ffea97","tab_filtered_active_title_font_weight":"normal","tab_filtered_active_hover_title_font_color":"#fff4ca","tab_filtered_active_hover_title_font_weight":"bold","tab_filtered_selected_title_font_weight":"normal","tab_filtered_active_title_font_style":"normal","tab_hover_title_font_style":"normal","tab_filtered_selected_title_font_style":"normal","tab_filtered_hover_title_font_style":"normal","tab_filtered_active_hover_title_font_style":"normal","tab_filtered_selected_active_hover_title_font_color":"#fff4ca","tab_filtered_active_highlighted_search_hover_title_font_color":"#f5feb8","tab_filtered_selected_active_highlighted_search_hover_title_font_color":"#f5feb8","tab_filtered_selected_active_title_font_color":"#ffea97","tab_filtered_active_highlighted_search_title_font_color":"#ddfb0b","tab_filtered_selected_active_highlighted_search_title_font_color":"#ddfb0b","tab_filtered_hover_title_font_color":"#ffd220","tab_filtered_selected_hover_title_font_style":"normal","tab_filtered_selected_hover_title_font_color":"#ffd220","tab_filtered_selected_hover_title_font_weight":"bold","tab_filtered_selected_active_title_font_weight":"normal","tab_filtered_selected_active_title_font_style":"normal","tab_filtered_selected_active_hover_title_font_style":"normal","tab_filtered_active_highlighted_search_hover_background":"#8ea303","tab_filtered_selected_active_highlighted_search_hover_title_font_style":"normal","tab_filtered_selected_active_highlighted_search_title_font_style":"normal","tab_filtered_selected_highlighted_search_hover_title_font_style":"normal","tab_filtered_selected_highlighted_search_title_font_style":"normal","tab_filtered_selected_highlighted_search_hover_title_font_color":"#cfec04","tab_filtered_selected_highlighted_search_hover_title_font_weight":"bold","tab_filtered_highlighted_search_hover_title_font_color":"#cfec04","tab_filtered_highlighted_search_hover_title_font_weight":"bold","tab_filtered_highlighted_search_hover_background":"#687702","tab_filtered_selected_highlighted_search_hover_background":"#687702","tab_filtered_highlighted_search_title_font_color":"#000000","tab_filtered_active_highlighted_search_title_font_weight":"normal","tab_filtered_active_highlighted_search_hover_title_font_weight":"bold","tab_filtered_selected_highlighted_search_title_font_color":"#000000","tab_filtered_selected_active_highlighted_search_title_font_weight":"normal","tab_filtered_selected_active_highlighted_search_hover_title_font_weight":"bold"},"TabsSizeSetNumber":2,"theme_name":"dark by dzodzu(1)(1)(1)","theme_version":2,"toolbar":"
","unused_buttons":""} \ No newline at end of file +{"ToolbarShow":true,"ColorsSet":{"toolbar_border_bottom":"#909090","attention_background":"#c68100","tab_active_hover_title_font_weight":"bold","tab_title_font_weight":"normal","button_icons":"#bebebe","scrollbar_width":"20px","scrollbar_height":"16px","scrollbar_thumb":"#484848","scrollbar_thumb_hover":"#353535","scrollbar_track":"#3c3c3c","toolbar_background":"#515151","button_border":"#515151","button_background":"#515151","button_hover_border":"#515151","button_hover_background":"#515151","filter_box_background":"#626262","filter_box_border":"#515151","filter_box_font":"#ffffff","filter_clear_icon":"#aeaeae","pin_list_border_bottom":"#0b0b0b","pin_list_background":"#0b0b0b","tab_list_background":"#373737","tab_background":"#484848","tab_border":"#373737","tab_hover_background":"#535353","tab_hover_border":"#535353","tab_selected_background":"#535353","tab_selected_border":"#d8d8d8","tab_selected_hover_border":"#dddddd","tab_selected_hover_background":"#535353","tab_filtered":"#827e00","tab_filtered_highlighted":"#b37400","tab_filtered_selected":"#0f8079","tab_filtered_selected_active":"#1299a9","active_font_weight":"normal","tab_title":"#adadad","tab_title_active":"#cacaca","tab_title_discarded":"#7e7e7e","drag_indicator":"#d8d8d8","close_x":"#c4c4c4","close_hover_x":"#fbfcfe","close_hover_border":"#3f3f3f","close_hover_background":"#3f3f3f","expand_open_border":"#339bf3","expand_open_background":"#b4b4b4","expand_closed_border":"#818181","expand_closed_background":"#b4b4b4","expand_lines":"#9d9d9d","tabs_menu_font":"#333333","tabs_menu_background":"#fafafa","tabs_menu_border":"#bebebe","tabs_menu_hover_background":"#efefef","tabs_menu_hover_border":"#bebebe","tabs_menu_separator":"#efefef","group_list_background":"#0b0b0b","group_list_borders":"#373737","group_list_button_hover_background":"#242424","tab_title_font_color":"#9b9b9b","tab_hover_title_font_color":"#c7c7c7","tab_selected_title_font_color":"#c7c7c7","tab_selected_hover_title_font_color":"#dbdbdb","tab_selected_discarded_background":"#535353","tab_selected_discarded_border":"#d8d8d8","tab_discarded_background":"#444444","tab_discarded_border":"#373737","tab_discarded_hover_background":"#535353","tab_discarded_hover_border":"#535353","tab_selected_discarded_hover_background":"#535353","tab_selected_discarded_hover_border":"#dddddd","button_icons_hover":"#ffffff","tab_title_font_style":"normal","tab_header_border_radius":"3px","tab_filtered_selected_active_highlighted_search_hover_border":"#eafeba","tab_filtered_selected_active_highlighted_search_hover_background":"#8ea303","tab_filtered_border":"#373737","tab_filtered_hover_border":"#c68100","tab_filtered_active_border":"#c68100","tab_filtered_active_hover_border":"#ea9800","tab_hover_title_font_weight":"bold","tab_selected_title_font_weight":"normal","tab_selected_hover_title_font_weight":"bold","tab_active_title_font_weight":"normal","tab_active_background":"#737373","tab_active_title_font_color":"#e2e2e2","tab_active_hover_border":"#737373","tab_active_border":"#373737","tab_active_hover_background":"#737373","tab_active_hover_title_font_color":"#ffffff","tab_active_selected_background":"#737373","tab_active_selected_border":"#dddddd","tab_active_selected_title_font_color":"#dddddd","tab_selected_active_hover_background":"#737373","tab_selected_active_hover_border":"#dddddd","tab_selected_active_hover_title_font_color":"#ffffff","attention_border":"#adadad","tab_discarded_title_font_color":"#a2a2a2","group_list_default_font_color":"#9e9e9e","tab_discarded_title_font_style":"italic","tab_discarded_hover_title_font_color":"#c7c7c7","tab_discarded_hover_title_font_weight":"bold","tab_discarded_hover_title_font_style":"italic","tab_selected_discarded_hover_title_font_color":"#dbdbdb","tab_selected_discarded_hover_title_font_weight":"bold","tab_selected_discarded_title_font_color":"#c7c7c7","expand_hover_background":"#f7f7f7","tab_selected_title_font_style":"normal","tab_selected_hover_title_font_style":"normal","tab_selected_active_hover_title_font_style":"normal","tab_selected_active_hover_title_font_weight":"bold","tab_active_selected_title_font_style":"normal","children_padding_left":"15px","tab_filtered_background":"#c68100","tab_filtered_hover_background":"#c68100","tab_filtered_active_background":"#ea9800","tab_filtered_active_hover_background":"#ea9800","tab_filtered_selected_background":"#c68100","tab_filtered_selected_hover_background":"#c68100","tab_filtered_selected_active_background":"#ea9800","tab_filtered_selected_active_hover_background":"#ea9800","tab_filtered_highlighted_search_background":"#687702","tab_filtered_active_highlighted_search_background":"#8ea303","tab_filtered_selected_highlighted_search_background":"#687702","tab_filtered_selected_active_highlighted_search_background":"#8ea303","tab_filtered_selected_border":"#ffce5b","tab_filtered_selected_active_border":"#ffce5b","tab_filtered_selected_active_hover_border":"#ffce5b","tab_filtered_highlighted_search_border":"#373737","tab_filtered_highlighted_search_hover_border":"#687702","tab_filtered_active_highlighted_search_border":"#8ea303","tab_filtered_active_highlighted_search_hover_border":"#8ea303","tab_filtered_selected_highlighted_search_border":"#eafeba","tab_filtered_selected_highlighted_search_hover_border":"#eafeba","tab_filtered_selected_active_highlighted_search_border":"#eafeba","tab_filtered_selected_hover_border":"#ffce5b","tab_filtered_hover_title_font_weight":"bold","tab_filtered_active_title_font_color":"#ffea97","tab_filtered_active_title_font_weight":"normal","tab_filtered_active_hover_title_font_color":"#fff4ca","tab_filtered_active_hover_title_font_weight":"bold","tab_filtered_selected_title_font_weight":"normal","tab_filtered_active_title_font_style":"normal","tab_hover_title_font_style":"normal","tab_filtered_selected_title_font_style":"normal","tab_filtered_hover_title_font_style":"normal","tab_filtered_active_hover_title_font_style":"normal","tab_filtered_selected_active_hover_title_font_color":"#fff4ca","tab_filtered_active_highlighted_search_hover_title_font_color":"#f5feb8","tab_filtered_selected_active_highlighted_search_hover_title_font_color":"#f5feb8","tab_filtered_selected_active_title_font_color":"#ffea97","tab_filtered_active_highlighted_search_title_font_color":"#ddfb0b","tab_filtered_selected_active_highlighted_search_title_font_color":"#ddfb0b","tab_filtered_hover_title_font_color":"#ffd220","tab_filtered_selected_hover_title_font_style":"normal","tab_filtered_selected_hover_title_font_color":"#ffd220","tab_filtered_selected_hover_title_font_weight":"bold","tab_filtered_selected_active_title_font_weight":"normal","tab_filtered_selected_active_title_font_style":"normal","tab_filtered_selected_active_hover_title_font_style":"normal","tab_filtered_active_highlighted_search_hover_background":"#8ea303","tab_filtered_selected_active_highlighted_search_hover_title_font_style":"normal","tab_filtered_selected_active_highlighted_search_title_font_style":"normal","tab_filtered_selected_highlighted_search_hover_title_font_style":"normal","tab_filtered_selected_highlighted_search_title_font_style":"normal","tab_filtered_selected_highlighted_search_hover_title_font_color":"#cfec04","tab_filtered_selected_highlighted_search_hover_title_font_weight":"bold","tab_filtered_highlighted_search_hover_title_font_color":"#cfec04","tab_filtered_highlighted_search_hover_title_font_weight":"bold","tab_filtered_highlighted_search_hover_background":"#687702","tab_filtered_selected_highlighted_search_hover_background":"#687702","tab_filtered_highlighted_search_title_font_color":"#000000","tab_filtered_active_highlighted_search_title_font_weight":"normal","tab_filtered_active_highlighted_search_hover_title_font_weight":"bold","tab_filtered_selected_highlighted_search_title_font_color":"#000000","tab_filtered_selected_active_highlighted_search_title_font_weight":"normal","tab_filtered_selected_active_highlighted_search_hover_title_font_weight":"bold"},"TabsSizeSetNumber":2,"theme_name":"dark by dzodzu","theme_version":2,"toolbar":"
","unused_buttons":""} \ No newline at end of file diff --git a/Themes/dark by kroppy.tt_theme b/..Themes/dark by kroppy.tt_theme similarity index 100% rename from Themes/dark by kroppy.tt_theme rename to ..Themes/dark by kroppy.tt_theme diff --git a/Themes/dark by kvaps.tt_theme b/..Themes/dark by kvaps.tt_theme similarity index 100% rename from Themes/dark by kvaps.tt_theme rename to ..Themes/dark by kvaps.tt_theme diff --git a/..Themes/dark2 by kroppy.tt_theme b/..Themes/dark2 by kroppy.tt_theme new file mode 100644 index 0000000..619e992 --- /dev/null +++ b/..Themes/dark2 by kroppy.tt_theme @@ -0,0 +1 @@ +{"ToolbarShow":true,"ColorsSet":{"toolbar_border_bottom":"#616161","attention_background":"#3364ac","tab_active_hover_title_font_weight":"bold","tab_title_font_weight":"normal","button_icons":"#9e9e9e","scrollbar_width":"12px","scrollbar_height":"11px","scrollbar_thumb":"#484848","scrollbar_thumb_hover":"#353535","scrollbar_track":"#3c3c3c","toolbar_background":"#484848","button_border":"#484848","button_background":"#484848","button_hover_border":"#353535","button_hover_background":"#353535","filter_box_background":"#3c3c3c","filter_box_border":"#616161","filter_box_font":"#adadad","filter_clear_icon":"#adadad","pin_list_border_bottom":"#616161","pin_list_background":"#3c3c3c","tab_list_background":"#3b3b3b","tab_background":"#484848","tab_border":"#484848","tab_hover_background":"#353535","tab_hover_border":"#353535","tab_selected_background":"#6e6e6e","tab_selected_border":"#6e6e6e","tab_selected_hover_border":"#353535","tab_selected_hover_background":"#353535","tab_filtered":"#827e00","tab_filtered_highlighted":"#b37400","tab_filtered_selected":"#0f8079","tab_filtered_selected_active":"#1299a9","active_font_weight":"normal","tab_title":"#adadad","tab_title_active":"#cacaca","tab_title_discarded":"#7e7e7e","drag_indicator":"#d1d1d1","close_x":"#dddddd","close_hover_x":"#fbfcfe","close_hover_border":"#757676","close_hover_background":"#939394","expand_open_border":"#339bf3","expand_open_background":"#339bf3","expand_closed_border":"#818181","expand_closed_background":"#818181","expand_lines":"#9d9d9d","tabs_menu_font":"#bfbfbf","tabs_menu_background":"#484848","tabs_menu_border":"#616161","tabs_menu_hover_background":"#353535","tabs_menu_hover_border":"#353535","tabs_menu_separator":"#616161","group_list_background":"#3c3c3c","group_list_borders":"#616161","group_list_button_hover_background":"#353535","tab_title_font_color":"#c1c1c1","tab_hover_title_font_color":"#c1c1c1","tab_selected_title_font_color":"#c1c1c1","tab_selected_hover_title_font_color":"#c7c7c7","tab_selected_discarded_background":"#616161","tab_selected_discarded_border":"#616161","tab_discarded_background":"#484848","tab_discarded_border":"#484848","tab_discarded_hover_background":"#353535","tab_discarded_hover_border":"#353535","tab_selected_discarded_hover_background":"#353535","tab_selected_discarded_hover_border":"#353535","button_icons_hover":"#9e9e9e","tab_title_font_style":"normal","tab_header_border_radius":"0px","tab_filtered_selected_active_highlighted_search_hover_border":"#c68100","tab_filtered_selected_active_highlighted_search_hover_background":"#c68100","tab_filtered_border":"#e8e000","tab_filtered_hover_border":"#d2cb00","tab_filtered_active_border":"#d2cb00","tab_filtered_active_hover_border":"#d2cb00","tab_hover_title_font_weight":"normal","tab_selected_title_font_weight":"normal","tab_selected_hover_title_font_weight":"normal","tab_active_title_font_weight":"bold","tab_active_background":"#969696","tab_active_title_font_color":"#ffffff","tab_active_hover_border":"#747474","tab_active_border":"#969696","tab_active_hover_background":"#747474","tab_active_hover_title_font_color":"#f8f8f8","tab_active_selected_background":"#787878","tab_active_selected_border":"#787878","tab_active_selected_title_font_color":"#c1c1c1","tab_selected_active_hover_background":"#353535","tab_selected_active_hover_border":"#353535","tab_selected_active_hover_title_font_color":"#c1c1c1","attention_border":"#3364ac","children_padding_left":"11px","tab_selected_discarded_title_font_color":"#9e9e9e","tab_discarded_hover_title_font_color":"#9e9e9e","tab_filtered_selected_active_hover_border":"#0d6d67","tab_filtered_selected_active_border":"#0f8079","tab_filtered_selected_hover_border":"#0d6d67","tab_filtered_selected_border":"#0f8079","tab_filtered_selected_active_highlighted_search_border":"#ed9900","tab_filtered_selected_highlighted_search_hover_border":"#c68100","tab_filtered_active_highlighted_search_hover_border":"#c68100","tab_filtered_highlighted_search_hover_border":"#c68100","tab_filtered_active_highlighted_search_border":"#ed9900","tab_filtered_highlighted_search_border":"#ed9900","tab_filtered_selected_highlighted_search_border":"#ed9900"},"TabsSizeSetNumber":0,"theme_name":"dark2 by kroppy","theme_version":2,"toolbar":"
","unused_buttons":""} \ No newline at end of file diff --git a/..Themes/dark3 by kroppy.tt_theme b/..Themes/dark3 by kroppy.tt_theme new file mode 100644 index 0000000..1141b16 --- /dev/null +++ b/..Themes/dark3 by kroppy.tt_theme @@ -0,0 +1 @@ +{"ToolbarShow":true,"ColorsSet":{"toolbar_border_bottom":"#616161","attention_background":"#cf4010","tab_active_hover_title_font_weight":"normal","tab_title_font_weight":"normal","button_icons":"#9e9e9e","scrollbar_width":"12px","scrollbar_height":"11px","scrollbar_thumb":"#484848","scrollbar_thumb_hover":"#353535","scrollbar_track":"#3c3c3c","toolbar_background":"#484848","button_border":"#484848","button_background":"#484848","button_hover_border":"#353535","button_hover_background":"#353535","filter_box_background":"#3c3c3c","filter_box_border":"#616161","filter_box_font":"#adadad","filter_clear_icon":"#adadad","pin_list_border_bottom":"#616161","pin_list_background":"#3c3c3c","tab_list_background":"#3b3b3b","tab_background":"#484848","tab_border":"#484848","tab_hover_background":"#353535","tab_hover_border":"#353535","tab_selected_background":"#3f7ebe","tab_selected_border":"#3f7ebe","tab_selected_hover_border":"#356a9f","tab_selected_hover_background":"#356a9f","tab_filtered":"#827e00","tab_filtered_highlighted":"#b37400","tab_filtered_selected":"#0f8079","tab_filtered_selected_active":"#1299a9","active_font_weight":"normal","tab_title":"#adadad","tab_title_active":"#cacaca","tab_title_discarded":"#7e7e7e","drag_indicator":"#d1d1d1","close_x":"#dddddd","close_hover_x":"#fbfcfe","close_hover_border":"#757676","close_hover_background":"#939394","expand_open_border":"#339bf3","expand_open_background":"#339bf3","expand_closed_border":"#818181","expand_closed_background":"#818181","expand_lines":"#9d9d9d","tabs_menu_font":"#bfbfbf","tabs_menu_background":"#484848","tabs_menu_border":"#616161","tabs_menu_hover_background":"#353535","tabs_menu_hover_border":"#353535","tabs_menu_separator":"#616161","group_list_background":"#3c3c3c","group_list_borders":"#616161","group_list_button_hover_background":"#353535","tab_title_font_color":"#c1c1c1","tab_hover_title_font_color":"#c1c1c1","tab_selected_title_font_color":"#c1c1c1","tab_selected_hover_title_font_color":"#c7c7c7","tab_selected_discarded_background":"#2e5c8b","tab_selected_discarded_border":"#2e5c8b","tab_discarded_background":"#484848","tab_discarded_border":"#484848","tab_discarded_hover_background":"#353535","tab_discarded_hover_border":"#353535","tab_selected_discarded_hover_background":"#25496d","tab_selected_discarded_hover_border":"#25496d","button_icons_hover":"#9e9e9e","tab_title_font_style":"normal","tab_header_border_radius":"0px","tab_filtered_selected_active_highlighted_search_hover_border":"#c68100","tab_filtered_selected_active_highlighted_search_hover_background":"#c68100","tab_filtered_border":"#e8e000","tab_filtered_hover_border":"#d2cb00","tab_filtered_active_border":"#d2cb00","tab_filtered_active_hover_border":"#d2cb00","tab_hover_title_font_weight":"normal","tab_selected_title_font_weight":"normal","tab_selected_hover_title_font_weight":"normal","tab_active_title_font_weight":"normal","tab_active_background":"#a0a0a0","tab_active_title_font_color":"#ffffff","tab_active_hover_border":"#747474","tab_active_border":"#969696","tab_active_hover_background":"#747474","tab_active_hover_title_font_color":"#f8f8f8","tab_active_selected_background":"#3f7ebe","tab_active_selected_border":"#3f7ebe","tab_active_selected_title_font_color":"#e8e8e8","tab_selected_active_hover_background":"#356a9f","tab_selected_active_hover_border":"#356a9f","tab_selected_active_hover_title_font_color":"#e8e8e8","attention_border":"#cf4010","children_padding_left":"11px","tab_selected_discarded_title_font_color":"#9e9e9e","tab_discarded_hover_title_font_color":"#9e9e9e","tab_filtered_selected_active_hover_border":"#0d6d67","tab_filtered_selected_active_border":"#0f8079","tab_filtered_selected_hover_border":"#0d6d67","tab_filtered_selected_border":"#0f8079","tab_filtered_selected_active_highlighted_search_border":"#ed9900","tab_filtered_selected_highlighted_search_hover_border":"#c68100","tab_filtered_active_highlighted_search_hover_border":"#c68100","tab_filtered_highlighted_search_hover_border":"#c68100","tab_filtered_active_highlighted_search_border":"#ed9900","tab_filtered_highlighted_search_border":"#ed9900","tab_filtered_selected_highlighted_search_border":"#ed9900","tab_selected_active_hover_title_font_weight":"normal","tab_active_selected_title_font_weight":"normal","tab_filtered_selected_active_hover_title_font_weight":"normal","tab_filtered_selected_active_title_font_weight":"normal","tab_filtered_selected_active_title_font_color":"#cfcfcf","tab_filtered_selected_active_hover_title_font_color":"#cfcfcf","tab_filtered_active_title_font_color":"#919191","tab_filtered_active_hover_title_font_color":"#919191","tab_filtered_active_title_font_weight":"normal","tab_filtered_active_hover_title_font_weight":"normal","group_list_default_font_color":"#b1b1b1"},"TabsSizeSetNumber":0,"theme_name":"dark3 by kroppy","theme_version":2,"toolbar":"
","unused_buttons":""} \ No newline at end of file diff --git a/Themes/legacy by luetage.tt_theme b/..Themes/legacy by luetage.tt_theme similarity index 100% rename from Themes/legacy by luetage.tt_theme rename to ..Themes/legacy by luetage.tt_theme diff --git a/files_ForTesting/background.html b/..files_ForTesting/background.html similarity index 100% rename from files_ForTesting/background.html rename to ..files_ForTesting/background.html diff --git a/files_firefox/manifest.json b/..files_ForTesting/manifest.json similarity index 90% rename from files_firefox/manifest.json rename to ..files_ForTesting/manifest.json index 3f2757a..64c5cec 100644 --- a/files_firefox/manifest.json +++ b/..files_ForTesting/manifest.json @@ -14,7 +14,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "" ], + "permissions": [ "tabs", "sessions", "", "storage" ], "sidebar_action": { "default_icon": { @@ -39,5 +39,5 @@ "page": "options.html", "open_in_tab": true }, - "version": "1.1" + "version": "100" } \ No newline at end of file diff --git a/files_firefox/background.html b/..files_firefox/background.html similarity index 73% rename from files_firefox/background.html rename to ..files_firefox/background.html index faeda18..f1c0516 100644 --- a/files_firefox/background.html +++ b/..files_firefox/background.html @@ -3,6 +3,5 @@ - \ No newline at end of file diff --git a/files_ForTesting/manifest.json b/..files_firefox/manifest.json similarity index 78% rename from files_ForTesting/manifest.json rename to ..files_firefox/manifest.json index cab8a82..46fd2a4 100644 --- a/files_ForTesting/manifest.json +++ b/..files_firefox/manifest.json @@ -14,8 +14,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "" ], - + "permissions": [ "tabs", "sessions", "", "storage" ], "sidebar_action": { "default_icon": { "16": "icons/16.png", @@ -29,6 +28,12 @@ "browser_action": { "default_icon": "icons/24.png" }, + "commands": { + "_execute_browser_action": { + "suggested_key": { "default": "F2" }, + "description": "toggle Tree Tabs" + } + }, "applications": { "gecko": { "id": "TreeTabs@jagiello.it", @@ -39,5 +44,5 @@ "page": "options.html", "open_in_tab": true }, - "version": "0.0.16" + "version": "1.3" } \ No newline at end of file diff --git a/files_opera/background.html b/..files_opera/background.html similarity index 100% rename from files_opera/background.html rename to ..files_opera/background.html diff --git a/files_opera/manifest.json b/..files_opera/manifest.json similarity index 89% rename from files_opera/manifest.json rename to ..files_opera/manifest.json index 744d966..21972c4 100644 --- a/files_opera/manifest.json +++ b/..files_opera/manifest.json @@ -15,7 +15,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "" ], + "permissions": [ "tabs", "sessions", "", "storage" ], "sidebar_action": { "default_icon": { "19": "icons/16.png", diff --git a/files_vivaldi/background.html b/..files_vivaldi/background.html similarity index 100% rename from files_vivaldi/background.html rename to ..files_vivaldi/background.html diff --git a/files_vivaldi/manifest.json b/..files_vivaldi/manifest.json similarity index 86% rename from files_vivaldi/manifest.json rename to ..files_vivaldi/manifest.json index 79d4a1e..7acbade 100644 --- a/files_vivaldi/manifest.json +++ b/..files_vivaldi/manifest.json @@ -14,7 +14,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "" ], + "permissions": [ "tabs", "sessions", "", "storage" ], "options_ui": { "page": "options.html", "open_in_tab": false diff --git a/theme/expand_closed.svg b/..theme/expand_closed.svg similarity index 100% rename from theme/expand_closed.svg rename to ..theme/expand_closed.svg diff --git a/..theme/expand_closed_0.svg b/..theme/expand_closed_0.svg new file mode 100644 index 0000000..76bf299 --- /dev/null +++ b/..theme/expand_closed_0.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/theme/expand_open.svg b/..theme/expand_open.svg similarity index 100% rename from theme/expand_open.svg rename to ..theme/expand_open.svg diff --git a/..theme/expand_open_0.svg b/..theme/expand_open_0.svg new file mode 100644 index 0000000..048cc15 --- /dev/null +++ b/..theme/expand_open_0.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/Themes/dark2 by kroppy.tt_theme b/Themes/dark2 by kroppy.tt_theme deleted file mode 100644 index a18ec8b..0000000 --- a/Themes/dark2 by kroppy.tt_theme +++ /dev/null @@ -1 +0,0 @@ -{"ToolbarShow":true,"ColorsSet":{"toolbar_border_bottom":"#616161","attention_background":"#3364ac","tab_active_hover_title_font_weight":"bold","tab_title_font_weight":"normal","button_icons":"#9e9e9e","scrollbar_width":"12px","scrollbar_height":"11px","scrollbar_thumb":"#484848","scrollbar_thumb_hover":"#353535","scrollbar_track":"#3c3c3c","toolbar_background":"#484848","button_border":"#484848","button_background":"#484848","button_hover_border":"#323232","button_hover_background":"#323232","filter_box_background":"#3c3c3c","filter_box_border":"#616161","filter_box_font":"#adadad","filter_clear_icon":"#adadad","pin_list_border_bottom":"#616161","pin_list_background":"#3c3c3c","tab_list_background":"#404040","tab_background":"#484848","tab_border":"#484848","tab_hover_background":"#353535","tab_hover_border":"#353535","tab_selected_background":"#575757","tab_selected_border":"#575757","tab_selected_hover_border":"#353535","tab_selected_hover_background":"#353535","tab_filtered":"#827e00","tab_filtered_highlighted":"#b37400","tab_filtered_selected":"#0f8079","tab_filtered_selected_active":"#1299a9","active_font_weight":"normal","tab_title":"#adadad","tab_title_active":"#cacaca","tab_title_discarded":"#7e7e7e","drag_indicator":"#d1d1d1","close_x":"#c4c4c4","close_hover_x":"#fbfcfe","close_hover_border":"#757676","close_hover_background":"#939394","expand_open_border":"#339bf3","expand_open_background":"#339bf3","expand_closed_border":"#818181","expand_closed_background":"#818181","expand_lines":"#9d9d9d","tabs_menu_font":"#333333","tabs_menu_background":"#fafafa","tabs_menu_border":"#bebebe","tabs_menu_hover_background":"#efefef","tabs_menu_hover_border":"#bebebe","tabs_menu_separator":"#efefef","group_list_background":"#3c3c3c","group_list_borders":"#616161","group_list_button_hover_background":"#353535","tab_title_font_color":"#c1c1c1","tab_hover_title_font_color":"#c1c1c1","tab_selected_title_font_color":"#c1c1c1","tab_selected_hover_title_font_color":"#c7c7c7","tab_selected_discarded_background":"#535353","tab_selected_discarded_border":"#535353","tab_discarded_background":"#484848","tab_discarded_border":"#484848","tab_discarded_hover_background":"#353535","tab_discarded_hover_border":"#353535","tab_selected_discarded_hover_background":"#353535","tab_selected_discarded_hover_border":"#353535","button_icons_hover":"#9e9e9e","tab_title_font_style":"normal","tab_header_border_radius":"0px","tab_filtered_selected_active_highlighted_search_hover_border":"#c68100","tab_filtered_selected_active_highlighted_search_hover_background":"#c68100","tab_filtered_border":"#e8e000","tab_filtered_hover_border":"#d2cb00","tab_filtered_active_border":"#d2cb00","tab_filtered_active_hover_border":"#d2cb00","tab_hover_title_font_weight":"normal","tab_selected_title_font_weight":"normal","tab_selected_hover_title_font_weight":"normal","tab_active_title_font_weight":"bold","tab_active_background":"#969696","tab_active_title_font_color":"#ffffff","tab_active_hover_border":"#353535","tab_active_border":"#969696","tab_active_hover_background":"#353535","tab_active_hover_title_font_color":"#c1c1c1","tab_active_selected_background":"#787878","tab_active_selected_border":"#787878","tab_active_selected_title_font_color":"#c1c1c1","tab_selected_active_hover_background":"#353535","tab_selected_active_hover_border":"#353535","tab_selected_active_hover_title_font_color":"#c1c1c1","attention_border":"#3364ac","children_padding_left":"11px"},"TabsSizeSetNumber":2,"theme_name":"dark2 by kroppy","theme_version":2,"toolbar":"
","unused_buttons":""} \ No newline at end of file diff --git a/Tree Tabs.zip b/Tree Tabs.zip new file mode 100644 index 0000000..63f01db Binary files /dev/null and b/Tree Tabs.zip differ diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3ae3079..79881a0 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -76,7 +76,7 @@ "message": "Remove group.\nHold shift key to close tabs from this group" }, "button_edit_group": { - "message": "Edit group" + "message": "Rename group" }, "button_import_group": { @@ -109,6 +109,23 @@ }, + "button_folders": { + "message": "Folders" + }, + + "button_new_folder": { + "message": "New folder" + }, + + "button_remove_folder": { + "message": "Remove selected folder/s" + }, + + "button_edit_folder": { + "message": "Rename folder" + }, + + "tabs_menu_expand_all": { @@ -168,6 +185,35 @@ + "folders_menu_new_folder": { + "message": "New folder" + }, + "folders_menu_rename_folder": { + "message": "Rename folder" + }, + "folders_menu_delete": { + "message": "Delete" + }, + + "groups_menu_new_group": { + "message": "New group" + }, + "groups_menu_rename": { + "message": "Rename group" + }, + "groups_menu_delete": { + "message": "Delete group" + }, + "groups_menu_delete_tabs_close": { + "message": "Delete group with tabs" + }, + + "groups_menu_unload": { + "message": "Unload group" + }, + + + @@ -183,49 +229,49 @@ "message": " Pinned tabs bar " }, "options_pin_list_multi_row": { - "message": "multi row list" + "message": "Multi row list" }, "option_allow_pin_close": { - "message": "allow to close pinned tabs" + "message": "Allow to close pinned tabs" }, "options_tabs": { "message": " Tabs " }, "options_syncro_tabbar_tabs_order": { - "message": "synchronise browser tabs order with Tree Tabs, tabs can be unresponsive for a second after drag&drop, but this option is needed for correct ctrl+tab switching" + "message": "Synchronize browser tabs order with Tree Tabs, tabs can be unresponsive for a second after drag&drop. This option is needed for correct ctrl+tab switching" }, "options_switch_with_scroll": { - "message": "switch tabs with mouse wheel" + "message": "Switch tabs with mouse wheel" }, "options_close_with_MMB": { - "message": "close tabs with middle mouse button" + "message": "Close tabs with middle mouse button" }, "options_always_show_close": { - "message": "show close button on all tabs" + "message": "Show close button on all tabs" }, "options_never_show_close": { - "message": "don't show close button (option above will be ignored)" + "message": "Don't show close button (option above will be ignored)" }, "options_close_other_trees": { - "message": "automatically collapse other trees on expand" + "message": "Automatically collapse other trees on expand" }, "options_open_tree_on_hover": { - "message": "auto expand collapsed trees when dragging and holding for a second over them" + "message": "Auto expand collapsed trees when dragging and holding for a second over them" }, "options_promote_children": { - "message": "promote children tabs on close, if disabled, when closing the parent of a tree structure, all tabs will be closed (be careful, because undo close tab will not recover the trees structure)" + "message": "Promote children tabs on close, if disabled, when closing the parent of a tree structure, all tabs will be closed (be careful, because undo close tab will not recover the trees structure)" }, "options_promote_children_in_first_child": { - "message": "promote first child tab as a parent" + "message": "Promote first child tab as a parent" }, "options_skip_load": { - "message": "discard tree structure after browser's restart, this option is for those who don't use browser's session. Basically it disables loading database at startup." + "message": "Discard tree structure after browser's restart, this option is for those who don't use browser's session. Basically it disables loading database at startup." }, "options_append_child_tab": { - "message": "append children tabs at the" + "message": "Append children tabs at the" }, "options_append_child_tab_top": { "message": "top (reverse hierarchy)" @@ -233,9 +279,12 @@ "options_append_child_tab_bottom": { "message": "bottom" }, + "options_append_child_tab_after_active": { + "message": "after active" + }, "options_append_orphan_tab": { - "message": "append orphan tabs (new tabs, tabs opened from shortcuts or from bookmarks)" + "message": "Append orphan tabs (new tabs, tabs opened from shortcuts or from bookmarks)" }, "options_append_orphan_tab_top": { "message": "at the top" @@ -251,7 +300,7 @@ }, "options_after_closing_active_tab": { - "message": "after closing active tab," + "message": "After closing active tab," }, "options_after_closing_active_tab_go_up": { "message": "activate tab above" @@ -259,12 +308,18 @@ "options_after_closing_active_tab_go_down": { "message": "activate tab below" }, + "options_after_closing_active_tab_go_up_seek_in_parent": { + "message": "activate tab above if on the same level" + }, + "options_after_closing_active_tab_go_down_seek_in_parent": { + "message": "activate tab below if on the same level" + }, "options_after_closing_active_tab_go_browser": { - "message": "let browser handle which tab to activate" + "message": "let browser activate tab" }, "options_append_child_tab_after_limit": { - "message": "once reached tree depth, place tab on the same level, but" + "message": "Once reached tree depth, place tab on the same level, but" }, "options_append_child_tab_after_limit_top": { "message": "at the top" @@ -276,17 +331,17 @@ "message": "at the bottom" }, "options_max_tree_drag_drop": { - "message": "limit Drag&Drop to tree's maximum depth as well" + "message": "Limit Drag&Drop to tree's maximum depth as well" }, "options_show_counter_tabs": { - "message": "show children tabs count on tab's title" + "message": "Show children tabs count on tab's title" }, "options_show_counter_tabs_hints": { - "message": "show children tabs count in tab's hint" + "message": "Show children tabs count in tab's hint" }, "options_max_tree_depth": { - "message": "maximum tree depth: set it to -1 for unlimited branches, 0 for flat tabs placement (no trees), any number above 0 will be its maximum" + "message": "Maximum tree depth: set it to -1 for unlimited branches, 0 for flat tabs placement (no trees), any number above 0 will be its maximum" }, @@ -296,11 +351,14 @@ }, "options_show_counter_groups": { - "message": "show tabs count on groups" + "message": "Show tabs count on groups" }, "options_groups_toolbar_default": { - "message": "show groups toolbar in new windows" + "message": "Show groups toolbar in new windows" + }, + "options_syncro_tabbar_groups_tabs_order": { + "message": "Synchronize browser tabs order after drag&drop of the group tabs. Tabs will sort for a long time, if browser has a lot of tabs open. This option is needed for correct ctrl+tab switching" }, @@ -334,6 +392,9 @@ "options_export_theme_button": { "message": "Export" }, + "options_share_theme_link": { + "message": "Get more!" + }, @@ -475,6 +536,12 @@ "message": "Clear search result x button color" }, + "close_x": { + "message": "x inside the close button" + }, + "close_hover_x": { + "message": "x inside the close button on hover" + }, "options_color_pick_hover": { "message": "On hover" }, @@ -587,6 +654,14 @@ }, + "options_development": { + "message": "Development" + }, + "options_debug": { + "message": "Debug" + }, + + @@ -606,10 +681,23 @@ + "folder_edit_button_cancel": { + "message": "Cancel" + }, + + "folder_edit_button_confirm": { + "message": "Ok" + }, + + + + "warning_exporting_big_amount_of_tabs": { + "message": "Importing big amount of tabs can make your browser unresponsive even for hours! Consider dividing your tabs to groups and exporting each group separately." + }, "caption_ungrouped_group": { "message": "Ungrouped" }, diff --git a/background.html b/background.html index a6cc030..c97bdfc 100644 --- a/background.html +++ b/background.html @@ -5,5 +5,4 @@ - \ No newline at end of file diff --git a/bg_ch.js b/bg_ch.js index 5f00dee..3e7d97c 100644 --- a/bg_ch.js +++ b/bg_ch.js @@ -3,112 +3,118 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ if (browserId != "F") { + ConvertLegacyStorage(); LoadPreferences(); + GetCurrentTheme(); ChromeLoadTabs(0); ChromeMessageListeners(); } function ChromeLoadTabs(retry) { chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { - var refTabs = {}; - var tabs_matched = 0; - // load tabs and windows from hdd - var w_count = LoadData("w_count", 0); - var t_count = LoadData("t_count", 0); - var LoadedWindows = LoadData("windows", []); - var LoadedTabs = LoadData("tabs", []); - // if loaded tabs mismatch by 50%, then try to load back - if (LoadedTabs.length < t_count*0.5 || retry > 0) { - LoadedTabs = LoadData("tabs_BAK"+retry, []); - } - // if loaded windows mismatch, then try to load back - if (LoadedWindows.length < w_count || retry > 0) { - LoadedWindows = LoadData("windows_BAK"+retry, []); - } - // CACHED COUNTS - var WinCount = w.length; - var LoadedWinCount = LoadedWindows.length; - var LoadedTabsCount = LoadedTabs.length; - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - if (w[wIndex].tabs[0].url != "chrome://videopopout/") { // this is for opera for their extra video popup, which is weirdly queried as a "normal" window - let winId = w[wIndex].id; - let url1 = w[wIndex].tabs[0].url; - let url2 = w[wIndex].tabs[w[wIndex].tabs.length-1].url; - windows[winId] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; - for (var LwIndex = 0; LwIndex < LoadedWinCount; LwIndex++) { - if (LoadedWindows[LwIndex].url1 == url1 || LoadedWindows[LwIndex].url2 == url2) { - if (LoadedWindows[LwIndex].group_bar) { windows[winId].group_bar = LoadedWindows[LwIndex].group_bar; } - if (LoadedWindows[LwIndex].search_filter) { windows[winId].search_filter = LoadedWindows[LwIndex].search_filter; } - if (LoadedWindows[LwIndex].active_shelf) { windows[winId].active_shelf = LoadedWindows[LwIndex].active_shelf; } - if (LoadedWindows[LwIndex].active_group) { windows[winId].active_group = LoadedWindows[LwIndex].active_group; } - if (Object.keys(LoadedWindows[LwIndex].groups).length > 0) { windows[winId].groups = Object.assign({}, LoadedWindows[LwIndex].groups); } - if (Object.keys(LoadedWindows[LwIndex].folders).length > 0) { windows[winId].folders = Object.assign({}, LoadedWindows[LwIndex].folders); } - LoadedWindows[LwIndex].url1 = ""; - LoadedWindows[LwIndex].url2 = ""; - break; - } - } + chrome.storage.local.get(null, function(storage) { + var refTabs = {}; + var tabs_matched = 0; + // load tabs and windows from storage.local + var w_count = storage.w_count ? storage.w_count : 0; + var t_count = storage.t_count ? storage.t_count : 0; + var LoadedWindows = storage.windows ? storage.windows : []; + var LoadedTabs = storage.tabs ? storage.tabs : []; + // if loaded tabs mismatch by 50%, then try to load back + if (LoadedTabs.length < t_count*0.5 || retry > 0) { + LoadedTabs = storage["tabs_BAK"+retry] ? storage["tabs_BAK"+retry] : []; } - } - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - var TabsCount = w[wIndex].tabs.length; - for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { - ChromeHashURL(w[wIndex].tabs[tabIndex]); + // if loaded windows mismatch, then try to load back + if (LoadedWindows.length < w_count || retry > 0) { + LoadedWindows = storage["windows_BAK"+retry] ? storage["windows_BAK"+retry] : []; } - } - // compare saved tabs from storage to current session tabs, but can be skipped if set in options - if (opt.skip_load == false && LoadedTabs.length > 0) { - // match loaded tabs + // CACHED COUNTS + var WinCount = w.length; + var LoadedWinCount = LoadedWindows.length; + var LoadedTabsCount = LoadedTabs.length; for (var wIndex = 0; wIndex < WinCount; wIndex++) { - var TabsCount = w[wIndex].tabs.length; - for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { - for (var LtabIndex = 0; LtabIndex < LoadedTabsCount; LtabIndex++) { - let tabId = w[wIndex].tabs[tabIndex].id; - if (LoadedTabs[LtabIndex].hash == tabs[tabId].hash && refTabs[LoadedTabs[LtabIndex].id] == undefined) { - refTabs[LoadedTabs[LtabIndex].id] = tabId; - if (LoadedTabs[LtabIndex].parent) { tabs[tabId].parent = LoadedTabs[LtabIndex].parent; } - if (LoadedTabs[LtabIndex].index) { tabs[tabId].index = LoadedTabs[LtabIndex].index; } - if (LoadedTabs[LtabIndex].expand) { tabs[tabId].expand = LoadedTabs[LtabIndex].expand; } - LoadedTabs[LtabIndex].hash = undefined; - tabs_matched++; + if (w[wIndex].tabs[0].url != "chrome://videopopout/") { // this is for opera for their extra video popup, which is weirdly queried as a "normal" window + let winId = w[wIndex].id; + let url1 = w[wIndex].tabs[0].url; + let url2 = w[wIndex].tabs[w[wIndex].tabs.length-1].url; + windows[winId] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; + for (var LwIndex = 0; LwIndex < LoadedWinCount; LwIndex++) { + if (LoadedWindows[LwIndex].url1 == url1 || LoadedWindows[LwIndex].url2 == url2) { + if (LoadedWindows[LwIndex].group_bar) { windows[winId].group_bar = LoadedWindows[LwIndex].group_bar; } + if (LoadedWindows[LwIndex].search_filter) { windows[winId].search_filter = LoadedWindows[LwIndex].search_filter; } + if (LoadedWindows[LwIndex].active_shelf) { windows[winId].active_shelf = LoadedWindows[LwIndex].active_shelf; } + if (LoadedWindows[LwIndex].active_group) { windows[winId].active_group = LoadedWindows[LwIndex].active_group; } + if (Object.keys(LoadedWindows[LwIndex].groups).length > 0) { windows[winId].groups = Object.assign({}, LoadedWindows[LwIndex].groups); } + if (Object.keys(LoadedWindows[LwIndex].folders).length > 0) { windows[winId].folders = Object.assign({}, LoadedWindows[LwIndex].folders); } + LoadedWindows[LwIndex].url1 = ""; + LoadedWindows[LwIndex].url2 = ""; break; } } } } - // replace parents tabIds for new ones, for that purpose refTabs was made before - for (var tabId in tabs) { - if (refTabs[tabs[tabId].parent] != undefined) { - tabs[tabId].parent = refTabs[tabs[tabId].parent]; + for (var wIndex = 0; wIndex < WinCount; wIndex++) { + var TabsCount = w[wIndex].tabs.length; + for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { + ChromeHashURL(w[wIndex].tabs[tabIndex]); } } - } - // replace active tab ids for each group using refTabs - for (var windowId in windows) { - for (var group in windows[windowId].groups) { - if (refTabs[windows[windowId].groups[group].activetab]) { - windows[windowId].groups[group].activetab = refTabs[windows[windowId].groups[group].activetab]; + if (opt.skip_load == false && LoadedTabs.length > 0) { // compare saved tabs from storage to current session tabs, but can be skipped if set in options + for (var wIndex = 0; wIndex < WinCount; wIndex++) { // match loaded tabs + var TabsCount = w[wIndex].tabs.length; + for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { + for (var LtabIndex = 0; LtabIndex < LoadedTabsCount; LtabIndex++) { + let tabId = w[wIndex].tabs[tabIndex].id; + if (LoadedTabs[LtabIndex].hash == tabs[tabId].hash && refTabs[LoadedTabs[LtabIndex].id] == undefined) { + refTabs[LoadedTabs[LtabIndex].id] = tabId; + if (LoadedTabs[LtabIndex].parent) { tabs[tabId].parent = LoadedTabs[LtabIndex].parent; } + if (LoadedTabs[LtabIndex].index) { tabs[tabId].index = LoadedTabs[LtabIndex].index; } + if (LoadedTabs[LtabIndex].expand) { tabs[tabId].expand = LoadedTabs[LtabIndex].expand; } + LoadedTabs[LtabIndex].hash = undefined; + tabs_matched++; + break; + } + } + } + } + // replace parents tabIds for new ones, for that purpose refTabs was made before + for (var tabId in tabs) { + if (refTabs[tabs[tabId].parent] != undefined) { + tabs[tabId].parent = refTabs[tabs[tabId].parent]; + } } } - } - // will try to find tabs for 3 times - if (opt.skip_load == true || retry > 2 || (tabs_matched > t_count*0.5)) { - schedule_save++; - running = true; - ChromeAutoSaveData("", 1000); - ChromeAutoSaveData("_BAK1", 300000); - ChromeAutoSaveData("_BAK2", 600000); - ChromeAutoSaveData("_BAK3", 1800000); - ChromeListeners(); - } else { - setTimeout(function() {ChromeLoadTabs(retry+1);}, 2000); - } + // replace active tab ids for each group using refTabs + for (var windowId in windows) { + for (var group in windows[windowId].groups) { + if (refTabs[windows[windowId].groups[group].active_tab]) { + windows[windowId].groups[group].active_tab = refTabs[windows[windowId].groups[group].active_tab]; + } + } + } + // will try to find tabs for 3 times + if (opt.skip_load == true || retry > 2 || (tabs_matched > t_count*0.5)) { + schedule_save = 1; + running = true; + ChromeAutoSaveData(0, 1000); + ChromeAutoSaveData(1, 300000); + ChromeAutoSaveData(2, 600000); + ChromeAutoSaveData(3, 1800000); + ChromeListeners(); + } else { + setTimeout(function() { + ChromeLoadTabs(retry+1); + }, 2000); + } + }); }); } // You maybe are asking yourself why I save tabs in array? It's because, instead of, keeping 2 index numbers (one for browser tabs on top and one for my index in tree), it's easier to just arrange them in order and save it in localstorage. // Another reason is that Object does not preserve order in chrome, I've been told that in Firefox it is. But I can't trust that. -async function ChromeAutoSaveData(BackupName, LoopTimer) { +async function ChromeAutoSaveData(BAK, LoopTimer) { setInterval(function() { - if (schedule_save > 1 || BackupName != "") {schedule_save = 1;} + if (schedule_save > 1 || BAK > 0) { + schedule_save = 1; + } if (running && schedule_save > 0 && Object.keys(tabs).length > 1) { chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { var WinCount = w.length; @@ -116,17 +122,14 @@ async function ChromeAutoSaveData(BackupName, LoopTimer) { var counter = 0; var Windows = []; var Tabs = []; - for (var wIndex = 0; wIndex < WinCount; wIndex++) { t_count += w[wIndex].tabs.length; } - for (var wIndex = 0; wIndex < WinCount; wIndex++) { let winId = w[wIndex].id; if (windows[winId] != undefined && windows[winId].group_bar != undefined && windows[winId].search_filter != undefined && windows[winId].active_shelf != undefined && windows[winId].active_group != undefined && windows[winId].groups != undefined && windows[winId].folders != undefined) { Windows.push({url1: w[wIndex].tabs[0].url, url2: w[wIndex].tabs[w[wIndex].tabs.length-1].url, group_bar: windows[winId].group_bar, search_filter: windows[winId].search_filter, active_shelf: windows[winId].active_shelf, active_group: windows[winId].active_group, groups: windows[winId].groups, folders: windows[winId].folders}); } - let TabsCount = w[wIndex].tabs.length; for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { let tabId = w[wIndex].tabs[tabIndex].id; @@ -136,10 +139,28 @@ async function ChromeAutoSaveData(BackupName, LoopTimer) { } } if (counter == t_count) { - localStorage["t_count"] = JSON.stringify(t_count); - localStorage["w_count"] = JSON.stringify(WinCount); - localStorage["windows"+BackupName] = JSON.stringify(Windows); - localStorage["tabs"+BackupName] = JSON.stringify(Tabs); + chrome.storage.local.set({t_count: t_count}); + chrome.storage.local.set({w_count: WinCount}); + + if (BAK == 0) { + chrome.storage.local.set({windows: Windows}); + chrome.storage.local.set({tabs: Tabs}); + } + if (BAK == 1) { + chrome.storage.local.set({windows_BAK1: Windows}); + chrome.storage.local.set({tabs_BAK1: Tabs}); + chrome.runtime.sendMessage({command: "backup_available", bak: 1}); + } + if (BAK == 2) { + chrome.storage.local.set({windows_BAK2: Windows}); + chrome.storage.local.set({tabs_BAK2: Tabs}); + chrome.runtime.sendMessage({command: "backup_available", bak: 2}); + } + if (BAK == 3) { + chrome.storage.local.set({windows_BAK3: Windows}); + chrome.storage.local.set({tabs_BAK3: Tabs}); + chrome.runtime.sendMessage({command: "backup_available", bak: 3}); + } } } schedule_save--; @@ -147,53 +168,44 @@ async function ChromeAutoSaveData(BackupName, LoopTimer) { } }, LoopTimer); } -function ChromeHashURL(tab){ +function ChromeHashURL(tab) { if (tabs[tab.id] == undefined) { tabs[tab.id] = {hash: 0, parent: tab.pinned ? "pin_list" : "tab_list", index: tab.index, expand: "n"}; } var hash = 0; - for (var charIndex = 0; charIndex < tab.url.length; charIndex++){ + for (var charIndex = 0; charIndex < tab.url.length; charIndex++) { hash += tab.url.charCodeAt(charIndex); } tabs[tab.id].hash = hash; } - function ReplaceParents(oldTabId, newTabId) { for (var tabId in tabs) { if (tabs[tabId].parent == oldTabId) { tabs[tabId].parent = newTabId; } } - - // TO DO FOLDERS } - -// start all listeners -function ChromeListeners() { +function ChromeListeners() { // start all listeners chrome.tabs.onCreated.addListener(function(tab) { ChromeHashURL(tab); chrome.runtime.sendMessage({command: "tab_created", windowId: tab.windowId, tab: tab, tabId: tab.id}); schedule_save++; }); - chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) { setTimeout(function() { chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: tabId}); },5); delete tabs[tabId]; schedule_save++; }); - chrome.tabs.onAttached.addListener(function(tabId, attachInfo) { chrome.tabs.get(tabId, function(tab) { chrome.runtime.sendMessage({command: "tab_attached", windowId: attachInfo.newWindowId, tab: tab, tabId: tabId, ParentId: tabs[tabId].parent}); }); schedule_save++; }); - chrome.tabs.onDetached.addListener(function(tabId, detachInfo) { chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: tabId}); schedule_save++; }); - chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (tabs[tabId] == undefined || changeInfo.url != undefined) { ChromeHashURL(tab); @@ -209,11 +221,9 @@ function ChromeListeners() { } chrome.runtime.sendMessage({command: "tab_updated", windowId: tab.windowId, tab: tab, tabId: tabId, changeInfo: changeInfo}); }); - chrome.tabs.onMoved.addListener(function(tabId, moveInfo) { schedule_save++; }); - chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) { chrome.tabs.get(addedTabId, function(tab) { if (addedTabId == removedTabId) { @@ -232,35 +242,48 @@ function ChromeListeners() { schedule_save++; }); }); - chrome.tabs.onActivated.addListener(function(activeInfo) { chrome.runtime.sendMessage({command: "tab_activated", windowId: activeInfo.windowId, tabId: activeInfo.tabId}); }); - chrome.windows.onCreated.addListener(function(window) { - windows[window.id] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; + windows[window.id] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; schedule_save++; }); - chrome.windows.onRemoved.addListener(function(windowId) { delete windows[windowId]; schedule_save++; }); - chrome.runtime.onSuspend.addListener(function() { running = false; }); } - function ChromeMessageListeners() { chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + log("message to background: "); + log(message); switch(message.command) { case "reload": window.location.reload(); break; + case "get_preferences": + sendResponse(opt); + break; + case "save_preferences": + opt = Object.assign({}, message.opt); + chrome.storage.local.set({preferences: message.opt}); + break; case "get_windows": sendResponse(windows); break; + case "get_folders": + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].folders); + } + break; + case "save_folders": + windows[message.windowId].folders = Object.assign({}, message.folders); + schedule_save++; + break; case "get_groups": if (windows[message.windowId]) { sendResponse(windows[message.windowId].groups); @@ -270,7 +293,6 @@ function ChromeMessageListeners() { windows[message.windowId].groups = Object.assign({}, message.groups); schedule_save++; break; - case "set_active_group": windows[message.windowId].active_group = message.active_group; schedule_save++; @@ -280,11 +302,6 @@ function ChromeMessageListeners() { sendResponse(windows[message.windowId].active_group); } break; - - - - - case "set_search_filter": windows[message.windowId].search_filter = message.search_filter; schedule_save++; @@ -294,10 +311,6 @@ function ChromeMessageListeners() { sendResponse(windows[message.windowId].search_filter); } break; - - - - case "set_active_shelf": windows[message.windowId].active_shelf = message.active_shelf; schedule_save++; @@ -316,13 +329,13 @@ function ChromeMessageListeners() { sendResponse(windows[message.windowId].group_bar); } break; - case "console_log": - console.log(message.m); - break; + // case "console_log": + // console.log(message.m); + // break; case "get_browser_tabs": sendResponse(tabs); break; - case "is_bg_running": + case "is_bg_ready": sendResponse(running); break; case "update_tab": @@ -334,9 +347,11 @@ function ChromeMessageListeners() { } break; case "get_theme": - let theme = LoadData(("theme"+localStorage["current_theme"]), {"TabsSizeSetNumber": 2, "ToolbarShow": true, "toolbar": DefaultToolbar}); sendResponse(theme); break; + case "reload_theme": + GetCurrentTheme(); + break; } }); -} +} \ No newline at end of file diff --git a/bg_ff.js b/bg_ff.js index a7962c6..2675db5 100644 --- a/bg_ff.js +++ b/bg_ff.js @@ -3,42 +3,29 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ if (browserId == "F") { + ConvertLegacyStorage(); + FirefoxStart(0); LoadPreferences(); - FirefoxStart(); + GetCurrentTheme(); FirefoxMessageListeners(); } - - -function FirefoxStart() { - var SafeToRun = true; - chrome.tabs.query({}, function(t) { - // will loop forever if session restore tab is found - for (var tabIndex = 0; tabIndex < t.length; tabIndex++) { - if (t[tabIndex].url.match("about:sessionrestore") && t.length < 10) { - SafeToRun = false; - chrome.tabs.update(t[tabIndex].id, { active: true }); - } - if (tabIndex == t.length-1) { - if (SafeToRun) { - if (localStorage.getItem("t0") !== null){ - LoadV015(0); - } else { - if (localStorage.getItem("tabs") !== null){ - FirefoxLoadV100(0); - } else { - FirefoxLoadTabs(0); - } - } - } else { - setTimeout(function() { - FirefoxStart(); - }, 1000); - } +function FirefoxStart(retry) { + chrome.windows.getAll({windowTypes: ["normal"], populate: true}, function(w) { + FirefoxLoadTabs(0); + if (w[0].tabs.length == 1 && (w[0].tabs[0].url == "about:blank" || w[0].tabs[0].url == "about:sessionrestore")) { + setTimeout(function() { + FirefoxStart(retry+1); + }, 2000); + } else { + if (retry > 0) { + chrome.runtime.sendMessage({command: "reload_sidebar"}); } + setTimeout(function() { + schedule_save = 0; + }, 2000); } - }); + }); } - function FirefoxLoadTabs(retry) { chrome.windows.getAll({windowTypes: ["normal"], populate: true}, function(w) { var tt_ids = {}; @@ -47,12 +34,10 @@ function FirefoxLoadTabs(retry) { for (var wIndex = 0; wIndex < w.length; wIndex++) { tabs_count += w[wIndex].tabs.length; } - // CACHED COUNTS AND STUFF var lastWinId = w[w.length-1].id; var lastTabId = w[w.length-1].tabs[w[w.length-1].tabs.length-1].id; var WinCount = w.length; - for (var wIndex = 0; wIndex < WinCount; wIndex++) { let winIndex = wIndex; let winId = w[winIndex].id; @@ -60,18 +45,15 @@ function FirefoxLoadTabs(retry) { // LOAD TTID FROM FIREFOX GET WINDOW VALUE let win = Promise.resolve(browser.sessions.getWindowValue(winId, "TTdata")).then(function(WindowData) { - if (opt.skip_load == false && WindowData != undefined) { windows[winId] = Object.assign({}, WindowData); } else { - windows[winId] = {ttid: "", group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, activetab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + windows[winId] = {ttid: "", group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, active_tab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; } - for (var tIndex = 0; tIndex < tabsCount; tIndex++) { let tabIndex = tIndex; let tabId = w[winIndex].tabs[tabIndex].id; let tabPinned = w[winIndex].tabs[tabIndex].pinned; - // LOAD TTID FROM FIREFOX GET TAB VALUE let tab = Promise.resolve(browser.sessions.getTabValue(tabId, "TTdata")).then(function(TabData) { if (opt.skip_load == false && TabData != undefined) { @@ -81,17 +63,16 @@ function FirefoxLoadTabs(retry) { } else { tabs[tabId] = {ttid: "", parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: "n"}; } - // IF ON LAST TAB AND LAST WINDOW, START MATCHING LOADED DATA if (tabId == lastTabId && winId == lastWinId) { for (var ThisSessonWinId in windows) { - if (windows[ThisSessonWinId].ttid == ""){ + if (windows[ThisSessonWinId].ttid == "") { AppendWinTTId(parseInt(ThisSessonWinId)); } } // OK, DONE WITH WINDOWS, START TABS LOOP for (var ThisSessonTabId in tabs) { - if (tabs[ThisSessonTabId].ttid == ""){ + if (tabs[ThisSessonTabId].ttid == "") { AppendTabTTId(parseInt(ThisSessonTabId)); } } @@ -101,28 +82,26 @@ function FirefoxLoadTabs(retry) { tabs[ThisSessonTabId].parent = tt_ids[tabs[ThisSessonTabId].parent_ttid]; } } - // OK, SAME THING FOR ACTIVE TABS IN GROUPS for (var ThisSessonWinId in windows) { for (var group in windows[ThisSessonWinId].groups) { - if (tt_ids[windows[ThisSessonWinId].groups[group].activetab_ttid] != undefined) { - windows[ThisSessonWinId].groups[group].activetab = tt_ids[windows[ThisSessonWinId].groups[group].activetab_ttid]; + if (tt_ids[windows[ThisSessonWinId].groups[group].active_tab_ttid] != undefined) { + windows[ThisSessonWinId].groups[group].active_tab = tt_ids[windows[ThisSessonWinId].groups[group].active_tab_ttid]; } } } - - // TODO - // replace parent tab ids for each folder using reference_tabs, unless tabs will be nested ONLY in tabs and folders ONLY in folders, I did not decide yet - // will try to find tabs for 3 times if (opt.skip_load == true || retry > 2 || (tabs_matched > tabs_count*0.5)) { running = true; + // setInterval(function() { FirefoxAutoSaveData(); + // }, 10000); FirefoxListeners(); } else { - setTimeout(function() {FirefoxLoadTabs(retry+1);}, 2000); + setTimeout(function() { + FirefoxLoadTabs(retry+1); + }, 2000); } - } }); } @@ -130,11 +109,12 @@ function FirefoxLoadTabs(retry) { } }); } - // save every second if there is anything to save obviously async function FirefoxAutoSaveData() { setInterval(function() { - if (schedule_save > 1) {schedule_save = 1;} + if (schedule_save > 1) { + schedule_save = 1; + } if (running && schedule_save > 0 && Object.keys(tabs).length > 1) { chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { var WinCount = w.length; @@ -156,8 +136,7 @@ async function FirefoxAutoSaveData() { } }, 1000); } - -function GenerateNewWindowID(){ +function GenerateNewWindowID() { var newID = "w_"+GenerateRandomID(); var newIdAvailable = true; for (var windowId in windows) { @@ -171,8 +150,7 @@ function GenerateNewWindowID(){ GenerateNewWindowID(); } } - -function GenerateNewTabID(){ +function GenerateNewTabID() { var newID = "t_"+GenerateRandomID(); var newIdAvailable = true; for (var tabId in tabs) { @@ -186,97 +164,85 @@ function GenerateNewTabID(){ GenerateNewTabID(); } } - -function AppendTabTTId(tabId){ +function AppendTabTTId(tabId) { let NewTTTabId = GenerateNewTabID(); if (tabs[tabId] != undefined) { tabs[tabId].ttid = NewTTTabId; } else { tabs[tabId] = {ttid: NewTTTabId, parent: "tab_list", parent_ttid: "", index: 0, expand: "n"}; } - browser.sessions.setTabValue( tabId, "TTdata", tabs[tabId] ); + // if (schedule_save > 0) browser.sessions.setTabValue( tabId, "TTdata", tabs[tabId] ); } -function AppendWinTTId(windowId){ +function AppendWinTTId(windowId) { let NewTTWindowId = GenerateNewWindowID(); if (windows[windowId] != undefined) { windows[windowId].ttid = NewTTWindowId; } else { - windows[windowId] = {ttid: NewTTWindowId, group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, activetab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + windows[windowId] = {ttid: NewTTWindowId, group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, active_tab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; } - browser.sessions.setWindowValue( windowId, "TTdata", windows[windowId] ); + // if (schedule_save > 0) browser.sessions.setWindowValue( windowId, "TTdata", windows[windowId] ); } - function ReplaceParents(oldTabId, newTabId) { for (var tabId in tabs) { if (tabs[tabId].parent == oldTabId) { - console.log("replaced tab id "+oldTabId+" with "+newTabId); tabs[tabId].parent = newTabId; } } - // TO DO FOLDERS } - var DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA = {}; - // start all listeners function FirefoxListeners() { - - // browser.commands.onCommand.addListener(function(command) { - // if (command == "open_sidebar") { - // browser.sidebarAction.setPanel({panel: (browser.extension.getURL("/sidebar.html")) }); - // browser.sidebarAction.open(); - // } - // chrome.windows.getLastFocused({windowTypes: ["normal"]}, function(window) { - // if (CurrentWindowId == window.id) { - // if (command == "open_sidebar") { - // ActivatePrevTab(); - // } - // } - // }); - // }); - browser.browserAction.onClicked.addListener(function() { browser.sidebarAction.setPanel({panel: (browser.extension.getURL("/sidebar.html")) }); browser.sidebarAction.open(); }); - chrome.tabs.onCreated.addListener(function(tab) { - AppendTabTTId(tab.id); + let t = Promise.resolve(browser.sessions.getTabValue(tab.id, "TTdata")).then(function(TabData) { + if (TabData != undefined) { + tabs[tab.id] = Object.assign({}, TabData); + } else { + AppendTabTTId(tab.id); + } + schedule_save++; + }); chrome.runtime.sendMessage({command: "tab_created", windowId: tab.windowId, tab: tab, tabId: tab.id}); schedule_save++; }); - chrome.tabs.onAttached.addListener(function(tabId, attachInfo) { - chrome.tabs.get(tabId, function(tab) { - ReplaceParents(tabId, tab.id); - DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] = tab.id; - tabs[tab.id] = tabs[tabId]; - AppendTabTTId(tab.id); - // let ParentId = DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabs[tabId].parent] ? DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabs[tabId].parent] : tabs[tabId].parent; - // chrome.runtime.sendMessage({command: "tab_attached", windowId: attachInfo.newWindowId, tab: tab, tabId: tabId, ParentId: ParentId}); - chrome.runtime.sendMessage({command: "tab_attached", windowId: attachInfo.newWindowId, tab: tab, tabId: tabId, ParentId: tabs[tabId].parent}); + let oldId = tabId; + chrome.tabs.get(oldId, function(tab) { + ReplaceParents(oldId, tab.id); + tabs[tab.id] = tabs[oldId]; + DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[oldId] = tab.id; + DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tab.id] = oldId; + browser.sessions.setTabValue( tab.id, "TTdata", tabs[oldId] ); + chrome.runtime.sendMessage({command: "tab_attached", windowId: attachInfo.newWindowId, tab: tab, tabId: tab.id, ParentId: tabs[tab.id].parent}); schedule_save++; }); }); chrome.tabs.onDetached.addListener(function(tabId, detachInfo) { - let detachTabId = tabId; + chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: tabId}); + let detachTabId = tabId; if (DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] != undefined) { detachTabId = DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]; - setTimeout(function() { - delete DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]; - },2000); + chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]}); } - chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: detachTabId}); }); chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) { - setTimeout(function() { chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: tabId}); },5); - delete tabs[tabId]; + setTimeout(function() { + if (DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] != undefined) { + chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]}); + } + chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: tabId}); + }, 5); + // setTimeout(function() { + // delete tabs[tabId]; + // },60000); schedule_save++; }); - chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (changeInfo.pinned == true) { tabs[tabId].parent = "pin_list"; @@ -288,7 +254,6 @@ function FirefoxListeners() { } chrome.runtime.sendMessage({command: "tab_updated", windowId: tab.windowId, tab: tab, tabId: tabId, changeInfo: changeInfo}); }); - chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) { chrome.tabs.get(addedTabId, function(tab) { if (addedTabId == removedTabId) { @@ -300,7 +265,7 @@ function FirefoxListeners() { ReplaceParents(tabId, tab.id); chrome.runtime.sendMessage({command: "tab_removed", windowId: tab.windowId, tabId: removedTabId}); chrome.runtime.sendMessage({command: "tab_attached", windowId: tab.windowId, tab: tab, tabId: addedTabId, ParentId: tabs[addedTabId].parent}); - delete tabs[removedTabId]; + // delete tabs[removedTabId]; } setTimeout(function() { AppendTabTTId(addedTabId); @@ -309,31 +274,51 @@ function FirefoxListeners() { }); }); - chrome.tabs.onActivated.addListener(function(activeInfo) { chrome.runtime.sendMessage({command: "tab_activated", windowId: activeInfo.windowId, tabId: activeInfo.tabId}); }); - chrome.windows.onCreated.addListener(function(window) { - AppendWinTTId(window.id); - schedule_save++; + let win = Promise.resolve(browser.sessions.getWindowValue(window.id, "TTdata")).then(function(WindowData) { + if (WindowData != undefined) { + windows[winId] = Object.assign({}, WindowData); + } else { + AppendWinTTId(window.id); + } + schedule_save++; + }); }); - chrome.windows.onRemoved.addListener(function(windowId) { - delete windows[windowId]; + // delete windows[windowId]; schedule_save++; }); } - function FirefoxMessageListeners() { chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + log("message to background: "); + log(message); switch(message.command) { case "reload": window.location.reload(); break; + case "get_preferences": + sendResponse(opt); + break; + case "save_preferences": + opt = Object.assign({}, message.opt); + chrome.storage.local.set({preferences: message.opt}); + break; case "get_windows": sendResponse(windows); break; + case "get_folders": + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].folders); + } + break; + case "save_folders": + windows[message.windowId].folders = Object.assign({}, message.folders); + schedule_save++; + break; case "get_groups": if (windows[message.windowId]) { sendResponse(windows[message.windowId].groups); @@ -342,8 +327,8 @@ function FirefoxMessageListeners() { case "save_groups": windows[message.windowId].groups = Object.assign({}, message.groups); for (var group in windows[message.windowId].groups) { - if (tabs[windows[message.windowId].groups[group].activetab]) { - windows[message.windowId].groups[group].activetab_ttid = tabs[windows[message.windowId].groups[group].activetab].ttid; + if (tabs[windows[message.windowId].groups[group].active_tab]) { + windows[message.windowId].groups[group].active_tab_ttid = tabs[windows[message.windowId].groups[group].active_tab].ttid; } } schedule_save++; @@ -384,13 +369,13 @@ function FirefoxMessageListeners() { sendResponse(windows[message.windowId].group_bar); } break; - case "console_log": - console.log(message.m); - break; + // case "console_log": + // console.log(message.m); + // break; case "get_browser_tabs": sendResponse(tabs); break; - case "is_bg_running": + case "is_bg_ready": sendResponse(running); break; case "update_tab": @@ -413,9 +398,11 @@ function FirefoxMessageListeners() { } break; case "get_theme": - let theme = LoadData(("theme"+localStorage["current_theme"]), {"TabsSizeSetNumber": 2, "ToolbarShow": true, "toolbar": DefaultToolbar}); sendResponse(theme); break; + case "reload_theme": + GetCurrentTheme(); + break; } }); -} +} \ No newline at end of file diff --git a/files_chrome/background.html b/files_chrome/background.html deleted file mode 100644 index 44d782d..0000000 --- a/files_chrome/background.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/files_chrome/bg_ch.js b/files_chrome/bg_ch.js deleted file mode 100644 index 1325714..0000000 --- a/files_chrome/bg_ch.js +++ /dev/null @@ -1,341 +0,0 @@ -// 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/ - -if (localStorage.getItem("t0") !== null){ - LoadV015(0); -} else { - LoadPreferences(); - ChromeLoadTabs(0); - ChromeMessageListeners(); -} - - -function ChromeLoadTabs(retry) { - chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { - - var refTabs = {}; - var tabs_matched = 0; - - // load tabs and windows from hdd - var w_count = LoadData("w_count", 0); - var t_count = LoadData("t_count", 0); - var LoadedWindows = LoadData("windows", []); - var LoadedTabs = LoadData("tabs", []); - - // if loaded tabs mismatch by 50%, then try to load back - if (LoadedTabs.length < t_count*0.5 || retry > 0) { - LoadedTabs = LoadData("tabs_BAK"+retry, []); - } - // if loaded windows mismatch, then try to load back - if (LoadedWindows.length < w_count || retry > 0) { - LoadedWindows = LoadData("windows_BAK"+retry, []); - } - - // CACHED COUNTS - var WinCount = w.length; - var LoadedWinCount = LoadedWindows.length; - var LoadedTabsCount = LoadedTabs.length; - - - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - if (w[wIndex].tabs[0].url != "chrome://videopopout/") { // this is for opera for their extra video popup, which is weirdly queried as a "normal" window - let winId = w[wIndex].id; - let url1 = w[wIndex].tabs[0].url; - let url2 = w[wIndex].tabs[w[wIndex].tabs.length-1].url; - windows[winId] = {group_bar: true, active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; - for (var LwIndex = 0; LwIndex < LoadedWinCount; LwIndex++) { - if (LoadedWindows[LwIndex].url1 == url1 || LoadedWindows[LwIndex].url2 == url2) { - windows[winId].group_bar = LoadedWindows[LwIndex].group_bar; - windows[winId].active_shelf = LoadedWindows[LwIndex].active_shelf; - windows[winId].active_group = LoadedWindows[LwIndex].active_group; - if (Object.keys(LoadedWindows[LwIndex].groups).length > 0) { windows[winId].groups = Object.assign({}, LoadedWindows[LwIndex].groups); } - if (Object.keys(LoadedWindows[LwIndex].folders).length > 0) { windows[winId].folders = Object.assign({}, LoadedWindows[LwIndex].folders); } - LoadedWindows[LwIndex].url1 = ""; - LoadedWindows[LwIndex].url2 = ""; - break; - } - } - } - } - - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - var TabsCount = w[wIndex].tabs.length; - for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { - ChromeHashURL(w[wIndex].tabs[tabIndex]); - } - } - - // compare saved tabs from storage to current session tabs, but can be skipped if set in options - if (opt.skip_load == false && LoadedTabs.length > 0) { - // match loaded tabs - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - var TabsCount = w[wIndex].tabs.length; - for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { - for (var LtabIndex = 0; LtabIndex < LoadedTabsCount; LtabIndex++) { - let tabId = w[wIndex].tabs[tabIndex].id; - if (LoadedTabs[LtabIndex].hash == tabs[tabId].hash && refTabs[LoadedTabs[LtabIndex].id] == undefined) { - refTabs[LoadedTabs[LtabIndex].id] = tabId; - tabs[tabId].parent = LoadedTabs[LtabIndex].parent; - tabs[tabId].index = LoadedTabs[LtabIndex].index; - tabs[tabId].expand = LoadedTabs[LtabIndex].expand; - LoadedTabs[LtabIndex].hash = undefined; - tabs_matched++; - break; - } - } - } - } - - // replace parents tabIds for new ones, for that purpose refTabs was made before - for (var tabId in tabs) { - if (refTabs[tabs[tabId].parent] != undefined) { - tabs[tabId].parent = refTabs[tabs[tabId].parent]; - } - } - } - - - // replace active tab ids for each group using refTabs - for (var windowId in windows) { - for (var group in windows[windowId].groups) { - if (refTabs[windows[windowId].groups[group].activetab]) { - windows[windowId].groups[group].activetab = refTabs[windows[windowId].groups[group].activetab]; - } - } - } - - - - - // will try to find tabs for 3 times - if (opt.skip_load == true || retry > 2 || (tabs_matched > t_count*0.5)) { - schedule_save++; - hold = false; - ChromeAutoSaveData("", 1000); - ChromeAutoSaveData("_BAK1", 300000); - ChromeAutoSaveData("_BAK2", 600000); - ChromeAutoSaveData("_BAK3", 1800000); - ChromeListeners(); - } else { - setTimeout(function() {ChromeLoadTabs(retry+1);}, 2000); - } - }); -} - -// You maybe are asking yourself why I save tabs in array? It's because, instead of, keeping 2 index numbers (one for browser tabs on top and one for my index in tree), it's easier to just arrange them in order and save it in localstorage. -// Another reason is that Object does not preserve order in chrome, I've been told that in Firefox it is. But I can't trust that. -async function ChromeAutoSaveData(BackupName, LoopTimer) { - setTimeout(function() { - ChromeAutoSaveData(BackupName, LoopTimer); - if (schedule_save > 1 || BackupName != "") {schedule_save = 1;} - if (!hold && schedule_save > 0 && Object.keys(tabs).length > 1) { - chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { - var WinCount = w.length; - var t_count = 0; - var counter = 0; - var Windows = []; - var Tabs = []; - - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - t_count += w[wIndex].tabs.length; - } - - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - let winId = w[wIndex].id; - if (windows[winId] != undefined && windows[winId].group_bar != undefined && windows[winId].active_shelf != undefined && windows[winId].active_group != undefined && windows[winId].groups != undefined && windows[winId].folders != undefined) { - Windows.push({url1: w[wIndex].tabs[0].url, url2: w[wIndex].tabs[w[wIndex].tabs.length-1].url, group_bar: windows[winId].group_bar, active_shelf: windows[winId].active_shelf, active_group: windows[winId].active_group, groups: windows[winId].groups, folders: windows[winId].folders}); - } - - let TabsCount = w[wIndex].tabs.length; - for (var tabIndex = 0; tabIndex < TabsCount; tabIndex++) { - let tabId = w[wIndex].tabs[tabIndex].id; - if (tabs[tabId] != undefined && tabs[tabId].hash != undefined && tabs[tabId].parent != undefined && tabs[tabId].index != undefined && tabs[tabId].expand != undefined) { - Tabs.push({id: tabId, hash: tabs[tabId].hash, parent: tabs[tabId].parent, index: tabs[tabId].index, expand: tabs[tabId].expand}); - counter++; - } - } - if (counter == t_count) { - localStorage["t_count"] = JSON.stringify(t_count); - localStorage["w_count"] = JSON.stringify(WinCount); - localStorage["windows"+BackupName] = JSON.stringify(Windows); - localStorage["tabs"+BackupName] = JSON.stringify(Tabs); - } - } - schedule_save--; - }); - } - }, LoopTimer); -} - -function ChromeHashURL(tab){ - if (tabs[tab.id] == undefined) { - tabs[tab.id] = {hash: 0, parent: tab.pinned ? "pin_list" : "tab_list", index: tab.index, expand: "n"}; - } - var hash = 0; - for (var charIndex = 0; charIndex < tab.url.length; charIndex++){ - hash += tab.url.charCodeAt(charIndex); - } - tabs[tab.id].hash = hash; -} - -function ReplaceParents(oldTabId, newTabId) { - for (var tabId in tabs) { - if (tabs[tabId].parent == oldTabId) { - tabs[tabId].parent = newTabId; - } - } - - // TO DO FOLDERS -} - -// start all listeners -function ChromeListeners() { - chrome.tabs.onCreated.addListener(function(tab) { - ChromeHashURL(tab); - chrome.runtime.sendMessage({command: "tab_created", windowId: tab.windowId, tab: tab, tabId: tab.id}); - schedule_save++; - }); - - chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) { - chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: tabId}); - delete tabs[tabId]; - schedule_save++; - }); - - chrome.tabs.onAttached.addListener(function(tabId, attachInfo) { - chrome.tabs.get(tabId, function(tab) { - chrome.runtime.sendMessage({command: "tab_attached", windowId: attachInfo.newWindowId, tab: tab, tabId: tabId, ParentId: tabs[tabId].parent}); - }); - schedule_save++; - }); - - chrome.tabs.onDetached.addListener(function(tabId, detachInfo) { - chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: tabId}); - schedule_save++; - }); - - chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { - if (tabs[tabId] == undefined || changeInfo.url != undefined) { - ChromeHashURL(tab); - } - if (changeInfo.pinned != undefined) { - schedule_save++; - } - if (changeInfo.pinned == true) { - tabs[tabId].parent = "pin_list"; - } - if (changeInfo.title != undefined && !tab.active) { - chrome.runtime.sendMessage({command: "tab_attention", windowId: tab.windowId, tabId: tabId}); - } - chrome.runtime.sendMessage({command: "tab_updated", windowId: tab.windowId, tab: tab, tabId: tabId, changeInfo: changeInfo}); - }); - - chrome.tabs.onMoved.addListener(function(tabId, moveInfo) { - schedule_save++; - }); - - chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) { - chrome.tabs.get(addedTabId, function(tab) { - if (addedTabId == removedTabId) { - chrome.runtime.sendMessage({command: "tab_updated", windowId: tab.windowId, tab: tab, tabId: tab.id, changeInfo: {status: tab.status, url: tab.url, title: tab.title, audible: tab.audible, mutedInfo: tab.mutedInfo}}); - } else { - ReplaceParents(tabId, tab.id); - if (tabs[removedTabId]) { - tabs[addedTabId] = tabs[removedTabId]; - } else { - ChromeHashURL(tab); - } - chrome.runtime.sendMessage({command: "tab_removed", windowId: tab.windowId, tabId: removedTabId}); - chrome.runtime.sendMessage({command: "tab_attached", windowId: tab.windowId, tab: tab, tabId: addedTabId}); - delete tabs[removedTabId]; - } - schedule_save++; - }); - }); - - chrome.tabs.onActivated.addListener(function(activeInfo) { - chrome.runtime.sendMessage({command: "tab_activated", windowId: activeInfo.windowId, tabId: activeInfo.tabId}); - }); - - chrome.windows.onCreated.addListener(function(window) { - windows[window.id] = {group_bar: true, active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; - schedule_save++; - }); - - chrome.windows.onRemoved.addListener(function(windowId) { - delete windows[windowId]; - schedule_save++; - }); - - chrome.runtime.onSuspend.addListener(function() { - hold = true; - }); -} - -function ChromeMessageListeners() { - chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { - switch(message.command) { - case "reload": - window.location.reload(); - break; - case "get_windows": - sendResponse(windows); - break; - case "get_groups": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].groups); - } - break; - case "save_groups": - windows[message.windowId].groups = Object.assign({}, message.groups); - schedule_save++; - break; - - case "set_active_group": - windows[message.windowId].active_group = message.active_group; - schedule_save++; - break; - case "get_active_group": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].active_group); - } - break; - case "set_active_shelf": - windows[message.windowId].active_shelf = message.active_shelf; - schedule_save++; - break; - case "get_active_shelf": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].active_shelf); - } - break; - case "set_group_bar": - windows[message.windowId].group_bar = message.group_bar; - schedule_save++; - break; - case "get_group_bar": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].group_bar); - } - break; - case "console_log": - console.log(message.m); - break; - case "get_browser_tabs": - sendResponse(tabs); - break; - case "is_bg_busy": - sendResponse(hold); - break; - case "update_tab": - if (tabs[message.tabId]) { - for (var parameter in message.tab) { - tabs[message.tabId][parameter] = message.tab[parameter]; - } - schedule_save++; - } - break; - } - }); -} diff --git a/legacy.js b/legacy.js index 1e8714b..b781c36 100644 --- a/legacy.js +++ b/legacy.js @@ -105,8 +105,6 @@ function LoadV015(retry){ }); } - - function FirefoxLoadV100(retry) { chrome.windows.getAll({windowTypes: ["normal"], populate: true}, function(w) { @@ -250,4 +248,100 @@ function FirefoxLoadV100(retry) { }); } }); -} \ No newline at end of file +} + + +function ConvertLegacyStorage() { + if (localStorage.getItem("current_theme") != null || localStorage.getItem("preferences") != null || localStorage.getItem("tabs") != null || localStorage.getItem("windows") != null) { + let current_theme = ""; + if (localStorage.getItem("current_theme") != null) { + current_theme = localStorage["current_theme"]; + } + let LSthemes = []; + if (localStorage.getItem("themes") != null) { + LSthemes = LoadData("themes", []); + } + SLThemes = {}; + LSthemes.forEach(function(themeName) { + let them = LoadData("theme"+themeName, {"TabsSizeSetNumber": 2, "ToolbarShow": true, "toolbar": DefaultToolbar}); + SLThemes[themeName] = them; + }); + + let LSpreferences = Object.assign({}, DefaultPreferences); + if (localStorage.getItem("preferences") != null) { + LSpreferences = LoadData("preferences", {}); + } + + if (browserId != "F") { + let LStabs = {}; + if (localStorage.getItem("tabs") != null) { + LStabs = LoadData("tabs", {}); + } + let LSwindows = {}; + if (localStorage.getItem("windows") != null) { + LSwindows = LoadData("windows", {}); + } + let LStabs_BAK1 = {}; + if (localStorage.getItem("tabs_BAK1") != null) { + LStabs_BAK1 = LoadData("tabs_BAK1", {}); + } + let LStabs_BAK2 = {}; + if (localStorage.getItem("tabs_BAK2") != null) { + LStabs_BAK2 = LoadData("tabs_BAK2", {}); + } + let LStabs_BAK3 = {}; + if (localStorage.getItem("tabs_BAK3") != null) { + LStabs_BAK3 = LoadData("tabs_BAK3", {}); + } + + let LSwindows_BAK1 = {}; + if (localStorage.getItem("windows_BAK1") != null) { + LSwindows_BAK1 = LoadData("windows_BAK1", {}); + } + let LSwindows_BAK2 = {}; + if (localStorage.getItem("windows_BAK2") != null) { + LSwindows_BAK2 = LoadData("windows_BAK2", {}); + } + let LSwindows_BAK3 = {}; + if (localStorage.getItem("windows_BAK3") != null) { + LSwindows_BAK3 = LoadData("windows_BAK3", {}); + } + + + let LSt_count = 0; + if (localStorage.getItem("t_count") != null) { + LSt_count = LoadData("t_count", {}); + } + let LSw_count = 0; + if (localStorage.getItem("w_count") != null) { + LSw_count = LoadData("w_count", {}); + } + chrome.storage.local.set({tabs: LStabs}); + chrome.storage.local.set({windows: LSwindows}); + chrome.storage.local.set({tabs_BAK1: LStabs_BAK1}); + chrome.storage.local.set({tabs_BAK2: LStabs_BAK2}); + chrome.storage.local.set({tabs_BAK3: LStabs_BAK3}); + + chrome.storage.local.set({windows_BAK1: LSwindows_BAK1}); + chrome.storage.local.set({windows_BAK2: LSwindows_BAK2}); + chrome.storage.local.set({windows_BAK3: LSwindows_BAK3}); + chrome.storage.local.set({t_count: LSt_count}); + chrome.storage.local.set({w_count: LSw_count}); + } + chrome.storage.local.set({preferences: LSpreferences}); + chrome.storage.local.set({current_theme: current_theme}); + chrome.storage.local.set({themes: SLThemes}); + localStorage.clear(); + window.location.reload(); + } +} + +function LoadData(KeyName, ExpectReturnDefaultType) { + var data = ExpectReturnDefaultType; + try { + data = JSON.parse(localStorage[KeyName]); + return data; + } catch(e) { + return ExpectReturnDefaultType; + } +} diff --git a/manifest.json b/manifest.json index 3f2757a..7acbade 100644 --- a/manifest.json +++ b/manifest.json @@ -14,30 +14,10 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "" ], - - "sidebar_action": { - "default_icon": { - "16": "icons/16.png", - "19": "icons/16.png", - "38": "icons/38.png" - }, - "default_panel": "sidebar.html", - "default_title": "Tree Tabs", - "browser_style": false - }, - "browser_action": { - "default_icon": "icons/24.png" - }, - "applications": { - "gecko": { - "id": "TreeTabs@jagiello.it", - "strict_min_version": "57.0" - } - }, + "permissions": [ "tabs", "sessions", "", "storage" ], "options_ui": { "page": "options.html", - "open_in_tab": true + "open_in_tab": false }, - "version": "1.1" -} \ No newline at end of file + "version": "1.0" +} diff --git a/options.html b/options.html index 2e98180..9465ff4 100644 --- a/options.html +++ b/options.html @@ -67,6 +67,11 @@ - + + + - + + @@ -151,6 +156,7 @@
  • @@ -167,6 +173,8 @@
  • @@ -194,15 +202,17 @@
    - + - - - - - - + + + + + + +
    +
    @@ -285,7 +295,10 @@
    -
    +
    +
    +
    +
    @@ -356,6 +369,18 @@
    +
    + + + + + + + +
    -
    + +
    + diff --git a/options/options.css b/options/options.css index cdf9fb2..4ac5c07 100644 --- a/options/options.css +++ b/options/options.css @@ -88,11 +88,11 @@ body { overflow: hidden; margin-bottom:15px; } -ul:not(#tabs_menu) { +ul:not(.menu) { padding-left: 22px; } -ul:not(#tabs_menu) li { +ul:not(.menu) li { margin: 5px; } .label { diff --git a/options/options.js b/options/options.js index a89bedf..854135d 100644 --- a/options/options.js +++ b/options/options.js @@ -4,33 +4,37 @@ // ********** OPTIONS *************** +var current_theme = ""; var themes = []; var SelectedTheme = Object.assign({}, DefaultTheme); var dragged_button; active_group = "tab_list"; document.addEventListener("DOMContentLoaded", function() { - LoadPreferences(); document.title = "Tree Tabs"; - - themes = LoadData("themes", []); - if (localStorage.getItem("current_theme") != null) { - LoadTheme(localStorage["current_theme"]); - } - - GetOptions(); - RefreshFields(); - SetEvents(); - SetToolbarShelfToggle("click"); - - AppendGroupToList("tab_list", caption_ungrouped_group, ""); - AppendGroupToList("tab_list2", caption_ungrouped_group, ""); - - AppendSampleTabs(); - + 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(); + SetToolbarShelfToggle("click"); + AppendGroupToList("tab_list", caption_ungrouped_group, ""); + AppendGroupToList("tab_list2", caption_noname_group, ""); + AppendSampleTabs(); + }); + }); }); - // document events function GetOptions() { // get language labels @@ -59,10 +63,10 @@ function GetOptions() { $(this)[0].textContent = chrome.i18n.getMessage(this.id); }); - - - // get language for color pick labels + $("#close_x, #close_hover_x").each(function() { + $(this).attr("title", chrome.i18n.getMessage(this.id)); + }); $(".color_border").each(function() { $(this).attr("title", chrome.i18n.getMessage("options_color_pick_border")); }); @@ -82,9 +86,6 @@ function GetOptions() { $("#filter_clear_icon").each(function() { $(this).attr("title", chrome.i18n.getMessage("options_color_pick_filter_clear_icon")); }); - - - // get options for append child tab for (var i = 0; i < $("#append_child_tab")[0].options.length; i++) { @@ -132,15 +133,13 @@ function GetOptions() { // select current theme in dropdown list for (var i = 0; i < $("#theme_list")[0].options.length; i++) { - if ($("#theme_list")[0].options[i].value == localStorage["current_theme"]) { + if ($("#theme_list")[0].options[i].value == current_theme) { $("#theme_list")[0].selectedIndex = i; break; } } } - - function RemoveRedPreview() { 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); @@ -153,6 +152,10 @@ function SetEvents() { // --------------------------------DONATIONS------------------------------------------------------------------------------ // Donate + $(document).on("click", "#options_share_theme_link", function(event) { + chrome.tabs.create({url: "https://drive.google.com/drive/folders/0B3jXQpRtOfvSelFrTEVHZEx3Nms?usp=sharing"}); + }); + $(document).on("click", "#donate_paypal", function(event) { chrome.tabs.create({url: "https://www.paypal.me/KarolJagiello/1"}); }); @@ -168,8 +171,6 @@ function SetEvents() { }); - - // --------------------------------COPY VIVALDI LINK---------------------------------------------------------------------- $(document).on("click", "#copy_vivaldi_url_for_web_panel", function(event) { @@ -239,7 +240,7 @@ function SetEvents() { -// filter_box_font + // filter_box_font $(document).on("mouseenter", "#options_tab_list_scrollbar_width_up, #options_tab_list_scrollbar_width_down", function(event) { $("#group_scrollbar, #group_scrollbar_thumb").css({ "background-color": "red" }); @@ -279,7 +280,6 @@ function SetEvents() { // show color picker $(document).on("click", ".pick_col", function(event) { RemoveRedPreview(); - // if (event.shiftKey || event.ctrlKey) return; event.stopPropagation(); PickColor = this.id; let bod = document.getElementById("body"); @@ -294,8 +294,6 @@ function SetEvents() { SaveTheme($("#theme_list").val()); }); - - // ----------------------------------EVENTS FOR CHECKBOXES AND DROPDOWN MENUS--------------------------------------------- // set checkbox options on/off and save @@ -305,7 +303,7 @@ function SetEvents() { }); // options that need reload - $(document).on("click", "#syncro_tabbar_tabs_order, #allow_pin_close, #switch_with_scroll, #always_show_close, #never_show_close, #close_other_trees, #show_counter_tabs, #show_counter_tabs_hints", function(event) { + $(document).on("click", "#syncro_tabbar_tabs_order, #allow_pin_close, #switch_with_scroll, #always_show_close, #never_show_close, #close_other_trees, #show_counter_tabs, #show_counter_tabs_hints, #syncro_tabbar_tabs_order, #syncro_tabbar_groups_tabs_order", function(event) { chrome.runtime.sendMessage({command: "reload_sidebar"}); }); @@ -435,8 +433,8 @@ function SetEvents() { // select theme from list $("#theme_list").change(function() { - localStorage["current_theme"] = $(this).val(); LoadTheme($(this).val()); + chrome.storage.local.set({current_theme: $(this).val()}); }); // import theme preset button @@ -462,9 +460,6 @@ function SetEvents() { }); - - - // -------------------------------INDENTATION ADJUSTMENT------------------------------------------------------------------ // change tabs size preset(down) @@ -595,43 +590,13 @@ function SetEvents() { // ----------------------CLEAR DATA BUTTON-------------------------------------------------------------------------------- - // clear data $(document).on("click", "#options_clear_data", function(event) { - localStorage.clear(); + chrome.storage.local.clear(); chrome.runtime.sendMessage({command: "reload"}); chrome.runtime.sendMessage({command: "reload_sidebar"}); location.reload(); }); - - - - -// THIIIIIIIIIIIS IS TO MOVE ICONS FOR SETUP OPTIONS PAGE - - // $(document).bind("contextmenu", function(event) { - // if (event.ctrlKey || event.shiftKey) { - // event.preventDefault(); - // } - // }); - // $(document).on("mousedown", "*", function(event) { - // $(document).on("mousedown", ".pick_col", function(event) { - // event.stopPropagation(); - // if (event.button == 0 && event.shiftKey) { - // $(this).css({ "left": $(this).position().left-1 }); - // } - // if (event.button == 2 && event.shiftKey) { - // $(this).css({ "left": $(this).position().left+1 }); - // } - // if (event.button == 0 && event.ctrlKey) { - // $(this).css({ "top": $(this).position().top-1 }); - // } - // if (event.button == 2 && event.ctrlKey) { - // $(this).css({ "top": $(this).position().top+1 }); - // } - // console.log(this.id + " top: " + $(this).position().top + "px; left: " + $(this).position().left + "px;"); - // console.log(this.id); - // }); } diff --git a/options/refresh.js b/options/refresh.js index 296d83b..0e1f5e7 100644 --- a/options/refresh.js +++ b/options/refresh.js @@ -9,16 +9,12 @@ function RefreshFields() { } else { $("#field_theme").css({"height": ""}); } - if (browserId != "F") { - $("#faster_scroll_for_firefox").hide(); - } if (browserId == "F") { - $("#scrollbar_size_indicator").hide(); + $("#scrollbar_size_indicator, #scrollbar_thumb, #scrollbar_thumb_hover, #scrollbar_track").hide(); } if (browserId == "V") { $("#url_for_web_panel").val(chrome.runtime.getURL("sidebar.html")); $("#url_for_web_panel").prop("readonly", true); - // $("#url_for_web_panel").select(); } else{ $("#field_vivaldi").hide(); } diff --git a/options/sample_tabs.js b/options/sample_tabs.js index ba04a3e..c5441c1 100644 --- a/options/sample_tabs.js +++ b/options/sample_tabs.js @@ -19,26 +19,26 @@ function AppendSampleTabs() { $("#tab_title11")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_hover"); $("#tab_header11").addClass("tab_header_hover").addClass("close_show"); - AppendTab({tab: {id: 12, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "selected"}); + AppendTab({tab: {id: 12, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "selected_tab"}); $("#tab_title12")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_selected"); - AppendTab({tab: {id: 13, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "selected"}); + AppendTab({tab: {id: 13, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "selected_tab"}); $("#tab_title13")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_selected_hover"); $("#tab_header13").addClass("tab_header_hover").addClass("close_show"); $("#close13").addClass("close_hover"); // regular active tabs - AppendTab({tab: {id: 3, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "active"}); + AppendTab({tab: {id: 3, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "active_tab"}); $("#tab_title3")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active"); - AppendTab({tab: {id: 15, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "active"}); + AppendTab({tab: {id: 15, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "active_tab"}); $("#tab_title15")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_hover"); $("#tab_header15").addClass("tab_header_hover"); - AppendTab({tab: {id: 14, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "c selected active"}); + AppendTab({tab: {id: 14, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "c selected_tab active_tab"}); $("#tab_title14")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_selected"); - AppendTab({tab: {id: 16, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "c selected active"}); + AppendTab({tab: {id: 16, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "c selected_tab active_tab"}); $("#tab_title16")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_selected_hover"); $("#tab_header16").addClass("tab_header_hover"); $("#exp16").addClass("hover"); @@ -51,10 +51,10 @@ function AppendSampleTabs() { $("#tab_title17")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_hover"); $("#tab_header17").addClass("tab_header_hover"); - AppendTab({tab: {id: 19, pinned: false, discarded: true}, Append: true, ParentId: "5", AdditionalClass: "selected"}); + AppendTab({tab: {id: 19, pinned: false, discarded: true}, Append: true, ParentId: "5", AdditionalClass: "selected_tab"}); $("#tab_title19")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_selected"); - AppendTab({tab: {id: 20, pinned: false, discarded: true}, Append: true, ParentId: "5", AdditionalClass: "selected"}); + AppendTab({tab: {id: 20, pinned: false, discarded: true}, Append: true, ParentId: "5", AdditionalClass: "selected_tab"}); $("#tab_title20")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_selected_hover"); $("#tab_header20").addClass("tab_header_hover"); @@ -66,27 +66,27 @@ function AppendSampleTabs() { $("#tab_title21")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_hover"); $("#tab_header21").addClass("tab_header_hover"); - AppendTab({tab: {id: 22, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered active"}); + AppendTab({tab: {id: 22, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered active_tab"}); $("#tab_title22")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_active"); - AppendTab({tab: {id: 23, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered active"}); + AppendTab({tab: {id: 23, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered active_tab"}); $("#tab_title23")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_active_hover"); $("#tab_header23").addClass("tab_header_hover"); // search result selected - AppendTab({tab: {id: 8, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected filtered"}); + AppendTab({tab: {id: 8, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered"}); $("#tab_title8")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected"); - AppendTab({tab: {id: 18, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected filtered"}); + AppendTab({tab: {id: 18, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered"}); $("#tab_title18")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_hover"); $("#tab_header18").addClass("tab_header_hover"); - AppendTab({tab: {id: 25, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected filtered active"}); + AppendTab({tab: {id: 25, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered active_tab"}); $("#tab_title25")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_active"); - AppendTab({tab: {id: 26, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected filtered active"}); + AppendTab({tab: {id: 26, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered active_tab"}); $("#tab_title26")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_active_hover"); $("#tab_header26").addClass("tab_header_hover"); @@ -98,25 +98,25 @@ function AppendSampleTabs() { $("#tab_title31")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_hover"); $("#tab_header31").addClass("tab_header_hover"); - AppendTab({tab: {id: 32, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search active"}); + AppendTab({tab: {id: 32, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search active_tab"}); $("#tab_title32")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_active"); - AppendTab({tab: {id: 33, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search active"}); + AppendTab({tab: {id: 33, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search active_tab"}); $("#tab_title33")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_active_hover"); $("#tab_header33").addClass("tab_header_hover"); - AppendTab({tab: {id: 34, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected filtered highlighted_search"}); + AppendTab({tab: {id: 34, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search"}); $("#tab_title34")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected"); - AppendTab({tab: {id: 35, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected filtered highlighted_search"}); + AppendTab({tab: {id: 35, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search"}); $("#tab_title35")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_hover"); $("#tab_header35").addClass("tab_header_hover"); - AppendTab({tab: {id: 36, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected filtered highlighted_search active"}); + AppendTab({tab: {id: 36, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search active_tab"}); $("#tab_title36")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_active"); - AppendTab({tab: {id: 37, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected filtered highlighted_search active"}); + AppendTab({tab: {id: 37, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search active_tab"}); $("#tab_title37")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_active_hover"); $("#tab_header37").addClass("tab_header_hover"); diff --git a/options/theme.js b/options/theme.js index 65ce189..e4c977e 100644 --- a/options/theme.js +++ b/options/theme.js @@ -3,115 +3,118 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ function LoadTheme(themeName) { - if (localStorage.getItem("theme"+themeName) != null) { - SelectedTheme = JSON.parse(localStorage["theme"+themeName]); - $("#new_theme_name")[0].value = themeName; + chrome.storage.local.get(null, function(items) { + if (items.themes[themeName]) { + SelectedTheme = Object.assign({}, items.themes[themeName]); + current_theme = themeName; + } else { + SelectedTheme = Object.assign({}, DefaultTheme); + current_theme = ""; + } setTimeout(function() { - ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]); - ApplyColorsSet(SelectedTheme["ColorsSet"]); - ApplySizeOptionsSet(SelectedTheme["TabsSizeSetNumber"]); - - $("#toolbar").html(SelectedTheme.toolbar); - $("#toolbar_unused_buttons").html(SelectedTheme.unused_buttons); - - if (browserId == "F") { - $(".button#button_load_bak1, .button#button_load_bak2, .button#button_load_bak3").remove(); - } - // expand toolbar options - SelectedTheme.ToolbarShow = $("#show_toolbar")[0].checked = SelectedTheme.ToolbarShow; - $("#field_show_toolbar").css({"height": $("#show_toolbar")[0].checked ? "" : "6"}); - SelectedTheme.ToolbarShow ? $("#options_available_buttons, #toolbar, #toolbar_colors").show() : $("#options_available_buttons, #toolbar, #toolbar_colors").hide(); - - $(".on").removeClass("on"); - RefreshGUI(); - - chrome.runtime.sendMessage({command: "reload_theme", themeName: "theme"+themeName}); + $("#new_theme_name")[0].value = themeName; + setTimeout(function() { + ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]); + ApplyColorsSet(SelectedTheme["ColorsSet"]); + ApplySizeOptionsSet(SelectedTheme["TabsSizeSetNumber"]); + $("#toolbar").html(SelectedTheme.toolbar); + $("#toolbar_unused_buttons").html(SelectedTheme.unused_buttons); + if (browserId == "F") { + $(".button#button_load_bak1, .button#button_load_bak2, .button#button_load_bak3").remove(); + } + SelectedTheme.ToolbarShow = $("#show_toolbar")[0].checked = SelectedTheme.ToolbarShow; + $("#field_show_toolbar").css({"height": $("#show_toolbar")[0].checked ? "" : "6"}); + SelectedTheme.ToolbarShow ? $("#options_available_buttons, #toolbar, #toolbar_colors").show() : $("#options_available_buttons, #toolbar, #toolbar_colors").hide(); + $(".on").removeClass("on"); + RefreshGUI(); + chrome.runtime.sendMessage({command: "reload_theme", themeName: "theme"+themeName}); + }, 200); }, 200); - } + }); } - function SaveTheme(themeName) { - localStorage["theme"+themeName] = JSON.stringify(SelectedTheme); - chrome.runtime.sendMessage({command: "reload_theme", themeName: "theme"+themeName}); - return SelectedTheme; + chrome.storage.local.get(null, function(items) { + let LSthemes = items.themes ? Object.assign({}, items.themes) : {}; + LSthemes[themeName] = Object.assign({}, SelectedTheme); + chrome.storage.local.set({themes: LSthemes}); + chrome.runtime.sendMessage({command: "reload_theme", themeName: "theme"+themeName}); + return SelectedTheme; + }); } - function AddNewTheme() { if (themes.indexOf($("#new_theme_name")[0].value) != -1) { alert(chrome.i18n.getMessage("options_there_is_a_theme_with_this_name")); return; } - if ($("#new_theme_name")[0].value == "") { alert(chrome.i18n.getMessage("options_theme_name_cannot_be_empty")); return; } - $("#toolbar").html(DefaultToolbar); SelectedTheme = Object.assign({}, DefaultTheme); SelectedTheme["ColorsSet"] = {}; DefaultTheme["ColorsSet"] = {}; - themes.push($("#new_theme_name")[0].value); var t_list = document.getElementById("theme_list"); var theme_name = document.createElement("option"); theme_name.value = $("#new_theme_name")[0].value; theme_name.text = theme_name.value; t_list.add(theme_name); - $("#theme_list")[0].selectedIndex = $("#theme_list")[0].options.length-1; SaveTheme(theme_name.value); - LoadTheme(theme_name.value); - - localStorage["themes"] = JSON.stringify(themes); - localStorage["current_theme"] = $("#theme_list").val(); + setTimeout(function() { + LoadTheme(theme_name.value); + }, 500); + chrome.storage.local.set({current_theme: $("#theme_list").val()}); RefreshFields(); } - function DeleteSelectedTheme() { - if ($("#theme_list")[0].options.length == 0) { - localStorage["current_theme"] = "Default"; + chrome.storage.local.get(null, function(items) { + let LSthemes = items.themes ? Object.assign({}, items.themes) : {}; + themes.splice(themes.indexOf($("#theme_list").val()), 1); + if (LSthemes[current_theme]) { + delete LSthemes[current_theme]; + } + chrome.storage.local.set({themes: LSthemes}); + var x = document.getElementById("theme_list"); + x.remove(x.selectedIndex); + current_theme = ($("#theme_list")[0].options.length > 0) ? $("#theme_list").val() : "Default"; + chrome.storage.local.set({current_theme: current_theme}); + if ($("#theme_list")[0].options.length == 0) { + SelectedTheme = Object.assign({}, DefaultTheme); + SelectedTheme["ColorsSet"] = {}; + chrome.storage.local.set({themes: {}}); + setTimeout(function() { + chrome.runtime.sendMessage({command: "reload_theme", themeName: ""}); + }, 500); + } + LoadTheme(current_theme); + RefreshFields(); + }); +} +function RenameSelectedTheme() { + if (themes.indexOf($("#new_theme_name")[0].value) != -1) { + alert(chrome.i18n.getMessage("options_there_is_a_theme_with_this_name")); return; } - themes.splice(themes.indexOf($("#theme_list").val()), 1); - localStorage["themes"] = JSON.stringify(themes); - - // localStorage.removeItem("theme"+($("#theme_list").val())); - localStorage.removeItem("theme"+SelectedTheme["theme_name"]); - - var x = document.getElementById("theme_list"); - x.remove(x.selectedIndex); - - localStorage["current_theme"] = ($("#theme_list")[0].options.length > 0) ? $("#theme_list").val() : "Default"; - LoadTheme(localStorage["current_theme"]); - RefreshFields(); - if ($("#theme_list")[0].options.length == 0) { - SelectedTheme = Object.assign({}, DefaultTheme); - SelectedTheme["ColorsSet"] = {}; - chrome.runtime.sendMessage({command: "reload_theme", themeName: "themeDefault"}); + if ($("#new_theme_name")[0].value == "") { + alert(chrome.i18n.getMessage("options_theme_name_cannot_be_empty")); + return; } -} - -function RenameSelectedTheme() { - if (themes.indexOf($("#new_theme_name")[0].value) != -1) { - alert(chrome.i18n.getMessage("options_there_is_a_theme_with_this_name")); - return; - } - if ($("#new_theme_name")[0].value == "") { - alert(chrome.i18n.getMessage("options_theme_name_cannot_be_empty")); - return; - } - var t_list = document.getElementById("theme_list"); - localStorage.removeItem("theme"+SelectedTheme["theme_name"]); + chrome.storage.local.get(null, function(items) { + let LSthemes = items.themes ? Object.assign({}, items.themes) : {}; SelectedTheme["theme_name"] = $("#new_theme_name")[0].value; - themes[themes.indexOf(t_list.options[t_list.selectedIndex].value)] = SelectedTheme["theme_name"]; + let t_list = document.getElementById("theme_list"); t_list.options[t_list.selectedIndex].value = t_list.options[t_list.selectedIndex].text = SelectedTheme["theme_name"]; - localStorage["current_theme"] = SelectedTheme["theme_name"]; - localStorage["themes"] = JSON.stringify(themes); - SaveTheme(SelectedTheme["theme_name"]); + LSthemes[SelectedTheme["theme_name"]] = SelectedTheme; + if (LSthemes[current_theme]) { + delete LSthemes[current_theme]; + } + current_theme = SelectedTheme["theme_name"]; + chrome.storage.local.set({themes: LSthemes}); + chrome.storage.local.set({current_theme: current_theme}); + }); } - - function ImportTheme() { var file = document.getElementById("import_theme"); var fr = new FileReader(); @@ -121,27 +124,21 @@ function ImportTheme() { var data = fr.result; file.remove(); var themeObj = JSON.parse(data); - if (themeObj.theme_version > DefaultTheme["theme_version"]) { alert(chrome.i18n.getMessage("options_loaded_theme_newer_version")); } if (themeObj.theme_version < DefaultTheme["theme_version"]) { alert(chrome.i18n.getMessage("options_loaded_theme_older_version")); } - if (themeObj.theme_version <= DefaultTheme["theme_version"]) { - SelectedTheme = Object.assign({}, DefaultTheme); SelectedTheme["ColorsSet"] = {}; - for (var val in themeObj.ColorsSet) { SelectedTheme["ColorsSet"][val] = themeObj.ColorsSet[val]; } - SelectedTheme["ToolbarShow"] = themeObj.ToolbarShow; SelectedTheme["TabsSizeSetNumber"] = themeObj.TabsSizeSetNumber; SelectedTheme["theme_version"] = DefaultTheme["theme_version"]; - if (themeObj.theme_version == 1) { SelectedTheme["ColorsSet"]["scrollbar_height"] = themeObj.ScrollbarPinList + "px"; SelectedTheme["ColorsSet"]["scrollbar_width"] = themeObj.ScrollbarTabList + "px"; @@ -149,39 +146,30 @@ function ImportTheme() { if (themeObj.theme_version == 2) { SelectedTheme["unused_buttons"] = themeObj["unused_buttons"]; } - - - if (themes.indexOf(themeObj.theme_name) == -1) { SelectedTheme["theme_name"] = themeObj.theme_name; } else { SelectedTheme["theme_name"] = themeObj.theme_name + "(1)"; } - themes.push(SelectedTheme["theme_name"]); - SaveTheme(SelectedTheme["theme_name"]); var t_list = document.getElementById("theme_list"); var theme_name = document.createElement("option"); theme_name.value = SelectedTheme["theme_name"]; theme_name.text = theme_name.value; t_list.add(theme_name); - - localStorage["themes"] = JSON.stringify(themes); - localStorage["current_theme"] = themeObj.theme_name; - $("#theme_list")[0].selectedIndex = $("#theme_list")[0].options.length-1; - - LoadTheme(SelectedTheme["theme_name"]); + current_theme = SelectedTheme["theme_name"]; + $("#new_theme_name")[0].value = current_theme; + setTimeout(function() { + LoadTheme(current_theme); + }, 500); RefreshFields(); - DefaultTheme["ColorsSet"] = {}; + chrome.storage.local.set({current_theme: current_theme}); } } - } - - function ApplySizeOptionsSet(size){ for (let si = 0; si < document.styleSheets.length; si++) { if ((document.styleSheets[si].ownerNode.id).match("size_settings") != null) { @@ -191,6 +179,5 @@ function ApplySizeOptionsSet(size){ document.styleSheets.item(si).disabled = true; } } - } -} +} \ No newline at end of file diff --git a/options/theme_size_settings_0.css b/options/theme_size_settings_0.css index 573fa7a..ae48b6f 100644 --- a/options/theme_size_settings_0.css +++ b/options/theme_size_settings_0.css @@ -138,9 +138,9 @@ /* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_open_background { top: 1px; left: 4px; background-size: var(--row_image_size);} +#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_open_background { top: 1px; left: -12px; background-size: var(--row_image_size);} #tab_list_background { top: 835px; left: 50px; } diff --git a/options/theme_size_settings_1.css b/options/theme_size_settings_1.css index e37931a..b18a0f4 100644 --- a/options/theme_size_settings_1.css +++ b/options/theme_size_settings_1.css @@ -138,9 +138,9 @@ /* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_open_background { top: 1px; left: 4px; background-size: var(--row_image_size);} +#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_open_background { top: 1px; left: -12px; background-size: var(--row_image_size);} #tab_list_background { top: 835px; left: 50px; } diff --git a/options/theme_size_settings_2.css b/options/theme_size_settings_2.css index d60a9ed..bd8011c 100644 --- a/options/theme_size_settings_2.css +++ b/options/theme_size_settings_2.css @@ -138,9 +138,9 @@ /* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_open_background { top: 1px; left: 4px; background-size: var(--row_image_size);} +#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_open_background { top: 1px; left: -12px; background-size: var(--row_image_size);} #tab_list_background { top: 835px; left: 50px; } diff --git a/options/theme_size_settings_3.css b/options/theme_size_settings_3.css index cc7ee79..8c77241 100644 --- a/options/theme_size_settings_3.css +++ b/options/theme_size_settings_3.css @@ -138,9 +138,9 @@ /* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 2px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_closed_background { top: 2px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_open_background { top: 2px; left: 4px; background-size: var(--row_image_size);} +#expand_hover_background { top: 2px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_closed_background { top: 2px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_open_background { top: 2px; left: -12px; background-size: var(--row_image_size);} #tab_list_background { top: 835px; left: 50px; } diff --git a/options/theme_size_settings_4.css b/options/theme_size_settings_4.css index f943b49..1c8910a 100644 --- a/options/theme_size_settings_4.css +++ b/options/theme_size_settings_4.css @@ -138,9 +138,9 @@ /* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 0px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_closed_background { top: 0px; left: calc(var(--children_padding_left) + 4px); background-size: var(--row_image_size);} -#expand_open_background { top: 0px; left: 4px; background-size: var(--row_image_size);} +#expand_hover_background { top: 0px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_closed_background { top: 0px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} +#expand_open_background { top: 0px; left: -12px; background-size: var(--row_image_size);} #tab_list_background { top: 835px; left: 50px; } diff --git a/scripts/IO.js b/scripts/IO.js index 28225eb..f885d81 100644 --- a/scripts/IO.js +++ b/scripts/IO.js @@ -40,21 +40,21 @@ function SetIOEvents() { if (MouseHoverOver == "pin_list") { // ctrl+a to select all if (event.ctrlKey && event.which == 65) { - $(".pin").addClass("selected"); + $(".pin").addClass("selected_tab"); } // ctrl+i to invert selection if (event.ctrlKey && event.which == 73) { - $(".pin").toggleClass("selected"); + $(".pin").toggleClass("selected_tab"); } } if (MouseHoverOver.match("g_|tab_list") !== null) { // ctrl+a to select all if (event.ctrlKey && event.which == 65) { - $("#"+active_group).children(".tab:visible").addClass("selected"); + $("#ch"+active_group).children(".tab:visible").addClass("selected_tab"); } // ctrl+i to invert selection if (event.ctrlKey && event.which == 73) { - $(".tab:visible").toggleClass("selected"); + $(".tab:visible").toggleClass("selected_tab"); } } RefreshGUI(); diff --git a/scripts/backup.js b/scripts/backup.js index 78e279f..b14d465 100644 --- a/scripts/backup.js +++ b/scripts/backup.js @@ -3,20 +3,32 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ function ExportGroup(filename) { - let GroupToSave = [0,[]]; - GroupToSave[0] = bggroups[active_group]; + let GroupToSave = { group: bggroups[active_group], folders: {}, tabs: [] }; let lastId = parseInt($("#"+active_group+" .tab").last()[0].id); - + $("#"+active_group+" .folder").each(function() { + if (bgfolders[this.id]) { + GroupToSave.folders[this.id] = bgfolders[this.id]; + } + }) $("#"+active_group+" .tab").each(function() { chrome.tabs.get(parseInt(this.id), function(tab) { - GroupToSave[1].push([tab.id, ($("#"+tab.id).parent(".group")[0] ? $("#"+tab.id).parent()[0].id : $("#"+tab.id).parent().parent(".tab")[0].id), $("#"+tab.id).index(), ($("#"+tab.id).is(".n") ? "n" : ($("#"+tab.id).is(".c") ? "c" : "o")), tab.url]); + if ((tab.url).startsWith("www") || (tab.url).startsWith("http") || (tab.url).startsWith("ftp")) { + (GroupToSave.tabs).push( + { + id: tab.id, + parent: $("#"+tab.id).parent().parent()[0].id, + index: $("#"+tab.id).index(), + expand: ($("#"+tab.id).is(".n") ? "n" : ($("#"+tab.id).is(".c") ? "c" : "o")), + url: tab.url + } + ); + } if (tab.id == lastId) { SaveFile(filename, GroupToSave); } }); }) } - function ImportGroup() { let file = document.getElementById("file_import_group"); let fr = new FileReader(); @@ -26,69 +38,77 @@ function ImportGroup() { let data = fr.result; file.remove(); let LoadedGroup = JSON.parse(data); + let NewFolders = {}; let RefsTabs = {}; - let newTabs = {}; - let lastId = LoadedGroup[1][LoadedGroup[1].length-1][0]; - let NewGroupId = AddNewGroup({name: LoadedGroup[0].name, font: LoadedGroup[0].font}); + let NewTabs = []; + let NewGroupId = AddNewGroup({name: LoadedGroup.group.name, font: LoadedGroup.group.font}); SetActiveGroup(NewGroupId, false, false); - LoadedGroup[1].forEach(function(LTab){ - chrome.tabs.create({url: LTab[4]}, function(tab) { - RefsTabs[LTab[0]] = tab.id; - newTabs[tab.id] = {i: LTab[2]}; - if (LTab[0] == lastId) { + for (var folder in LoadedGroup.folders) { + let newId = GenerateNewFolderID(); + NewFolders[folder] = { id: newId, parent: NewGroupId, index: (LoadedGroup.folders[folder].index), name: (LoadedGroup.folders[folder].name), expand: (LoadedGroup.folders[folder].expand) }; + } + for (var folder in NewFolders) { + if (NewFolders[LoadedGroup.folders[folder].parent]) { + NewFolders[folder].parent = NewFolders[LoadedGroup.folders[folder].parent].id; + } + } + (LoadedGroup.tabs).forEach(function(Tab){ + chrome.tabs.create({url: Tab.url, active: false}, function(new_tab) { + if (new_tab) { + RefsTabs[Tab.id] = new_tab.id; + Tab.id = new_tab.id; + NewTabs.push(Tab); + } + if (NewTabs.length == LoadedGroup.tabs.length-1) { setTimeout(function() { - LoadedGroup[1].forEach(function(LTab){ - $("#"+NewGroupId).append($("#"+LTab[0])); - }); - }, 2000); - setTimeout(function() { - LoadedGroup[1].forEach(function(LTab){ - if ($("#"+RefsTabs[LTab[1]])[0] && $("#"+LTab[0])[0]) { - $("#ch"+RefsTabs[LTab[1]]).append($("#"+LTab[0])); + NewTabs.forEach(function(LTab) { + if (LTab.parent == LoadedGroup.group.id) { + LTab.parent = NewGroupId; + } + if (NewFolders[LTab.parent]) { + LTab.parent = NewFolders[LTab.parent].id; + } + if (RefsTabs[LTab.parent]) { + LTab.parent = RefsTabs[LTab.parent]; } }); - LoadedGroup[1].forEach(function(LTab){ - $("#"+LTab[0]).addClass(LTab[3]); - }); - chrome.tabs.query({currentWindow: true}, function(tabs) { - RearrangeTreeTabs(tabs, newTabs, true); - RefreshExpandStates(); - RefreshGUI(); - }); - }, 4000); - } - LTab[0] = tab.id; + RearrangeTreeStructure({}, NewFolders, NewTabs); + }, 2000); + } }); }); } } - -function ExportTabs(filename) { +function ExportSession(filename) { chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { chrome.runtime.sendMessage({command: "get_browser_tabs"}, function(response) { let tabs = Object.assign({}, response); chrome.runtime.sendMessage({command: "get_windows"}, function(response) { let windows = Object.assign({}, response); - let WindowsToSave = []; - w.forEach(function(CWin){ - if (windows[CWin.id] != undefined && windows[CWin.id].group_bar != undefined && windows[CWin.id].active_shelf != undefined && windows[CWin.id].active_group != undefined && windows[CWin.id].groups != undefined && windows[CWin.id].folders != undefined) { - WindowsToSave.push([[], CWin.id, CWin.tabs[0].url, CWin.tabs[CWin.tabs.length-1].url, windows[CWin.id].group_bar, windows[CWin.id].group_bar, windows[CWin.id].active_shelf, windows[CWin.id].active_group, windows[CWin.id].groups, windows[CWin.id].folders, 0]); - } - - CWin.tabs.forEach(function(CTab){ - if (tabs[CTab.id] != undefined && tabs[CTab.id].parent != undefined && tabs[CTab.id].index != undefined && tabs[CTab.id].expand != undefined) { - WindowsToSave[WindowsToSave.length-1][0].push([CTab.id, CTab.url, tabs[CTab.id].parent, tabs[CTab.id].index, tabs[CTab.id].expand]); + let warn = true; + let ExportWindows = []; + w.forEach(function(CWin) { + if (CWin.tabs.length > 0) { + if (CWin.tabs.length > 100 && warn) { + alert(chrome.i18n.getMessage("warning_exporting_big_amount_of_tabs")); + warn = false; } - }); + windows[CWin.id]["id"] = CWin.id; + windows[CWin.id]["tabs"] = []; + CWin.tabs.forEach(function(CTab) { + if ((CTab.url).startsWith("www") || (CTab.url).startsWith("http") || (CTab.url).startsWith("ftp")) { + windows[CWin.id]["tabs"].push({id: CTab.id, url: CTab.url, parent: tabs[CTab.id].parent, index: tabs[CTab.id].index, expand: tabs[CTab.id].expand}); + } + }); + ExportWindows.push(windows[CWin.id]); + } }); - SaveFile(filename, WindowsToSave); + SaveFile(filename, ExportWindows); }); }); }); } - - -function ImportTabs() { +function ImportSession() { let file = document.getElementById("file_import_backup"); let fr = new FileReader(); if (file.files[0] == undefined) return; @@ -96,63 +116,80 @@ function ImportTabs() { fr.onload = function() { let data = fr.result; file.remove(); - chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { - - //make global variables - LoadedWindows = JSON.parse(data); - RefsTabs = {}; - TotalTabsCount = 0; - - LoadedWindows.forEach(function(LWin){ - TotalTabsCount += LWin[0].length; + let LoadedWindows = JSON.parse(data); + let RefsTabs = {}; + log(LoadedWindows); + LoadedWindows.forEach(function(LWin) { + let NewTabs = []; + let urls = []; + (LWin.tabs).forEach(function(Tab) { + urls.push(Tab.url); + NewTabs.push(Tab); }); - - LoadedWindows.forEach(function(LWin){ - chrome.windows.create({}, function(new_window) { - LWin[1] = new_window.id; - LWin[2] = ""; - LWin[3] = ""; - - setTimeout(function() { - chrome.runtime.sendMessage({command: "save_groups", groups: LWin[8], windowId: new_window.id}); - }, 1000); - - LWin[0].forEach(function(LTab){ - chrome.tabs.create({url: LTab[1], pinned: (LTab[2] == "pin_list" ? true : false), windowId: new_window.id}, function(tab) { - RefsTabs[LTab[0]] = tab.id; - LTab[0] = tab.id; - LTab[1] = ""; - TotalTabsCount--; - - if (TotalTabsCount < 2) { - setTimeout(function() { - chrome.runtime.sendMessage({command: "get_windows"}, function(response) { - let windows = Object.assign({}, response); - - LoadedWindows.forEach(function(LWin){ - LWin[0].forEach(function(LTab){ - schedule_update_data -= 2; - chrome.runtime.sendMessage({command: "update_tab", tabId: LTab[0], tab: {parent: (RefsTabs[LTab[2]] ? RefsTabs[LTab[2]] : LTab[2]), index: LTab[3], expand: LTab[4]}}); - }); - }); - - setTimeout(function() { - chrome.runtime.sendMessage({command: "reload_sidebar"}); - location.reload(); - }, 3000); - }); - chrome.tabs.remove(new_window.tabs[0].id, null); - }, 1000); - } - }); + chrome.windows.create({url: urls}, function(new_window) { + for (let tInd = 0; tInd < new_window.tabs.length; tInd++) { + RefsTabs[NewTabs[tInd].id] = new_window.tabs[tInd].id; + NewTabs[tInd].id = new_window.tabs[tInd].id; + } + for (let tInd = 0; tInd < new_window.tabs.length; tInd++) { + if (RefsTabs[NewTabs[tInd].parent] != undefined) { + NewTabs[tInd].parent = RefsTabs[NewTabs[tInd].parent]; + } + } + let HaveResponse; + let GiveUp = 0; + var Append = setInterval(function() { + chrome.runtime.sendMessage({command: "remote_update", groups: LWin.groups, folders: LWin.folders, tabs: NewTabs, windowId: new_window.id}, function(response) { + HaveResponse = response; }); - }); + if (HaveResponse || GiveUp > 900) { + clearInterval(Append); + } + GiveUp++; + }, 2000); }); }); } } - +function RearrangeTreeStructure(groups, folders, tabs) { // groups and folders are in object, just like bggroups and bgfolders, but tabs are in array of bgtreetabs objects + log("function: RearrangeTreeStructure"); + chrome.tabs.query({currentWindow: true}, function(ChromeTabs) { + if (Object.keys(groups).length > 0) { + for (var group in groups) { + bggroups[groups[group].id] = Object.assign({}, groups[group]); + } + AppendGroups(bggroups); + } + if (Object.keys(folders).length > 0) { + for (var folder in folders) { + bgfolders[folders[folder].id] = Object.assign({}, folders[folder]); + } + AppendFolders(bgfolders); + } + let bgtabs = {}; + tabs.forEach(function(Tab) { + if (Tab.parent == "pin_list") { + chrome.tabs.update(Tab.id, {pinned: true}); + } + if ($("#"+Tab.id)[0] && $("#ch"+Tab.parent)[0]) { + $("#ch"+Tab.parent).append($("#"+Tab.id)); + $("#"+Tab.id).addClass(Tab.expand); + } + bgtabs[Tab.id] = {index: Tab.index, parent: Tab.parent, expand: Tab.expand}; + }); + RearrangeTreeTabs(ChromeTabs, bgtabs, true); + RearrangeFolders(true); + UpdateBgGroupsOrder(); + setTimeout(function() { + RefreshExpandStates(); + RefreshCounters(); + schedule_update_data++; + SaveFolders(); + }, 1000); + }); +} function ImportMergeTabs() { + log("function: ImportMergeTabs"); let file = document.getElementById("file_import_merge_backup"); let fr = new FileReader(); if (file.files[0] == undefined) return; @@ -160,105 +197,107 @@ function ImportMergeTabs() { fr.onload = function() { let data = fr.result; file.remove(); - - //make global variables - LoadedWindows = JSON.parse(data); - RefsTabs = {}; - RefsWins = {}; - TotalTabsCount = 0; - LoadedWindows.forEach(function(LWin){ - TotalTabsCount += LWin[0].length; - }); - - chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { - w.forEach(function(CWin){ // loop Current Windows (CWin) - LoadedWindows.forEach(function(LWin){ // loop Loaded Windows (LWin) - CWin.tabs.forEach(function(CTab){ // loop Tabs of each Current Window - schedule_update_data -= 2; - for (let LWinTabInd = 0; LWinTabInd < LWin[0].length; LWinTabInd++) { // loop Tabs of each Loaded Window - if (CTab.url == LWin[0][LWinTabInd][1]) { - // TabsMatched++; - RefsTabs[LWin[0][LWinTabInd][0]] = CTab.id; - LWin[0][LWinTabInd][0] = CTab.id; - LWin[0][LWinTabInd][1] = ""; - LWin[10]++; - TotalTabsCount--; + let lw = JSON.parse(data); + let RefsWins = {}; + let RefsTabs = {}; + for (let LWI = 0; LWI < lw.length; LWI++) { // clear previous window ids + lw[LWI].id = ""; + } + log(lw); + chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(cw) { + for (let CWI = 0; CWI < cw.length; CWI++) { // loop Windows + for (let LWI = 0; LWI < lw.length; LWI++) { // loop Loaded Windows + let tabsMatch = 0; + for (let CTI = 0; CTI < cw[CWI].tabs.length; CTI++) { // loop Tabs of each Current Window + for (let LTI = 0; LTI < lw[LWI].tabs.length; LTI++) { // loop Tabs of each Loaded Window + if (cw[CWI].tabs[CTI].url == lw[LWI].tabs[LTI].url) { + RefsTabs[lw[LWI].tabs[LTI].id] = cw[CWI].tabs[CTI].id; + lw[LWI].tabs[LTI].id = cw[CWI].tabs[CTI].id; + lw[LWI].tabs[LTI].url = ""; + tabsMatch++; break; } } - }); - if (CWin.tabs[0].url == LWin[2] && CWin.tabs[CWin.tabs.length-1].url == LWin[3] && LWin[10] > LWin[0].length*0.5) { - RefsWins[LWin[1]] = CWin.id; - LWin[1] = CWin.id; - LWin[2] = ""; - LWin[3] = ""; } - }); - }); - - LoadedWindows.forEach(function(LWin){ - if (LWin[2] != "" && LWin[3] != "") { // missing window, lets make one - chrome.windows.create({}, function(new_window) { - RefsWins[LWin[1]] = new_window.id; - LWin[1] = new_window.id; - - LWin[2] = ""; - LWin[3] = ""; - - LWin[0].forEach(function(LTab){ - if (LTab[1] != "") { // missing tab of missing window, lets make one - chrome.tabs.create({url: LTab[1], windowId: new_window.id}, function(tab) { - - // chrome.tabs.executeScript(tab.id, {code: "setTimeout(function() { window.stop(); }, 5000);", runAt: "document_start"}, function(){}); - - RefsTabs[LTab[0]] = tab.id; - LTab[0] = tab.id; - LTab[1] = ""; - TotalTabsCount--; - }); - - } - }); - chrome.tabs.remove(new_window.tabs[0].id, null); + log(tabsMatch); + if (tabsMatch > lw[LWI].tabs.length*0.8) { + lw[LWI].id = cw[CWI].id; + break; + } + } + } + log(lw); + lw.forEach(function(w) { + if (w.id == "") { // missing window, lets make one + log("missing window"); + let NewTabs = []; + let urls = []; + (w.tabs).forEach(function(Tab) { + urls.push(Tab.url); + NewTabs.push(Tab); }); - } else { - LWin[0].forEach(function(LTab){ - if (LTab[1] != "") { // missing tab, lets make one - chrome.tabs.create({url: LTab[1], windowId: LWin[1]}, function(tab) { - RefsTabs[LTab[0]] = tab.id; - LTab[0] = tab.id; - LTab[1] = ""; - TotalTabsCount--; - - if (TotalTabsCount < 2) { - setTimeout(function() { - chrome.runtime.sendMessage({command: "get_windows"}, function(response) { - let windows = Object.assign({}, response); - - LoadedWindows.forEach(function(LWin){ - for (let lGroup in LWin[8]) { - if (windows[LWin[1]] && windows[LWin[1]].groups[lGroup] == undefined) { - windows[LWin[1]].groups[lGroup] = Object.assign({}, LWin[8][lGroup]); - chrome.runtime.sendMessage({command: "save_groups", groups: windows[LWin[1]].groups, windowId: LWin[1]}); - } - } - - LWin[0].forEach(function(LTab){ - schedule_update_data -= 2; - chrome.runtime.sendMessage({command: "update_tab", tabId: LTab[0], tab: {parent: (RefsTabs[LTab[2]] ? RefsTabs[LTab[2]] : LTab[2]), index: LTab[3], expand: LTab[4]}}); - }); - }); - - setTimeout(function() { - chrome.runtime.sendMessage({command: "reload_sidebar"}); - location.reload(); - }, 1000); - }); - }, 1000); - } + chrome.windows.create({url: urls}, function(new_window) { + for (let tInd = 0; tInd < new_window.tabs.length; tInd++) { + RefsTabs[NewTabs[tInd].id] = new_window.tabs[tInd].id; + NewTabs[tInd].id = new_window.tabs[tInd].id; + } + for (let tInd = 0; tInd < new_window.tabs.length; tInd++) { + if (RefsTabs[NewTabs[tInd].parent] != undefined) { + NewTabs[tInd].parent = RefsTabs[NewTabs[tInd].parent]; + } + } + let HaveResponse; + let GiveUp = 0; + var Append = setInterval(function() { + chrome.runtime.sendMessage({command: "remote_update", groups: w.groups, folders: w.folders, tabs: NewTabs, windowId: new_window.id}, function(response) { + HaveResponse = response; }); + if (HaveResponse || GiveUp > 900) { + clearInterval(Append); + } + GiveUp++; + }, 2000); + }); + } + else + { // window exists, lets add missing tabs + log("window exists"); + let NewTabs = []; + (w.tabs).forEach(function(Tab) { + if (Tab.url != "") { // missing tab, lets make one + chrome.tabs.create({url: Tab.url, windowId: w.id}, function(tab) { + Tab.id = tab.id; + RefsTabs[tab.id] = tab.id; + NewTabs.push(Tab); + }); + } else { + NewTabs.push(Tab); } }); + setTimeout(function() { + for (let tInd = 0; tInd < NewTabs.length; tInd++) { + if (RefsTabs[NewTabs[tInd].parent] != undefined) { + NewTabs[tInd].parent = RefsTabs[NewTabs[tInd].parent]; + } + } + }, 4000); + setTimeout(function() { + if (w.id == CurrentWindowId) { + RearrangeTreeStructure(w.groups, w.folders, NewTabs); + } else { + let HaveResponse; + let GiveUp = 0; + var Append = setInterval(function() { + chrome.runtime.sendMessage({command: "remote_update", groups: w.groups, folders: w.folders, tabs: NewTabs, windowId: w.id}, function(response) { + HaveResponse = response; + }); + if (HaveResponse || GiveUp > 900) { + clearInterval(Append); + } + GiveUp++; + }, 2000); + } + }, 6000); } }); }); diff --git a/scripts/chrome.js b/scripts/chrome.js index ca34de1..455e7e6 100644 --- a/scripts/chrome.js +++ b/scripts/chrome.js @@ -4,69 +4,90 @@ // ********** CHROME EVENTS *************** -function StartChromeListeners(){ +function StartChromeListeners() { + if (browserId == "F") { + browser.browserAction.onClicked.addListener(function(tab) { + if (tab.windowId == CurrentWindowId) { + browser.sidebarAction.close(); + } + }); + } chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + log("message to sidebar "+CurrentWindowId+": "); + log(message); + if (message.command == "backup_available") { + $("#button_load_bak"+message.bak).removeClass("disabled"); + } if (message.command == "drag_drop") { - DragAndDrop.DragNodeClass = message.DragNodeClass; - DragAndDrop.SelectedTabsIds = message.SelectedTabsIds; - DragAndDrop.TabsIds = message.TabsIds; - DragAndDrop.Parents = message.Parents; DragAndDrop.ComesFromWindowId = message.ComesFromWindowId; + DragAndDrop.DragNodeClass = message.DragNodeClass; DragAndDrop.Depth = message.Depth; + DragAndDrop.Folders = Object.assign({}, message.Folders); + DragAndDrop.FoldersSelected = message.FoldersSelected; + DragAndDrop.TabsIds = message.TabsIds; + DragAndDrop.TabsIdsParents = message.TabsIdsParents; + DragAndDrop.TabsIdsSelected = message.TabsIdsSelected; + } + if (message.command == "dropped") { + DragAndDrop.DroppedToWindowId = message.DroppedToWindowId; + if (Object.keys(DragAndDrop.Folders).length > 0 && message.DroppedToWindowId != CurrentWindowId) { + for (var folder in DragAndDrop.Folders) + { + RemoveFolder(DragAndDrop.Folders[folder].id); + } + } } if (message.command == "reload_sidebar") { window.location.reload(); } if (message.command == "reload_options") { - LoadPreferences(); - setTimeout(function() { - RestorePinListRowSettings(); - },200); + chrome.runtime.sendMessage({command: "get_preferences"}, function(response) { + opt = Object.assign({}, response); + setTimeout(function() { + RestorePinListRowSettings(); + }, 200); + }); } if (message.command == "reload_theme") { - let theme = LoadData(message.themeName, DefaultTheme); - ApplySizeSet(theme["TabsSizeSetNumber"]); - ApplyColorsSet(theme["ColorsSet"]); - if (theme.ToolbarShow) { - $("#toolbar").html(theme.toolbar); - } else { - $("#toolbar").html(""); - } - RestoreToolbarSearchFilter(); - RestoreToolbarShelf(); + setTimeout(function() { + chrome.runtime.sendMessage({command: "get_theme", windowId: CurrentWindowId}, function(response) { + RestorePinListRowSettings(); + let theme = response; + ApplyTheme(theme); + }); + }, 300); } if (message.windowId == CurrentWindowId) { switch(message.command) { - case "tab_created": - // if set to treat unparented tabs as active tab's child - if (opt.append_orphan_tab == "as_child" && message.tab.openerTabId == undefined && $(".active:visible")[0]) { - message.tab.openerTabId = $(".active:visible")[0].id; + case "tab_created": // if set to treat unparented tabs as active tab's child + if (opt.append_orphan_tab == "as_child" && message.tab.openerTabId == undefined && $("#"+active_group+" .active_tab")[0]) { + message.tab.openerTabId = $("#"+active_group+" .active_tab")[0].id; } - // child case - if (message.tab.openerTabId) { - // append to tree - if (opt.max_tree_depth < 0 || (opt.max_tree_depth > 0 && $("#"+message.tab.openerTabId).parents(".tab").length < opt.max_tree_depth)) { - if (opt.append_child_tab == "top") { - AppendTab({ tab: message.tab, ParentId: message.tab.openerTabId, Append: false, Scroll: true }); + if (message.tab.openerTabId) { // child case + if (opt.append_child_tab == "after_active") { + AppendTab({ tab: message.tab, InsertAfterId: $("#"+active_group+" .active_tab")[0] ? $("#"+active_group+" .active_tab")[0].id : undefined, Append: false, Scroll: true }); + } else { + if (opt.max_tree_depth < 0 || (opt.max_tree_depth > 0 && $("#"+message.tab.openerTabId).parents(".tab").length < opt.max_tree_depth)) { // append to tree + if (opt.append_child_tab == "top") { + AppendTab({ tab: message.tab, ParentId: message.tab.openerTabId, Append: false, Scroll: true }); + } + if (opt.append_child_tab == "bottom") { + AppendTab({ tab: message.tab, ParentId: message.tab.openerTabId, Append: true, Scroll: true }); + } } - if (opt.append_child_tab == "bottom") { - AppendTab({ tab: message.tab, ParentId: message.tab.openerTabId, Append: true, Scroll: true }); + if (opt.max_tree_depth > 0 && $("#"+message.tab.openerTabId).parents(".tab").length >= opt.max_tree_depth) { // if reached depth limit of the tree + if (opt.append_child_tab_after_limit == "after") { + AppendTab({ tab: message.tab, InsertAfterId: message.tab.openerTabId, Append: true, Scroll: true }); + } + if (opt.append_child_tab_after_limit == "top") { + AppendTab({ tab: message.tab, ParentId: $("#"+message.tab.openerTabId).parent().parent()[0].id, Append: false, Scroll: true }); + } + if (opt.append_child_tab_after_limit == "bottom") { + AppendTab({ tab: message.tab, ParentId: $("#"+message.tab.openerTabId).parent().parent()[0].id, Append: true, Scroll: true }); + } } } - // if reached depth limit of the tree - if (opt.max_tree_depth > 0 && $("#"+message.tab.openerTabId).parents(".tab").length >= opt.max_tree_depth) { - if (opt.append_child_tab_after_limit == "after") { - AppendTab({ tab: message.tab, InsertAfterId: message.tab.openerTabId, Append: true, Scroll: true }); - } - if (opt.append_child_tab_after_limit == "top") { - AppendTab({ tab: message.tab, ParentId: $("#"+message.tab.openerTabId).parent().parent()[0].id, Append: false, Scroll: true }); - } - if (opt.append_child_tab_after_limit == "bottom") { - AppendTab({ tab: message.tab, ParentId: $("#"+message.tab.openerTabId).parent().parent()[0].id, Append: true, Scroll: true }); - } - } - // place tabs flat, (should I merge it with orphans case?) - if (opt.max_tree_depth == 0) { + if (opt.max_tree_depth == 0) { // place tabs flat, (should I merge it with orphans case?) if (opt.append_child_tab_after_limit == "after") { AppendTab({ tab: message.tab, InsertAfterId: message.tab.openerTabId, Append: false, Scroll: true }); } @@ -77,10 +98,9 @@ function StartChromeListeners(){ AppendTab({ tab: message.tab, Append: true, Scroll: true }); } } - // orphan case - } else { + } else { // orphan case if (opt.append_orphan_tab == "after_active") { - AppendTab({ tab: message.tab, InsertAfterId: $(".active:visible")[0] ? $(".active:visible")[0].id : undefined, Append: false }); + AppendTab({ tab: message.tab, InsertAfterId: $("#"+active_group+" .active_tab")[0] ? $("#"+active_group+" .active_tab")[0].id : undefined, Append: false }); } if (opt.append_orphan_tab == "top") { AppendTab({ tab: message.tab, Append: false }); @@ -92,12 +112,17 @@ function StartChromeListeners(){ if ($("#"+message.tab.openerTabId).is(".c")) { $("#"+message.tab.openerTabId).removeClass("c").addClass("o"); } + if (opt.syncro_tabbar_tabs_order) { + let TTtabsIndexes = $(".pin, .tab").map(function(){return parseInt(this.id);}).toArray(); + chrome.tabs.move(message.tab.id, {index: TTtabsIndexes.indexOf(message.tab.id)}); + } RefreshExpandStates(); schedule_update_data++; RefreshGUI(); + RefreshCounters(); break; case "tab_attached": - AppendTab({ tab: message.tab, ParentId: message.ParentId, Append: true}); + AppendTab({tab: message.tab, ParentId: message.ParentId, Append: true}); RefreshGUI(); break; case "tab_detached": @@ -117,7 +142,9 @@ function StartChromeListeners(){ } } RemoveTabFromList(message.tabId); - setTimeout(function() { schedule_update_data++; },300); + setTimeout(function() { + schedule_update_data++; + }, 300); RefreshGUI(); break; case "tab_removed": @@ -138,11 +165,16 @@ function StartChromeListeners(){ } RemoveTabFromList(message.tabId); RefreshExpandStates(); - setTimeout(function() { schedule_update_data++; },300); + setTimeout(function() { + schedule_update_data++; + }, 300); RefreshGUI(); + RefreshCounters(); break; case "tab_activated": - setTimeout(function() { SetActiveTab(message.tabId); },100); + setTimeout(function() { + SetActiveTab(message.tabId); + }, 200); break; case "tab_attention": SetAttentionIcon(message.tabId); @@ -151,12 +183,12 @@ function StartChromeListeners(){ if (message.changeInfo.favIconUrl != undefined || message.changeInfo.url != undefined) { setTimeout(function() { GetFaviconAndTitle(message.tabId, true); - },100); + }, 100); } if (message.changeInfo.title != undefined) { setTimeout(function() { GetFaviconAndTitle(message.tabId, true); - },1000); + }, 1000); } if (message.changeInfo.audible != undefined || message.changeInfo.mutedInfo != undefined) { RefreshMediaIcon(message.tabId); @@ -172,6 +204,10 @@ function StartChromeListeners(){ RefreshExpandStates(); } break; + case "remote_update": + RearrangeTreeStructure(message.groups, message.folders, message.tabs); + sendResponse(true); + break; } } diff --git a/scripts/drag_and_drop.js b/scripts/drag_and_drop.js index 78dec25..45e8f0e 100644 --- a/scripts/drag_and_drop.js +++ b/scripts/drag_and_drop.js @@ -4,8 +4,43 @@ // ********** TABS EVENTS *************** +function GetSelectedFolders() { + log("function: GetSelectedFolders"); + let res = {Folders: {}, FoldersSelected: [], TabsIds: [], TabsIdsParents: []}; + $("#"+active_group+" .selected_folder").each(function() { + res.FoldersSelected.push(this.id); + res.Folders[this.id] = Object.assign({}, bgfolders[this.id]); + if ($("#cf" + this.id).children().length > 0) { + $($("#cf" + this.id).find(".folder")).each(function() { + res.Folders[this.id] = Object.assign({}, bgfolders[this.id]); + }); + } + $($(this).find(".tab")).each(function() { + res.TabsIds.push(parseInt(this.id)); + res.TabsIdsParents.push($(this).parent()[0].id); + }); + }); + log(res); + return res; +} +function GetSelectedTabs() { + log("function: GetSelectedTabs"); + let res = {TabsIds: [], TabsIdsParents: [], TabsIdsSelected: []}; + $("#"+active_group+" .selected_tab").each(function() { + res.TabsIds.push(parseInt(this.id)); + res.TabsIdsParents.push($(this).parent()[0].id); + res.TabsIdsSelected.push(parseInt(this.id)); + if ($("#ch" + this.id).children().length > 0) { + $($("#ch" + this.id).find(".tab")).each(function() { + res.TabsIds.push(parseInt(this.id)); + res.TabsIdsParents.push($(this).parent()[0].id); + }); + } + }); + log(res); + return res; +} function SetDragAndDropEvents() { - $(document).on("mouseleave", window, function(event) { MouseHoverOver = ""; }); @@ -18,145 +53,144 @@ function SetDragAndDropEvents() { $(document).on("dragover", "#toolbar_groups, #toolbar, #pin_list, .group", function(event) { MouseHoverOver = this.id; }); - $(document).on("mouseover", "#toolbar_groups, #toolbar, #pin_list, .group", function(event) { // set mouse over id + $(document).on("mouseover", "#toolbar_groups, #toolbar, #pin_list, .group", function(event) { MouseHoverOver = this.id; }); - - // PREVENT THE DEFAULT BROWSER DROP ACTION - $(document).bind("drop dragover", function(event) { + $(document).bind("drop dragover", function(event) { // PREVENT THE DEFAULT BROWSER DROP ACTION event.preventDefault(); }); - - - // bring to front drop zones - $(document).on("dragenter", ".tab_header, .folder", function(event) { - DropTargetsSendToFront(); + $(document).on("mousedown", ".drop_target", function(event) { // deny drag enter on drop_targets and allow clicks below them + $(".drop_target").css({"pointer-events": "none"}); }); - - - - // SET FOLDER DRAG SOURCE - $(document).on("dragstart", ".folder_header", function(event) { - DragAndDrop.DragNodeClass = "folder"; + $(document).on("dragenter", ".tab_header, .folder_header", function(event) { // allow drag enter on drop_targets + $(".drop_target").css({"pointer-events": "all"}); + }); + $(document).on("dragstart", ".tab_header, .folder_header", function(event) { // SET DRAG SOURCE event.stopPropagation(); event.originalEvent.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); event.originalEvent.dataTransfer.setData("text", ""); - + DragAndDrop.DroppedToWindowId = 0; DragAndDrop.ComesFromWindowId = CurrentWindowId; - DragAndDrop.SelectedTabsIds.splice(0, DragAndDrop.SelectedTabsIds.length); - DragAndDrop.TabsIds.splice(0, DragAndDrop.TabsIds.length); - DragAndDrop.Parents.splice(0, DragAndDrop.Parents.length); - }); - - - // SET TAB DRAG SOURCE - $(document).on("dragstart", ".tab_header", function(event) { - DragAndDrop.DragNodeClass = "tab"; - event.stopPropagation(); - event.originalEvent.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); - event.originalEvent.dataTransfer.setData("text", ""); - - if ($(this).parent().is(".active")) { - $(this).parent().addClass("selected_temporarly").addClass("selected"); - } - $(".close").removeClass("show"); - $(".tab_header_hover").removeClass("tab_header_hover"); - - if ($(this).parent().is(":not(.selected)")) { - $(".selected").addClass("selected_frozen").removeClass("selected"); - $(this).parent().addClass("selected_temporarly").addClass("selected"); - } - - $(".selected:not(:visible)").addClass("selected_frozen").removeClass("selected"); - - DragAndDrop.ComesFromWindowId = CurrentWindowId; - DragAndDrop.SelectedTabsIds.splice(0, DragAndDrop.SelectedTabsIds.length); - DragAndDrop.TabsIds.splice(0, DragAndDrop.TabsIds.length); - DragAndDrop.Parents.splice(0, DragAndDrop.Parents.length); - DragAndDrop.Depth = 0; - $(".selected:visible").find(".pin, .tab").each(function() { - if ($(this).parents(".pin, .tab").length > DragAndDrop.Depth) { DragAndDrop.Depth = $(this).parents(".pin, .tab").length; } - }); - DragAndDrop.Depth -= $(this).parents(".pin, .tab").length-1; - if (DragAndDrop.Depth < 0) { - DragAndDrop.Depth = 0; - } - console.log(DragAndDrop.Depth); - $(".selected:visible").each(function() { - DragAndDrop.SelectedTabsIds.push(parseInt(this.id)); - DragAndDrop.TabsIds.push(parseInt(this.id)); - DragAndDrop.Parents.push($(this).parent()[0].id); - if ($("#ch" + this.id).children().length > 0) { - $($("#ch" + this.id).find(".tab")).each(function() { - DragAndDrop.TabsIds.push(parseInt(this.id)); - DragAndDrop.Parents.push($(this).parent()[0].id); - }); + if ($(this)[0].classList[0] == "folder_header") { + DragAndDrop.DragNodeClass = "folder"; + if ($(this).parent().is(":not(.selected_folder)")) { + $(".selected_folder").addClass("selected_folder_frozen").removeClass("selected_folder"); + $(this).parent().addClass("selected_folder_temporarly").addClass("selected_folder"); } + $(".selected_folder:not(:visible)").addClass("selected_folder_frozen").removeClass("selected_folder"); + let Folders = GetSelectedFolders(); + DragAndDrop.TabsIds = Object.assign([], Folders.TabsIds); + DragAndDrop.TabsIdsParents = Object.assign([], Folders.TabsIdsParents); + DragAndDrop.TabsIdsSelected = Object.assign([], []); + DragAndDrop.Folders = Object.assign({}, Folders.Folders); + DragAndDrop.FoldersSelected = Object.assign([], Folders.FoldersSelected); + } + if ($(this)[0].classList[0] == "tab_header") { + DragAndDrop.DragNodeClass = "tab"; + if ($(this).parent().is(".active_tab")) { + $(this).parent().addClass("selected_temporarly").addClass("selected_tab"); + } + $(".close").removeClass("show"); + $(".tab_header_hover").removeClass("tab_header_hover"); + if ($(this).parent().is(":not(.selected_tab)")) { + $(".selected_tab").addClass("selected_frozen").removeClass("selected_tab"); + $(this).parent().addClass("selected_temporarly").addClass("selected_tab"); + } + $(".selected_tab:not(:visible)").addClass("selected_frozen").removeClass("selected_tab"); + $("#"+active_group+" .selected_tab").find(".pin, .tab").each(function() { + if ($(this).parents(".pin, .tab").length > DragAndDrop.Depth) { + DragAndDrop.Depth = $(this).parents(".pin, .tab").length; + } + }); + DragAndDrop.Depth -= $(this).parents(".pin, .tab").length-1; + if (DragAndDrop.Depth < 0) { + DragAndDrop.Depth = 0; + } + let Tabs = GetSelectedTabs(); + DragAndDrop.TabsIds = Object.assign([], Tabs.TabsIds); + DragAndDrop.TabsIdsParents = Object.assign([], Tabs.TabsIdsParents); + DragAndDrop.TabsIdsSelected = Object.assign([], Tabs.TabsIdsSelected); + DragAndDrop.Folders = Object.assign({}, {}); + DragAndDrop.FoldersSelected = Object.assign([], []); + } + chrome.runtime.sendMessage({ + command: "drag_drop", + DragNodeClass: DragAndDrop.DragNodeClass, + TabsIds: DragAndDrop.TabsIds, + TabsIdsParents: DragAndDrop.TabsIdsParents, + TabsIdsSelected: DragAndDrop.TabsIdsSelected, + ComesFromWindowId: CurrentWindowId, + Depth: DragAndDrop.Depth, + Folders: DragAndDrop.Folders, + FoldersSelected: DragAndDrop.FoldersSelected }); - chrome.runtime.sendMessage({command: "drag_drop", DragNodeClass: "tab", SelectedTabsIds: DragAndDrop.SelectedTabsIds, TabsIds: DragAndDrop.TabsIds, Parents: DragAndDrop.Parents, ComesFromWindowId: CurrentWindowId, Depth: DragAndDrop.Depth}); }); - - // REMOVE DROP TARGET WHEN DRAG LEAVES - $(document).on("dragleave", ".highlighted_drop_target", function(event) { + $(document).on("dragleave", ".highlighted_drop_target", function(event) { // REMOVE DROP TARGET WHEN DRAG LEAVES $(".highlighted_drop_target").removeClass("highlighted_drop_target"); }); - - // SET DROP TARGET WHEN ENTERING PINS - $(document).on("dragenter", ".pin>.drag_entered_top:not(.highlighted_drop_target), .pin>.drag_entered_bottom:not(.highlighted_drop_target)", function(event) { + $(document).on("dragenter", ".pin>.drag_entered_top:not(.highlighted_drop_target), .pin>.drag_entered_bottom:not(.highlighted_drop_target)", function(event) { // SET DROP TARGET WHEN ENTERING PINS event.stopPropagation(); if (DragAndDrop.DragNodeClass == "tab") { $(".highlighted_drop_target").removeClass("highlighted_drop_target"); $(this).addClass("highlighted_drop_target"); } }); - - // SET DROP TARGET WHEN ENTERING TABS - $(document).on("dragenter", ".tab>.drag_entered_top:not(.highlighted_drop_target), .tab>.drag_entered_bottom:not(.highlighted_drop_target)", function(event) { + $(document).on("dragenter", ".tab>.drag_entered_top:not(.highlighted_drop_target), .tab>.drag_entered_bottom:not(.highlighted_drop_target)", function(event) { // SET DROP TARGET WHEN ENTERING TABS event.stopPropagation(); - if ($(".selected:visible").find($(this)).length == 0 && DragAndDrop.DragNodeClass == "tab") { - if (opt.max_tree_drag_drop && opt.max_tree_depth >= 0) { - if ($(this).parents(".tab").length + DragAndDrop.Depth > opt.max_tree_depth+1) { return; } + if (DragAndDrop.DragNodeClass == "tab") { + if ($(".selected_tab:visible").find($(this)).length == 0) { + if (opt.max_tree_drag_drop && opt.max_tree_depth >= 0) { + if ($(this).parents(".tab").length + DragAndDrop.Depth-1 > opt.max_tree_depth) { + return; + } + } + $(".highlighted_drop_target").removeClass("highlighted_drop_target"); + $(this).addClass("highlighted_drop_target"); } - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); } }); $(document).on("dragenter", ".tab>.drag_enter_center:not(.highlighted_drop_target)", function(event) { event.stopPropagation(); - if ($(".selected:visible").find($(this)).length == 0 && DragAndDrop.DragNodeClass == "tab" && opt.max_tree_depth != 0) { - if (opt.max_tree_drag_drop) { - if (opt.max_tree_depth == 0) { return; } - if ($(this).parents(".tab").length + DragAndDrop.Depth > opt.max_tree_depth) { return; } + if (DragAndDrop.DragNodeClass == "tab") { + if ($(".selected_tab:visible").find($(this)).length == 0 && opt.max_tree_depth != 0) { + if (opt.max_tree_drag_drop && opt.max_tree_depth > 0) { + if ($(this).parents(".tab").length + DragAndDrop.Depth > opt.max_tree_depth) { + return; + } + } + $(".highlighted_drop_target").removeClass("highlighted_drop_target"); + $(this).addClass("highlighted_drop_target"); } - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); } }); - - - // SET DROP TARGET WHEN ENTERING FOLDERS - $(document).on("dragenter", ".folder>.drag_entered_top:not(.highlighted_drop_target), .folder>.drag_entered_bottom:not(.highlighted_drop_target), .folder>.drag_enter_center:not(.highlighted_drop_target)", function(event) { + $(document).on("dragenter", ".folder>.drag_entered_top:not(.highlighted_drop_target), .folder>.drag_entered_bottom:not(.highlighted_drop_target), .folder>.drag_enter_center:not(.highlighted_drop_target)", function(event) { // SET DROP TARGET WHEN ENTERING FOLDERS event.stopPropagation(); - if (DragAndDrop.DragNodeClass != "group") { - // if (/* $(".selected:visible").find($(this)).length > 0 || */ DragAndDrop.DragNodeClass != "folder") { return; } + if (DragAndDrop.DragNodeClass == "folder") { $(".highlighted_drop_target").removeClass("highlighted_drop_target"); $(this).addClass("highlighted_drop_target"); } }); - - // SET DROP TARGET, PIN_LIST, TAB_LIST, GROUP OR GROUP_BUTTON - $(document).on("dragover", "#pin_list, .group, .group_drag_box", function(event) { - if (DragAndDrop.DragNodeClass != "group" && $(".highlighted_drop_target").length == 0 && event.target.className == $(this)[0].className) { + $(document).on("dragenter", ".folder>.drag_enter_center:not(.highlighted_drop_target)", function(event) { + event.stopPropagation(); + if (DragAndDrop.DragNodeClass == "tab") { + $(".highlighted_drop_target").removeClass("highlighted_drop_target"); $(this).addClass("highlighted_drop_target"); } + }); + $(document).on("dragover", "#pin_list, .group, .group_drag_box", function(event) { // SET DROP TARGET, PIN_LIST, TAB_LIST, GROUP OR GROUP_BUTTON + if (DragAndDrop.DragNodeClass != "group") { + if ($(".highlighted_drop_target").length == 0 && event.target.className == $(this)[0].className) { + $(this).addClass("highlighted_drop_target"); + } + } }); - - // TIMER FOR FOR AUTO EXPAND - $(document).on("dragenter", ".drag_enter_center", function(event) { + $(document).on("dragenter", ".drag_enter_center", function(event) { // TIMER FOR FOR AUTO EXPAND event.stopPropagation(); DragAndDrop.timeout = false; - setTimeout(function() { DragAndDrop.timeout = true; }, 1800); + setTimeout(function() { + DragAndDrop.timeout = true; + }, 1800); }); $(document).on("dragleave", ".drag_enter_center", function(event) { DragAndDrop.timeout = false; @@ -167,190 +201,212 @@ function SetDragAndDropEvents() { DragAndDrop.timeout = false; } }); - - // DROP - $(document).on("drop", "*", function(event) { + $(document).on("drop", "*", function(event) { // DROP + chrome.runtime.sendMessage({command: "dropped", DroppedToWindowId: CurrentWindowId}); event.stopPropagation(); - if (DragAndDrop.ComesFromWindowId == CurrentWindowId /* && ($(window).width() > event.clientX || $(window).height() > event.clientY) */) { + if (DragAndDrop.ComesFromWindowId == CurrentWindowId) { DropToTarget($(".highlighted_drop_target")); } else { - $(".selected").addClass("selected_frozen").removeClass("selected"); + if (Object.keys(DragAndDrop.Folders).length > 0) { + for (var folder in DragAndDrop.Folders) { + bgfolders[DragAndDrop.Folders[folder].id] = Object.assign({}, DragAndDrop.Folders[folder]); + } + AppendFolders(bgfolders); + } + $(".selected_tab").addClass("selected_frozen").removeClass("selected_tab"); let target = $(".highlighted_drop_target"); - let counter = DragAndDrop.TabsIds.length; + let counter = 0; (DragAndDrop.TabsIds).forEach(function(TabId) { chrome.tabs.move(TabId, { windowId: CurrentWindowId, index: -1 }, function(MovedTab) { - counter--; - setTimeout(function() { - if (counter == 0) { - setTimeout(function() { - (DragAndDrop.SelectedTabsIds).forEach(function(selectedTabId) { - if ($("#"+selectedTabId)[0]){ - $("#"+selectedTabId).addClass("selected_temporarly").addClass("selected"); - } - }); - if (browserId != "F") { // I HAVE TO EXLUDE THIS IN FIREFOX SINCE MOVED TAB LOSES ITS ORIGINAL ID - WHAT IN THE ACTUAL F*CK MOZILLA! - for (var tabsIdsIndex = 1; tabsIdsIndex < (DragAndDrop.TabsIds).length; tabsIdsIndex++) { - if ($("#"+DragAndDrop.TabsIds[tabsIdsIndex])[0] && $("#"+DragAndDrop.Parents[tabsIdsIndex])[0]){ - $("#"+DragAndDrop.Parents[tabsIdsIndex]).append($("#"+DragAndDrop.TabsIds[tabsIdsIndex])); - } - - } - } - DropToTarget(target); - },300); + if (browserId == "F") { // FIRFOX BUG 1398272 - HAVE TO REPLACE ORIGINAL ID + if ((DragAndDrop.TabsIdsParents).indexOf("ch"+DragAndDrop.TabsIds[counter]) != -1) { + DragAndDrop.TabsIdsParents[(DragAndDrop.TabsIdsParents).indexOf("ch"+DragAndDrop.TabsIds[counter])] = "ch"+MovedTab[0].id; } - },300); + if ((DragAndDrop.TabsIdsSelected).indexOf(DragAndDrop.TabsIds[counter]) != -1) { + DragAndDrop.TabsIdsSelected[(DragAndDrop.TabsIdsSelected).indexOf(DragAndDrop.TabsIds[counter])] = MovedTab[0].id; + } + DragAndDrop.TabsIds[counter] = MovedTab[0].id; + } + counter++; + if (counter == DragAndDrop.TabsIds.length) { + setTimeout(function() { + (DragAndDrop.TabsIdsSelected).forEach(function(selectedTabId) { + if ($("#"+selectedTabId)[0]) { + $("#"+selectedTabId).addClass("selected_temporarly").addClass("selected_tab"); + } + }); + for (var tabsIdsIndex = 1; tabsIdsIndex < (DragAndDrop.TabsIds).length; tabsIdsIndex++) { + if ($("#"+DragAndDrop.TabsIds[tabsIdsIndex])[0] && $("#"+DragAndDrop.TabsIdsParents[tabsIdsIndex])[0]) { + $("#"+DragAndDrop.TabsIdsParents[tabsIdsIndex]).append($("#"+DragAndDrop.TabsIds[tabsIdsIndex])); + } + } + for (var FolderSelectedIndex = 0; FolderSelectedIndex < (DragAndDrop.FoldersSelected).length; FolderSelectedIndex++) { + if ($("#"+DragAndDrop.FoldersSelected[FolderSelectedIndex])[0]) { + $("#"+DragAndDrop.FoldersSelected[FolderSelectedIndex]).addClass("selected_folder_temporarly").addClass("selected_folder"); + } + } + DropToTarget(target); + }, 300); + } }); }); } + $(".drop_target").css({"pointer-events": "none"}); }); - - // DETACH - $(document).on("dragend", ".tab_header", function(event) { - if (DragAndDrop.ComesFromWindowId == CurrentWindowId) { - if (browserId == "F" && (event.screenX < event.view.mozInnerScreenX || event.screenX > (event.view.mozInnerScreenX + $(window).width()) || (event.screenY < event.view.mozInnerScreenY || event.screenY > (event.view.mozInnerScreenY + $(window).height())))) { - DetachTabs(DragAndDrop.TabsIds); + $(document).on("dragend", ".tab_header, .folder_header", function(event) { // DETACH TABS + setTimeout(function() { + if (DragAndDrop.ComesFromWindowId == CurrentWindowId && DragAndDrop.DroppedToWindowId == 0) { + if ( (browserId == "F" && (event.screenX < event.view.mozInnerScreenX || event.screenX > (event.view.mozInnerScreenX + $(window).width()) || (event.screenY < event.view.mozInnerScreenY || event.screenY > (event.view.mozInnerScreenY + $(window).height())))) + || (browserId != "F" && (event.pageX < 0 || event.pageX > $(window).width() || event.pageY < 0 || event.pageY > $(window).height())) + ) { + if (DragAndDrop.DragNodeClass == "tab") { + DetachTabs(DragAndDrop.TabsIds, {}); + } + if (DragAndDrop.DragNodeClass == "folder") { + DetachTabs(DragAndDrop.TabsIds, DragAndDrop.Folders); + setTimeout(function() { + SaveFolders(); + }, 500); + } + } } - if (browserId != "F" && (event.pageX < 0 || event.pageX > $(window).width() || event.pageY < 0 || event.pageY > $(window).height())) { - DetachTabs(DragAndDrop.TabsIds); - } - } + }, 200); + $(".drop_target").css({"pointer-events": "none"}); }); - - - // dragging groups - $(document).on("dragstart", ".group_drag_box", function(event) { + $(document).on("dragstart", ".group_drag_box", function(event) { // DRAGGING GROUPS event.originalEvent.dataTransfer.setData("null", "null"); event.originalEvent.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); DragAndDrop.DragNodeClass = "group"; DragAndDrop.DragNode = $(this).parent(); $(".highlighted_drop_target").removeClass("highlighted_drop_target"); }); - - - // when dragging the group, move it up or down - $(document).on("dragenter", ".group_drag_box", function(event) { - if (DragAndDrop.DragNode != undefined && DragAndDrop.DragNodeClass == "group" && $(this).parent() != DragAndDrop.DragNode) { - if ( $(this).parent().index() <= DragAndDrop.DragNode.index() ) { - DragAndDrop.DragNode.insertBefore($(this).parent()); - } else { - if ($(this).parent().index() > DragAndDrop.DragNode.index()) { - DragAndDrop.DragNode.insertAfter($(this).parent()); + $(document).on("dragenter", ".group_drag_box", function(event) { // WHEN DRAGGING THE GROUP, MOVE IT UP OR DOWN + if (DragAndDrop.DragNodeClass == "group") { + if (DragAndDrop.DragNode != undefined && $(this).parent() != DragAndDrop.DragNode) { + if ($(this).parent().index() <= DragAndDrop.DragNode.index()) { + DragAndDrop.DragNode.insertBefore($(this).parent()); + } else { + if ($(this).parent().index() > DragAndDrop.DragNode.index()) { + DragAndDrop.DragNode.insertAfter($(this).parent()); + } } + $(".highlighted_drop_target").removeClass("highlighted_drop_target"); } - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); } }); - - // when finished dragging the group - $(document).on("dragend", ".group_drag_box", function(event) { - DragAndDrop.DragNodeClass = ""; + $(document).on("dragend", ".group_drag_box", function(event) { // WHEN FINISHED DRAGGING THE GROUP DragAndDrop.DragNode = undefined; UpdateBgGroupsOrder(); $(".highlighted_drop_target").removeClass("highlighted_drop_target"); + RearrangeGroupsLists(); + $(".drop_target").css({"pointer-events": "none"}); + if (opt.syncro_tabbar_groups_tabs_order) { + schedule_rearrange_tabs++; + } }); } - - function DropToTarget(TargetNode) { - // dropped on pin - if (TargetNode.parent().is(".pin")) { - $(".selected").each(function() { - SetTabClass({ id: this.id, pin: true }); + if (DragAndDrop.DragNodeClass == "tab") { + if (TargetNode.parent().is(".pin")) { // dropped on pin + $(".selected_tab").each(function() { + SetTabClass({ id: this.id, pin: true }); + if (TargetNode.is(".drag_entered_top")) { + $(this).insertBefore(TargetNode.parent()); + } else { + $(this).insertAfter(TargetNode.parent()); + } + }); + } + if (TargetNode.is("#pin_list")) { // dropped on pin_list + $(".selected_tab").each(function() { + SetTabClass({ id: this.id, pin: true }); + }); + TargetNode.append($(".selected_tab")); + } + if (TargetNode.parent().is(".tab, .folder")) { // dropped on tab or folder + if (TargetNode.parent().is(".selected_tab")) { + TargetNode.parent().addClass("highlighted_selected").removeClass("selected_tab"); + } + $(".selected_tab").each(function() { + SetTabClass({ id: this.id, pin: false }); + }); if (TargetNode.is(".drag_entered_top")) { - $(this).insertBefore(TargetNode.parent()); - } else { - $(this).insertAfter(TargetNode.parent()); + $($(".selected_tab").get().reverse()).insertBefore(TargetNode.parent()); } - }); - } - - // dropped on pin_list - if (TargetNode.is("#pin_list")) { - $(".selected").each(function() { - SetTabClass({ id: this.id, pin: true }); - }); - TargetNode.append($(".selected")); - } - - // dropped on tab - if (TargetNode.parent().is(".tab, .folder")) { - if (TargetNode.parent().is(".selected")) { - TargetNode.parent().addClass("highlighted_selected").removeClass("selected"); - } - $(".selected").each(function() { - SetTabClass({ id: this.id, pin: false }); - }); - if (TargetNode.is(".drag_entered_top")) { - $($(".selected").get().reverse()).insertBefore(TargetNode.parent()); - } - if (TargetNode.is(".drag_entered_bottom")) { - $($(".selected").get().reverse()).insertAfter(TargetNode.parent()); - } - if (TargetNode.is(".drag_enter_center")) { - if (opt.append_child_tab == "bottom") { - $("#ch" + TargetNode[0].id.substr(2)).append($($(".selected").get().reverse())); - } else { - $("#ch" + TargetNode[0].id.substr(2)).prepend($($(".selected").get().reverse())); + if (TargetNode.is(".drag_entered_bottom")) { + $($(".selected_tab").get().reverse()).insertAfter(TargetNode.parent()); + } + if (TargetNode.is(".drag_enter_center")) { + if (opt.append_child_tab == "bottom") { + $("#ch" + TargetNode[0].id.substr(2)).append($($(".selected_tab").get().reverse())); + } else { + $("#ch" + TargetNode[0].id.substr(2)).prepend($($(".selected_tab").get().reverse())); + } } } - } - - // dropped on group (tab list) - if (TargetNode.is(".group")) { - $(".selected").each(function() { - SetTabClass({ id: this.id, pin: false }); - }); - TargetNode.append($($(".selected").get().reverse())); - } - - // dropped on group button (group list) - if (TargetNode.is(".group_drag_box")) { - $(".selected").each(function() { - SetTabClass({ id: this.id, pin: false }); - }); - $("#"+TargetNode[0].id.substr(1)).append($($(".selected").get().reverse())); + if (TargetNode.is(".group")) { // dropped on group (tab list) + $(".selected_tab").each(function() { + SetTabClass({ id: this.id, pin: false }); + }); + $("#ch"+TargetNode[0].id).append($($(".selected_tab").get().reverse())); + } + if (TargetNode.is(".group_drag_box")) { // dropped on group button (group list) + $(".selected_tab").each(function() { + SetTabClass({ id: this.id, pin: false }); + }); + $("#ch"+TargetNode[0].id.substr(1)).append($($(".selected_tab").get().reverse())); + } + $(".highlighted_selected").addClass("selected_tab").removeClass("highlighted_selected"); + $(".selected_frozen").addClass("selected_tab").removeClass("selected_frozen"); + $(".selected_temporarly").removeClass("selected_tab").removeClass("selected_temporarly"); } - - $(".highlighted_selected").addClass("selected").removeClass("highlighted_selected"); - - - - - - - // if ($(".tab.active:visible")[0] == undefined) { - // bggroups[$("#"+tabId).parents(".group")[0].id].activetab = parseInt(tabId); - - // if ($("#"+tabId).parents(".group")[0].id != active_group) { - // SetActiveGroup($("#"+tabId).parents(".group")[0].id, false, true); - // } - - - // chrome.runtime.sendMessage({command: "save_groups", groups: bggroups, windowId: CurrentWindowId}); - - - - // } - - - - + if (DragAndDrop.DragNodeClass == "folder") { // dropped on group button (group list) + if (TargetNode.is(".group_drag_box")) { + $("#cf"+TargetNode[0].id.substr(1)).append($($(".selected_folder").get().reverse())); + } + if (TargetNode.parent().is(".folder")) { // dropped on folder + if (TargetNode.parent().is(".selected_folder")) { + TargetNode.parent().addClass("highlighted_selected").removeClass("selected_folder"); + } + if (TargetNode.is(".drag_entered_top")) { + $($(".selected_folder").get().reverse()).insertBefore(TargetNode.parent()); + } + if (TargetNode.is(".drag_entered_bottom")) { + $($(".selected_folder").get().reverse()).insertAfter(TargetNode.parent()); + } + if (TargetNode.is(".drag_enter_center")) { + if (opt.append_child_tab == "bottom") { + $("#cf" + TargetNode[0].id.substr(2)).append($($(".selected_folder").get().reverse())); + } else { + $("#cf" + TargetNode[0].id.substr(2)).prepend($($(".selected_folder").get().reverse())); + } + } + } + $(".highlighted_selected").addClass("selected_folder").removeClass("highlighted_selected"); + $(".selected_folder_frozen").addClass("selected_folder").removeClass("selected_folder_frozen"); + $(".selected_folder_temporarly").removeClass("selected_folder").removeClass("selected_folder_temporarly"); + setTimeout(function() { + SaveFolders(); + }, 300); + } RefreshExpandStates(); DragAndDrop.timeout = false; RefreshGUI(); + RefreshCounters(); + + if (opt.syncro_tabbar_tabs_order) { + let TTtabsIndexes = $(".pin, .tab").map(function(){return parseInt(this.id);}).toArray(); + chrome.tabs.move(DragAndDrop.TabsIds, {index: TTtabsIndexes.indexOf(DragAndDrop.TabsIds[0])}); + setTimeout(function() { + schedule_rearrange_tabs++; + }, 500); + } + setTimeout(function() { - DropTargetsSendToBack(); schedule_update_data++; - schedule_rearrange_tabs++; }, 500); - - TargetNode.removeClass("highlighted_drop_target"); $(".tab_header_hover").removeClass("tab_header_hover"); - $(".selected_frozen").addClass("selected").removeClass("selected_frozen"); - $(".selected_temporarly").removeClass("selected").removeClass("selected_temporarly"); - - // this is group dragover indicator - $(".dragover_highlight").removeClass("dragover_highlight"); -} + $(".folder_header").removeClass("folder_header_hover"); + $(".dragover_highlight").removeClass("dragover_highlight"); // this is group dragover indicator +} \ No newline at end of file diff --git a/scripts/folders.js b/scripts/folders.js index 7b2cc38..bd86d59 100644 --- a/scripts/folders.js +++ b/scripts/folders.js @@ -3,70 +3,193 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ -function AddNewFolder() { - var ID = GenerateNewFolderID(); - AppendFolder({id: ID, name: "untitled"}); +function AddNewFolder(p) { + var newId = GenerateNewFolderID(); + bgfolders[newId] = { id: newId, parent: (p.ParentId ? p.ParentId : ""), index: (p.index ? p.index : 0), name: (p.name ? p.name : caption_noname_group), expand: (p.expand ? p.expand : "n") }; + AppendFolder({id: newId, ParentId: (p.ParentId ? p.ParentId : ""), name: caption_noname_group}); + SaveFolders(); + RefreshCounters(); + return newId; } - function AppendFolder(param) { - var fd = document.createElement("div"); fd.className = "folder c"; fd.id = param.id;// FOLDER - var dc = document.createElement("div"); dc.className = "drop_target drag_enter_center"; dc.id = "dc"+param.id; fd.appendChild(dc); // DROP TARGET CENTER - var dt = document.createElement("div"); dt.className = "drop_target drag_entered_top"; dt.id = "du"+param.id; fd.appendChild(dt); // DROP TARGET TOP - var db = document.createElement("div"); db.className = "drop_target drag_entered_bottom"; db.id = "dd"+param.id; fd.appendChild(db); // DROP TARGET BOTTOM - - - var fh = document.createElement("div"); fh.className = "folder_header"; fh.id = "tab_header"+param.id; fh.draggable = true; fd.appendChild(fh); // HEADER - var ex = document.createElement("div"); ex.className = "folder_icon"; ex.id = "fop"+param.id; fh.appendChild(ex); - var ft = document.createElement("div"); ft.className = "folder_title"; ft.id = "folder_title"+param.id; ft.textContent = param.name; fh.appendChild(ft); // TITLE - // $("#tab_title" + tab.id)[0].textContent = title; - // $("#tab_header" + tab.id).attr("title", title); - - - - - var ch = document.createElement("div"); ch.className = "children"; ch.id = "ch"+param.id; fd.appendChild(ch); - // var tt = document.createElement("div"); tt.className = "tab_title"; tt.id = "tab_title"+param.tab.id; th.appendChild(tt); // TITLE - - $("#"+active_group).append(fd); - + if ($("#"+param.id).length == 0) { + var fd = document.createElement("div"); fd.className = "folder "; if (param.expand) { fd.className += param.expand } fd.id = param.id;// FOLDER + var dc = document.createElement("div"); dc.className = "drop_target drag_enter_center"; dc.id = "dc"+param.id; fd.appendChild(dc); // DROP TARGET CENTER + var dt = document.createElement("div"); dt.className = "drop_target drag_entered_top"; dt.id = "du"+param.id; fd.appendChild(dt); // DROP TARGET TOP + var db = document.createElement("div"); db.className = "drop_target drag_entered_bottom"; db.id = "dd"+param.id; fd.appendChild(db); // DROP TARGET BOTTOM + var fh = document.createElement("div"); fh.className = opt.always_show_close ? "folder_header close_show" : "folder_header"; fh.id = "folder_header"+param.id; fh.draggable = true; fd.appendChild(fh); // HEADER + var ex = document.createElement("div"); ex.className = "folder_icon"; ex.id = "fop"+param.id; fh.appendChild(ex); + var ft = document.createElement("div"); ft.className = "folder_title"; ft.id = "folder_title"+param.id; ft.textContent = param.name; fh.appendChild(ft); // TITLE + var cf = document.createElement("div"); cf.className = "children"; cf.id = "cf"+param.id; fd.appendChild(cf); + var ch = document.createElement("div"); ch.className = "children"; ch.id = "ch"+param.id; fd.appendChild(ch); + if (!opt.never_show_close) { + var cl = document.createElement("div"); cl.className = "close"; cl.id = "close"+param.id; fh.appendChild(cl); // CLOSE BUTTON + var ci = document.createElement("div"); ci.className = "close_img"; ci.id = "close_img"+param.id; cl.appendChild(ci); + } + if (param.ParentId == "" || param.ParentId == undefined || $("#cf"+param.ParentId).length == 0) { + $("#cf"+active_group).append(fd); + } else { + $("#cf"+param.ParentId).append(fd); + } + } } - -function GenerateNewFolderID(){ +function GenerateNewFolderID() { var newID = "f_"+GenerateRandomID(); - console.log("generating "+newID); if ($("#"+newID)[0]) { GenerateNewFolderID(); - console.log("exists "+newID); } else { - console.log("yay this is ok "+newID); return newID; } } - +function AppendFolders(Folders) { + for (var folderId in Folders) { + AppendFolder({id: folderId, ParentId: Folders[folderId].parent, name: Folders[folderId].name, expand: Folders[folderId].expand}); + } + // APPEND FOLDERS TO PARENTS + for (var folderId in Folders) { + if ($("#"+folderId)[0] && Folders[folderId].parent != $("#"+folderId).parent().parent()[0].id) { + $("#cf"+Folders[folderId].parent).append($("#"+folderId)); + } + } +} +function SaveFolders() { + $(".folder").each(function() { + bgfolders[this.id].parent = $(this).parent().parent()[0].id; + bgfolders[this.id].index = $(this).index(); + bgfolders[this.id].expand = ($(this).is(".n") ? "n" : ($(this).is(".c") ? "c" : "o")); + }); + chrome.runtime.sendMessage({command: "save_folders", folders: bgfolders, windowId: CurrentWindowId}); +} +function RearrangeFolders(first_loop) { + $(".folder").each(function() { + if (bgfolders[this.id] && $(this).parent().children().eq(bgfolders[this.id].index)[0]) { + if ($(this).index() > bgfolders[this.id].index) { + $(this).insertBefore($(this).parent().children().eq(bgfolders[this.id].index)); + } else { + $(this).insertAfter($(this).parent().children().eq(bgfolders[this.id].index)); + } + } + if (bgfolders[this.id] && $(this).index() != bgfolders[this.id].index && first_loop) { + RearrangeFolders(false); + } + }); +} +function RemoveFolder(FolderId) { + if ($("#"+FolderId)[0]) { + if (opt.promote_children == true) { + if (opt.promote_children_in_first_child == true && $("#cf"+FolderId).children().length > 0) { + let FirstChild = $("#cf"+FolderId).children()[0]; + $(FirstChild).insertAfter($("#"+FolderId)); + $("#cf"+FirstChild.id).append($("#cf"+FolderId).children()); + if ($("#ch"+FolderId).children().length > 0) { + $("#ch"+FirstChild.id).append($("#ch"+FolderId).children()); + } + } else { + $("#ch"+($("#"+FolderId).parent().parent()[0].id)).append($("#ch"+FolderId).children()); + $("#cf"+FolderId).children().insertAfter($("#"+FolderId)); + } + } else { + $("#"+FolderId+" .tab").each(function() { + chrome.tabs.remove(parseInt(this.id), null); + }); + $("#"+FolderId+" .folder").each(function() { + delete bgfolders[this.id]; + }); + } + $("#"+FolderId).remove(); + delete bgfolders[FolderId]; + RefreshExpandStates(); + chrome.runtime.sendMessage({command: "save_folders", folders: bgfolders, windowId: CurrentWindowId}); + } +} +function SetActiveFolder(FolderId) { + if ($("#"+FolderId).length > 0) { + $(".selected_folder").removeClass("selected_folder"); + $("#"+FolderId).addClass("selected_folder"); + } +} +// Rename folder popup +function ShowRenameFolderDialog(FolderId) { + $("#folder_edit_name")[0].value = bgfolders[FolderId].name; + $("#folder_edit_name").data("FolderId", FolderId); + $("#folder_edit").css({"display": "block", "top": $("#toolbar_groups").offset().top + 8, "left": 22}); +} +// when pressed OK in folder popup +function FolderRenameConfirm() { + $("#folder_edit_name")[0].value = $("#folder_edit_name")[0].value.replace(/[\f\n\r\v\t\<\>\+\-\(\)\.\,\;\:\~\/\|\?\@\!\"\'\£\$\%\&\^\#\=\*\[\]]?/gi, ""); + bgfolders[$("#folder_edit_name").data("FolderId")].name = $("#folder_edit_name")[0].value; + $("#folder_title"+$("#folder_edit_name").data("FolderId"))[0].innerText = $("#folder_edit_name")[0].value; + $(".edit_dialog").hide(0); + chrome.runtime.sendMessage({command: "save_folders", folders: bgfolders, windowId: CurrentWindowId}); + RefreshCounters(); +} function SetFolderEvents() { // EXPAND BOX - EXPAND / COLLAPSE - $(document).on("mousedown", ".folder_icon", function(event) { + $(document).on("click", ".folder_icon", function(event) { event.stopPropagation(); if (event.button == 0) { if ($(this).parent().parent().is(".o")) { $(this).parent().parent().removeClass("o").addClass("c"); - // chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt($(this).parent().parent()[0].id), tab: { expand: "c" } }); } else { if ($(this).parent().parent().is(".c")) { $(this).parent().parent().removeClass("c").addClass("o"); - // chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt($(this).parent().parent()[0].id), tab: { expand: "o" } }); - // if (opt.close_other_trees) { - // $(".o:visible:not(#"+$(this).parent().parent()[0].id+")").removeClass("o").addClass("c"); - // $(this).parents(".tab").each(function() { - // $(this).removeClass("n").removeClass("c").addClass("o"); - // chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(this.id), tab: { expand: "o" } }); - // }); - // $(".c").each(function() { - // chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(this.id), tab: { expand: "c" } }); - // }); - // } } } + RefreshExpandStates(); + RefreshCounters(); + SaveFolders(); + } + }); + // SINGLE CLICK TO ACTIVATE FOLDER + $(document).on("click", ".folder_header", function(event) { + event.stopPropagation(); + if (event.button == 0 && !event.shiftKey) { + $("#"+active_group+" .tab").removeClass("selected_tab"); + if (!event.ctrlKey) { + $(".selected_folder:not(#"+($(this).parent()[0].id)+")").removeClass("selected_folder"); + } + // SetActiveFolder(); + $(this).parent().toggleClass("selected_folder"); + } + }); + // CLOSE TAB/PIN + $(document).on("mousedown", ".folder_header", function(event) { + if ((event.button == 1 && opt.close_with_MMB == true) || (event.button == 0 && $(event.target).is(".close, .close_img"))) { + RemoveFolder($(this).parent()[0].id); + } + if (event.button == 2) { + event.stopPropagation(); + ShowFolderMenu($(this).parent(), event); + } + }); + // edit folder dialog box + $(document).on("mousedown", "#folder_edit_discard", function(event) { + $(".edit_dialog").hide(0); + }); + $("#folder_edit_name").keyup(function(e) { + if (e.keyCode == 13) { + FolderRenameConfirm(); + } + }); + $(document).on("mousedown", "#folder_edit_confirm", function(event) { + FolderRenameConfirm(); + }); + // edit folder + $(document).on("dblclick", ".folder_title", function(event) { + if (event.button == 0) { + ShowRenameFolderDialog($(this).parent().parent()[0].id); + } + }); + $(document).on("mouseover", ".folder_header", function(event) { + $(this).addClass("folder_header_hover"); + if (opt.always_show_close == false) { + $(this).addClass("close_show"); + } + }); + $(document).on("mouseleave", ".folder_header", function(event) { + $(this).removeClass("folder_header_hover"); + if (opt.always_show_close == false) { + $(this).removeClass("close_show"); } }); } \ No newline at end of file diff --git a/scripts/global.js b/scripts/global.js index 8405ab1..33c0fc0 100644 --- a/scripts/global.js +++ b/scripts/global.js @@ -4,41 +4,42 @@ // ********** GLOBAL VARIABLES FOR BACKGROUND, OPTIONS AND SIDEBAR *************** - var running = false; -var schedule_save = 0; -var schedule_update_indexes = 0; +var schedule_save = -999; +var schedule_update_data = 0; var schedule_rearrange_tabs = 0; +var schedule_rearrange_reverse = false; var windows = {}; var tabs = {}; - var MouseHoverOver = ""; - - -var DragAndDrop = {timeout: false, DragNode: undefined, DragNodeClass: "", SelectedTabsIds: [], TabsIds: [], Parents: [], ComesFromWindowId: 0, Depth: 0}; -var DropTargetsInFront = false; - - -var menuTabId = 0; +var DragAndDrop = { + timeout: false, + DragNode: undefined, + DragNodeClass: "", + TabsIds: [], + TabsIdsParents: [], + TabsIdsSelected: [], + Folders: {}, + FoldersSelected: [], + ComesFromWindowId: 0, + DroppedToWindowId: 0, + Depth: 0 +}; +var menuItemId = 0; var CurrentWindowId = 0; var SearchIndex = 0; -var schedule_update_data = 0; var active_group = "tab_list"; var PickColor = ""; - var opt = {}; var browserId = navigator.userAgent.match("Opera") !== null ? "O" : ( navigator.userAgent.match("Vivaldi") !== null ? "V" : (navigator.userAgent.match("Firefox") !== null ? "F" : "C" ) ); - var bgtabs = {}; var bggroups = {}; - +var bgfolders = {}; var caption_clear_filter = chrome.i18n.getMessage("caption_clear_filter"); var caption_loading = chrome.i18n.getMessage("caption_loading"); var caption_searchbox = chrome.i18n.getMessage("caption_searchbox"); - var caption_ungrouped_group = chrome.i18n.getMessage("caption_ungrouped_group"); var caption_noname_group = chrome.i18n.getMessage("caption_noname_group"); - var DefaultToolbar = '
    '+ '
    '+ @@ -48,7 +49,7 @@ var DefaultToolbar = '
    '+ '
    '+ '
    '+ - // '
    '+ + '
    '+ '
    '+ '