2018-12-13 23:55:34 +01:00
function Toolbar _RestoreToolbarSearchFilter ( ) { // RESTORE LAST USED SEARCH TYPE (URL OR TITLE) IN TOOLBAR SEARCH
chrome . runtime . sendMessage ( { command : "get_search_filter" , windowId : tt . CurrentWindowId } , function ( response ) {
if ( response == "url" ) {
DOM _SetClasses ( document . getElementById ( "button_filter_type" ) , [ "url" ] , [ "title" ] , [ ] ) ;
} else {
DOM _SetClasses ( document . getElementById ( "button_filter_type" ) , [ "title" ] , [ "url" ] , [ ] ) ;
}
} ) ;
2017-07-26 22:23:39 +02:00
}
2018-12-13 23:55:34 +01:00
function Toolbar _RestoreToolbarShelf ( ) { // RESTORE LAST ACTIVE SHELF (SEARCH, TOOLS, GROUPS, SESSION OR FOLDER) IN TOOLBAR
chrome . runtime . sendMessage ( { command : "get_active_shelf" , windowId : tt . CurrentWindowId } , function ( response ) {
let filterBox = document . getElementById ( "filter_box" ) ;
filterBox . setAttribute ( "placeholder" , labels . searchbox ) ;
filterBox . style . opacity = "1" ;
let query = document . querySelectorAll ( ".on" ) ;
for ( let s of query ) {
s . classList . remove ( "on" ) ;
}
query = document . querySelectorAll ( ".toolbar_shelf" ) ;
for ( let s of query ) {
s . classList . add ( "hidden" ) ;
}
if ( response == "search" && document . getElementById ( "button_search" ) != null ) {
document . getElementById ( "toolbar_search" ) . classList . remove ( "hidden" ) ;
document . getElementById ( "button_search" ) . classList . add ( "on" ) ;
}
if ( response == "tools" && document . getElementById ( "button_tools" ) != null ) {
document . getElementById ( "toolbar_shelf_tools" ) . classList . remove ( "hidden" ) ;
document . getElementById ( "button_tools" ) . classList . add ( "on" ) ;
}
if ( response == "groups" && document . getElementById ( "button_groups" ) != null ) {
document . getElementById ( "toolbar_shelf_groups" ) . classList . remove ( "hidden" ) ;
document . getElementById ( "button_groups" ) . classList . add ( "on" ) ;
}
if ( response == "backup" && document . getElementById ( "button_backup" ) != null ) {
document . getElementById ( "toolbar_shelf_backup" ) . classList . remove ( "hidden" ) ;
document . getElementById ( "button_backup" ) . classList . add ( "on" ) ;
}
if ( response == "folders" && document . getElementById ( "button_folders" ) != null ) {
document . getElementById ( "toolbar_shelf_folders" ) . classList . remove ( "hidden" ) ;
document . getElementById ( "button_folders" ) . classList . add ( "on" ) ;
}
if ( browserId != "F" ) {
chrome . storage . local . get ( null , function ( storage ) {
let bak1 = storage [ "windows_BAK1" ] ? storage [ "windows_BAK1" ] : [ ] ;
let bak2 = storage [ "windows_BAK2" ] ? storage [ "windows_BAK2" ] : [ ] ;
let bak3 = storage [ "windows_BAK3" ] ? storage [ "windows_BAK3" ] : [ ] ;
if ( bak1 . length && document . getElementById ( "#button_load_bak1" ) != null ) {
document . getElementById ( "button_load_bak1" ) . classList . remove ( "disabled" ) ;
} else {
document . getElementById ( "button_load_bak1" ) . classList . add ( "disabled" ) ;
}
if ( bak2 . length && document . getElementById ( "#button_load_bak2" ) != null ) {
document . getElementById ( "button_load_bak2" ) . classList . remove ( "disabled" ) ;
} else {
document . getElementById ( "button_load_bak2" ) . classList . add ( "disabled" ) ;
}
if ( bak3 . length && document . getElementById ( "#button_load_bak3" ) != null ) {
document . getElementById ( "button_load_bak3" ) . classList . remove ( "disabled" ) ;
} else {
document . getElementById ( "button_load_bak3" ) . classList . add ( "disabled" ) ;
}
} ) ;
}
DOM _RefreshGUI ( ) ;
} ) ;
2017-11-12 22:00:40 +01:00
}
2017-07-26 22:23:39 +02:00
2018-12-13 23:55:34 +01:00
function Toolbar _ShelfToggle ( mousebutton , button , toolbarId , SendMessage , SidebarRefreshGUI , OptionsRefreshGUI ) { // FUNCTION TO TOGGLE SHELFS AND SAVE IT
if ( mousebutton == 1 ) {
if ( button . classList . contains ( "on" ) ) {
let query = document . querySelectorAll ( ".on" ) ;
for ( let s of query ) {
s . classList . remove ( "on" ) ;
}
query = document . querySelectorAll ( ".toolbar_shelf" ) ;
for ( let s of query ) {
s . classList . add ( "hidden" ) ;
}
chrome . runtime . sendMessage ( { command : "set_active_shelf" , active _shelf : "" , windowId : tt . CurrentWindowId } ) ;
} else {
let query = document . querySelectorAll ( ".toolbar_shelf:not(#" + toolbarId + ")" ) ;
for ( let s of query ) {
s . classList . add ( "hidden" ) ;
}
document . getElementById ( toolbarId ) . classList . remove ( "hidden" ) ;
chrome . runtime . sendMessage ( { command : "set_active_shelf" , active _shelf : SendMessage , windowId : tt . CurrentWindowId } ) ;
query = document . querySelectorAll ( ".on:not(#" + button . id + ")" ) ;
for ( let s of query ) {
s . classList . remove ( "on" ) ;
}
button . classList . add ( "on" ) ;
}
if ( SidebarRefreshGUI ) DOM _RefreshGUI ( ) ;
if ( OptionsRefreshGUI ) RefreshGUI ( ) ;
}
2018-05-22 02:11:29 +02:00
}
2018-12-13 23:55:34 +01:00
function Toolbar _RemoveToolbar ( ) {
let toolbar = document . getElementById ( "toolbar" ) ;
while ( toolbar . hasChildNodes ( ) ) {
toolbar . removeChild ( toolbar . firstChild ) ;
}
2018-05-22 02:11:29 +02:00
}
2018-12-13 23:55:34 +01:00
function Toolbar _RecreateToolbar ( NewToolbar ) {
let toolbar = document . getElementById ( "toolbar" ) ;
for ( var shelf in NewToolbar ) {
let NewShelf = DOM _New ( "div" , toolbar , { id : shelf , className : "toolbar_shelf" } ) ;
for ( let button of NewToolbar [ shelf ] ) {
let Newbutton = DOM _New ( "div" , NewShelf , { id : button , className : "button" } ) ;
DOM _New ( "div" , Newbutton , { className : "button_img" } ) ;
}
}
let toolbar _main = document . getElementById ( "toolbar_main" ) ;
let SearchShelf = document . getElementById ( "toolbar_search" ) ;
if ( toolbar _main != null && SearchShelf != null ) {
toolbar _main . classList . remove ( "toolbar_shelf" ) ;
let SearchBox = DOM _New ( "div" , SearchShelf , { id : "toolbar_search_input_box" } ) ;
DOM _New ( "input" , SearchBox , { id : "filter_box" , className : "text_input" , type : "text" , placeholder : labels . searchbox } ) ;
DOM _New ( "div" , SearchBox , { id : "button_filter_clear" , type : "reset" } , { opacity : "0" , position : "absolute" } ) ;
let SearchButtons = DOM _New ( "div" , SearchShelf , { id : "toolbar_search_buttons" } ) ;
DOM _AppendToNode ( document . getElementById ( "button_filter_type" ) , SearchButtons ) ;
DOM _AppendToNode ( document . getElementById ( "filter_search_go_prev" ) , SearchButtons ) ;
DOM _AppendToNode ( document . getElementById ( "filter_search_go_next" ) , SearchButtons ) ;
DOM _Loadi18n ( ) ;
}
2018-05-22 02:11:29 +02:00
}
2018-12-13 23:55:34 +01:00
function Toolbar _RecreateToolbarUnusedButtons ( buttonsIds ) { // OPTIONS PAGE
let unused _buttons = document . getElementById ( "toolbar_unused_buttons" ) ;
for ( let button of buttonsIds ) {
let Newbutton = DOM _New ( "div" , unused _buttons , { id : button , className : "button" } ) ;
DOM _New ( "div" , Newbutton , { className : "button_img" } ) ;
}
2018-05-22 02:11:29 +02:00
}
2018-12-13 23:55:34 +01:00
function Toolbar _SaveToolbar ( ) { // OPTIONS PAGE
let unused _buttons = [ ] ;
let toolbar = { } ;
let unused _buttons _div = document . querySelectorAll ( "#toolbar_unused_buttons .button" ) ;
for ( let b of unused _buttons _div ) {
unused _buttons . push ( b . id ) ;
}
let toolbar _div = document . getElementById ( "toolbar" ) ;
for ( let toolbar _shelf of toolbar _div . childNodes ) {
toolbar [ toolbar _shelf . id ] = [ ] ;
let query = document . querySelectorAll ( "#" + toolbar _shelf . id + " .button" ) ;
for ( let button of query ) {
toolbar [ toolbar _shelf . id ] . push ( button . id ) ;
}
}
chrome . storage . local . set ( { toolbar : toolbar } ) ;
chrome . storage . local . set ( { unused _buttons : unused _buttons } ) ;
setTimeout ( function ( ) { chrome . runtime . sendMessage ( { command : "reload_toolbar" , toolbar : toolbar , opt : opt } ) ; } , 50 ) ;
}
2018-05-22 02:11:29 +02:00
2018-12-13 23:55:34 +01:00
// ASSIGN MOUSE EVENTS FOR TOOLBAR BUTTONS, (Buttons AND BindToolbarShelfToggleButtons), PARAMETERS DECIDE IF BUTTONS ARE CLICKABLE
2018-03-13 14:39:34 +01:00
// IN OPTIONS PAGE - TOOLBAR BUTTONS SAMPLES, MUST NOT CALL FUNCTIONS ON CLICKS, BUT STILL SHELFS BUTTONS MUST TOGGLE AND MOREOVER ON CLICK AND NOT ON MOUSEDOWN THIS IS WHERE ToolbarShelfToggleClickType="Click" IS NECESSARY
2018-12-13 23:55:34 +01:00
function Toolbar _SetToolbarEvents ( CleanPreviousBindings , BindButtons , BindToolbarShelfToggleButtons , ToolbarShelfToggleClickType , SidebarRefreshGUI , OptionsRefreshGUI ) {
let ClearSearch = document . getElementById ( "button_filter_clear" ) ;
let FilterBox = document . getElementById ( "filter_box" ) ;
if ( ClearSearch != null && FilterBox != null ) {
if ( CleanPreviousBindings ) {
FilterBox . removeEventListener ( "oninput" , function ( ) { } ) ;
ClearSearch . removeEventListener ( "onmousedown" , function ( ) { } ) ;
}
if ( BindButtons ) {
// FILTER ON INPUT
FilterBox . oninput = function ( event ) {
Tabs _FindTab ( this . value ) ;
}
// CLEAR FILTER BUTTON
ClearSearch . onmousedown = function ( event ) {
if ( event . which == 1 ) {
this . style . opacity = "0" ;
this . setAttribute ( "title" , "" ) ;
Tabs _FindTab ( "" ) ;
}
}
}
}
let query = document . querySelectorAll ( ".button" ) ;
for ( let s of query ) {
if ( CleanPreviousBindings ) {
s . removeEventListener ( "onmousedown" , function ( ) { } ) ;
s . removeEventListener ( "onclick" , function ( ) { } ) ;
s . removeEventListener ( "click" , function ( ) { } ) ;
}
if ( BindToolbarShelfToggleButtons ) {
if ( s . id == "button_search" ) {
s . addEventListener ( ToolbarShelfToggleClickType , function ( event ) {
if ( event . which == 1 ) Toolbar _ShelfToggle ( event . which , this , "toolbar_search" , "search" , SidebarRefreshGUI , OptionsRefreshGUI ) ;
} ) ;
}
if ( s . id == "button_tools" ) {
s . addEventListener ( ToolbarShelfToggleClickType , function ( event ) {
if ( event . which == 1 ) Toolbar _ShelfToggle ( event . which , this , "toolbar_shelf_tools" , "tools" , SidebarRefreshGUI , OptionsRefreshGUI ) ;
} ) ;
}
if ( s . id == "button_groups" ) {
s . addEventListener ( ToolbarShelfToggleClickType , function ( event ) {
if ( event . which == 1 ) Toolbar _ShelfToggle ( event . which , this , "toolbar_shelf_groups" , "groups" , SidebarRefreshGUI , OptionsRefreshGUI ) ;
} ) ;
}
if ( s . id == "button_backup" ) {
s . addEventListener ( ToolbarShelfToggleClickType , function ( event ) {
if ( event . which == 1 ) Toolbar _ShelfToggle ( event . which , this , "toolbar_shelf_backup" , "backup" , SidebarRefreshGUI , OptionsRefreshGUI ) ;
} ) ;
}
if ( s . id == "button_folders" ) {
s . addEventListener ( ToolbarShelfToggleClickType , function ( event ) {
if ( event . which == 1 ) Toolbar _ShelfToggle ( event . which , this , "toolbar_shelf_folders" , "folders" , SidebarRefreshGUI , OptionsRefreshGUI ) ;
} ) ;
}
}
if ( BindButtons ) {
if ( s . id == "button_new" ) { // NEW TAB
s . onclick = function ( event ) {
if ( event . which == 1 ) {
if ( opt . append _tab _from _toolbar == "group_root" ) Tabs _OpenNewTab ( false , undefined , document . getElementById ( "°" + tt . active _group ) ) ;
if ( opt . append _tab _from _toolbar == "as_regular_orphan" ) Tabs _OpenNewTab ( false , undefined , undefined ) ;
}
}
s . onmousedown = function ( event ) {
if ( event . which == 2 ) { // DUPLICATE TAB
event . preventDefault ( ) ;
let activeTab = document . querySelector ( "#" + tt . active _group + " .active_tab" ) != null ? document . querySelector ( "#" + tt . active _group + " .active_tab" ) : document . querySelector ( ".pin.active_tab" ) != null ? document . querySelector ( ".pin.active_tab" ) : null ;
if ( activeTab != null && tt . tabs [ activeTab . id ] ) tt . tabs [ activeTab . id ] . DuplicateTab ( ) ;
}
if ( event . which == 3 ) { // SCROLL TO TAB
chrome . tabs . query ( { currentWindow : true , active : true } , function ( activeTab ) {
if ( activeTab [ 0 ] . pinned && opt . pin _list _multi _row == false && tt . tabs [ activeTab [ 0 ] . id ] ) tt . tabs [ activeTab [ 0 ] . id ] . ScrollToTab ( ) ;
if ( activeTab [ 0 ] . pinned == false ) {
let Tab = document . getElementById ( activeTab [ 0 ] . id ) ;
let groupId = DOM _GetParentsByClass ( Tab , "group" ) [ 0 ] . id ;
Groups _SetActiveGroup ( groupId , true , true ) ;
}
} ) ;
}
}
}
if ( s . id == "button_pin" ) { // PIN TAB
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let Tabs = document . querySelectorAll ( ".pin.active_tab, .pin.selected, #" + tt . active _group + " .active_tab, #" + tt . active _group + " .selected" ) ;
for ( let s of Tabs ) {
chrome . tabs . update ( parseInt ( s . id ) , { pinned : Tabs [ 0 ] . classList . contains ( "tab" ) } ) ;
}
}
}
}
if ( s . id == "button_options" ) { // VERTICAL TABS OPTIONS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) chrome . tabs . create ( { url : "options/options.html" } ) ;
}
}
if ( s . id == "button_undo" ) { // UNDO CLOSE
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
chrome . sessions . getRecentlyClosed ( null , function ( sessions ) {
if ( sessions . length > 0 ) chrome . sessions . restore ( null , function ( restored ) { } ) ;
} ) ;
}
}
}
if ( s . id == "button_detach" || s . id == "button_move" ) { // MOVE TAB TO NEW WINDOW (DETACH), move is legacy name of detach button
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
DOM _FreezeSelection ( false ) ;
let Nodes = [ ] ;
let NodesTypes = { DraggingPin : false , DraggingTab : false , DraggingFolder : false } ;
let query = [ ] ;
if ( document . querySelectorAll ( ".selected" ) . length > 0 ) {
query = document . querySelectorAll ( ".selected, .selected .tab, .selected .folder" ) ;
} else {
query = document . querySelectorAll ( ".active_tab" ) ;
}
for ( let s of query ) {
if ( s . classList . contains ( "pin" ) ) {
NodesTypes . DraggingPin = true ;
Nodes . push ( { id : s . id , parent : s . parentNode . id , selected : s . classList . contains ( "selected" ) , temporary : s . classList . contains ( "selected_temporarly" ) , NodeClass : "pin" } ) ;
}
if ( s . classList . contains ( "tab" ) ) {
NodesTypes . DraggingTab = true ;
Nodes . push ( { id : s . id , parent : s . parentNode . id , selected : s . classList . contains ( "selected" ) , temporary : s . classList . contains ( "selected_temporarly" ) , NodeClass : "tab" } ) ;
}
if ( s . classList . contains ( "folder" ) ) {
NodesTypes . DraggingFolder = true ;
Nodes . push ( { id : s . id , parent : s . parentNode . id , selected : s . classList . contains ( "selected" ) , temporary : s . classList . contains ( "selected_temporarly" ) , NodeClass : "folder" , index : ( tt . folders [ s . id ] ? tt . folders [ s . id ] . index : 0 ) , name : ( tt . folders [ s . id ] ? tt . folders [ s . id ] . name : labels . noname _group ) , expand : ( tt . folders [ s . id ] ? tt . folders [ s . id ] . expand : "" ) } ) ;
}
}
Tabs _Detach ( Nodes , NodesTypes , { } ) ;
}
}
}
if ( s . id == "filter_search_go_prev" ) { // GO TO PREVIOUS SEARCH RESULT
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let filtered = document . querySelectorAll ( "#" + tt . active _group + " .tab.filtered" ) ;
if ( filtered . length > 0 ) {
let query = document . querySelectorAll ( ".highlighted_search" ) ;
for ( let s of query ) {
s . classList . remove ( "highlighted_search" ) ;
}
if ( tt . SearchIndex == 0 ) {
tt . SearchIndex = filtered . length - 1 ;
} else {
tt . SearchIndex -- ;
}
filtered [ tt . SearchIndex ] . classList . add ( "highlighted_search" ) ;
if ( tt . tabs [ filtered [ tt . SearchIndex ] . id ] ) tt . tabs [ filtered [ tt . SearchIndex ] . id ] . ScrollToTab ( ) ;
}
}
}
}
if ( s . id == "filter_search_go_next" ) { // GO TO NEXT SEARCH RESULT
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let filtered = document . querySelectorAll ( "#" + tt . active _group + " .tab.filtered" ) ;
if ( filtered . length > 0 ) {
let query = document . querySelectorAll ( ".highlighted_search" ) ;
for ( let s of query ) {
s . classList . remove ( "highlighted_search" ) ;
}
if ( tt . SearchIndex == filtered . length - 1 ) {
tt . SearchIndex = 0 ;
} else {
tt . SearchIndex ++ ;
}
filtered [ tt . SearchIndex ] . classList . add ( "highlighted_search" ) ;
if ( tt . tabs [ filtered [ tt . SearchIndex ] . id ] ) tt . tabs [ filtered [ tt . SearchIndex ] . id ] . ScrollToTab ( ) ;
}
}
}
}
if ( s . id == "button_groups_toolbar_hide" ) { // SHOW/HIDE GROUPS TOOLBAR
s . onmousedown = function ( event ) {
if ( event . which == 1 ) Groups _GroupsToolbarToggle ( ) ;
}
}
if ( s . id == "button_manager_window" ) { // SHOW GROUP MANAGER
s . onmousedown = function ( event ) {
if ( event . which == 1 && document . getElementById ( "manager_window" ) . style . top == "-500px" ) {
Manager _OpenManagerWindow ( ) ;
} else {
DOM _HideRenameDialogs ( ) ;
}
}
}
if ( s . id == "button_new_group" ) { // NEW GROUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let NewGroupId = Groups _AddNewGroup ( ) ;
Groups _ShowGroupEditWindow ( NewGroupId ) ;
}
}
}
if ( s . id == "button_remove_group" ) { // REMOVE GROUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
if ( tt . active _group != "tab_list" ) Groups _GroupRemove ( tt . active _group , event . shiftKey ) ;
}
}
}
if ( s . id == "button_edit_group" ) { // EDIT GROUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
if ( tt . active _group != "tab_list" ) Groups _ShowGroupEditWindow ( tt . active _group ) ;
}
}
}
if ( s . id == "button_export_group" ) { // EXPORT GROUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) Manager _ExportGroup ( tt . active _group , tt . groups [ tt . active _group ] . name , false ) ;
}
}
if ( s . id == "button_import_group" ) { // IMPORT GROUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let inputFile = File _ShowOpenFileDialog ( ".tt_group" ) ;
inputFile . onchange = function ( event ) {
Manager _ImportGroup ( true , false ) ;
}
}
}
}
if ( s . id == "button_new_folder" ) { // NEW FOLDER
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let FolderId = Folders _AddNewFolder ( { } ) ;
Folders _ShowRenameFolderDialog ( FolderId ) ;
}
}
}
if ( s . id == "button_edit_folder" ) { // RENAME FOLDER
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
if ( document . querySelectorAll ( "#" + tt . active _group + " .selected" ) . length > 0 ) Folders _ShowRenameFolderDialog ( document . querySelectorAll ( "#" + tt . active _group + " .selected" ) [ 0 ] . id ) ;
}
}
}
if ( s . id == "button_remove_folder" ) { // REMOVE FOLDERS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let query = document . querySelectorAll ( "#" + tt . active _group + " .selected" ) ;
for ( let s of query ) {
Folders _RemoveFolder ( s . id ) ;
}
}
}
}
if ( s . id == "button_unload" || s . id == "button_discard" ) { // DISCARD TABS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
if ( document . querySelectorAll ( ".pin.selected:not(.active_tab), #" + tt . active _group + " .selected:not(.active_tab)" ) . length > 0 ) {
Tabs _DiscardTabs (
Array . prototype . map . call ( document . querySelectorAll ( ".pin:not(.active_tab), #" + tt . active _group + " .selected:not(.active_tab)" ) , function ( s ) {
return parseInt ( s . id ) ;
} )
) ;
} else {
Tabs _DiscardTabs (
Array . prototype . map . call ( document . querySelectorAll ( ".pin:not(.active_tab), .tab:not(.active_tab)" ) , function ( s ) {
return parseInt ( s . id ) ;
} )
) ;
}
}
}
}
if ( s . id == "button_import_bak" ) { // IMPORT BACKUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let inputFile = File _ShowOpenFileDialog ( ".tt_session" ) ;
inputFile . onchange = function ( event ) {
Manager _ImportSession ( true , false , false ) ;
}
}
}
}
if ( s . id == "button_export_bak" ) { // EXPORT BACKUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let d = new Date ( ) ;
Manager _ExportSession ( ( d . toLocaleString ( ) . replace ( /\//g , "." ) . replace ( /:/g , "꞉ " ) ) , true , false , false ) ;
}
}
}
if ( s . id == "button_import_merge_bak" ) { // MERGE BACKUP
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
let inputFile = File _ShowOpenFileDialog ( ".tt_session" ) ;
inputFile . onchange = function ( event ) {
Manager _ImportSession ( false , false , true ) ;
// Manager_ImportMergeTabs();
}
}
}
}
if ( s . id == "button_filter_type" ) { // CHANGE FILTERING TYPE
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
if ( this . classList . contains ( "url" ) ) {
DOM _SetClasses ( this , [ "title" ] , [ "url" ] , [ ] ) ;
chrome . runtime . sendMessage ( { command : "set_search_filter" , search _filter : "title" , windowId : tt . CurrentWindowId } ) ;
} else {
DOM _SetClasses ( this , [ "url" ] , [ "title" ] , [ ] ) ;
chrome . runtime . sendMessage ( { command : "set_search_filter" , search _filter : "url" , windowId : tt . CurrentWindowId } ) ;
}
Tabs _FindTab ( document . getElementById ( "filter_box" ) . value ) ;
}
}
}
if ( s . id == "button_reboot" ) { // EMERGENCY RELOAD
s . onmousedown = function ( event ) {
if ( event . which == 1 ) {
chrome . runtime . sendMessage ( { command : "reload" } ) ;
chrome . runtime . sendMessage ( { command : "reload_sidebar" } ) ;
location . reload ( ) ;
}
}
}
if ( browserId != "F" ) {
if ( s . id == "button_bookmarks" ) { // BOOKMARKS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) chrome . tabs . create ( { url : "chrome://bookmarks/" } ) ;
}
}
if ( s . id == "button_downloads" ) { // DOWNLOADS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) chrome . tabs . create ( { url : "chrome://downloads/" } ) ;
}
}
if ( s . id == "button_history" ) { // HISTORY
s . onmousedown = function ( event ) {
if ( event . which == 1 ) chrome . tabs . create ( { url : "chrome://history/" } ) ;
}
}
if ( s . id == "button_extensions" ) { // EXTENSIONS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) chrome . tabs . create ( { url : "chrome://extensions" } ) ;
}
}
if ( s . id == "button_settings" ) { // SETTINGS
s . onmousedown = function ( event ) {
if ( event . which == 1 ) chrome . tabs . create ( { url : "chrome://settings/" } ) ;
}
}
if ( s . id == "button_load_bak1" || s . id == "button_load_bak2" || s . id == "button_load_bak3" ) { // LOAD BACKUPS
s . onmousedown = function ( event ) {
if ( event . which == 1 && this . classList . contains ( "disabled" ) == false ) {
let BakN = ( this . id ) . substr ( 15 ) ;
chrome . storage . local . get ( null , function ( storage ) {
if ( Object . keys ( storage [ "windows_BAK" + BakN ] ) . length > 0 ) chrome . storage . local . set ( { "windows" : storage [ "windows_BAK" + BakN ] } ) ;
if ( Object . keys ( storage [ "tabs_BAK" + BakN ] ) . length > 0 ) {
chrome . storage . local . set ( { "tabs" : storage [ "tabs_BAK" + BakN ] } ) ;
alert ( "Loaded backup" ) ;
}
chrome . runtime . sendMessage ( { command : "reload" } ) ;
chrome . runtime . sendMessage ( { command : "reload_sidebar" } ) ;
location . reload ( ) ;
} ) ;
}
}
}
}
}
}
}