This commit is contained in:
karol@jagiello.it 2018-12-19 18:48:52 +01:00
parent 56b3bafe64
commit 9db4d8c1cc
6 changed files with 54 additions and 37 deletions

View File

@ -16,9 +16,8 @@ function VivaldiStart() {
chrome.storage.local.get(null, function(storage) { chrome.storage.local.get(null, function(storage) {
// LOAD PREFERENCES // LOAD PREFERENCES
Preferences_GetCurrentPreferences(storage); Preferences_GetCurrentPreferences(storage);
// LEGACY START TO CONVERT DATA // LEGACY START TO CONVERT DATA
if ((storage.data_version == undefined && storage.tabs != undefined) || storage.data_version < 2) { if ((storage.data_version == undefined && storage.tabs != undefined && storage.tabs.length) || (storage.data_version != undefined && storage.data_version < 2)) {
b.safe_mode = true; b.safe_mode = true;
let refTabs = {}; let refTabs = {};
let refWins = {}; let refWins = {};
@ -241,7 +240,7 @@ async function VivaldiAutoSaveData(BAK, LoopTimer) {
} }
} }
} }
chrome.storage.local.set((BAK == 0 ? { windows: Windows, tabs: Tabs } : (BAK == 1 ? { windows_BAK1: Windows, tabs_BAK1: Tabs } : (BAK == 2 ? { windows_BAK2: Windows, tabs_BAK2: Tabs } : { windows_BAK3: Windows, tabs_BAK3: Tabs })))); chrome.storage.local.set((BAK == 0 ? { data_version: 2, windows: Windows, tabs: Tabs } : (BAK == 1 ? { windows_BAK1: Windows, tabs_BAK1: Tabs } : (BAK == 2 ? { windows_BAK2: Windows, tabs_BAK2: Tabs } : { windows_BAK3: Windows, tabs_BAK3: Tabs }))));
b.schedule_save--; b.schedule_save--;
}); });
} }

View File

@ -48,5 +48,5 @@
"page": "options/options.html", "page": "options/options.html",
"open_in_tab": true "open_in_tab": true
}, },
"version": "1.8.7" "version": "1.8.9"
} }

View File

@ -1078,11 +1078,12 @@ function RefreshFields() {
} else { } else {
document.getElementById("field_theme").style.height = ""; document.getElementById("field_theme").style.height = "";
} }
if (browserId == "F") { // if (browserId == "F") {
document.querySelectorAll("#scrollbar_size_indicator, #scrollbar_thumb, #scrollbar_thumb_hover, #scrollbar_track").forEach(function(s) { if (browserId != "F") {
s.style.display = "none"; // document.querySelectorAll("#scrollbar_size_indicator, #scrollbar_thumb, #scrollbar_thumb_hover, #scrollbar_track").forEach(function(s) {
}); // s.style.display = "none";
} else { // });
// } else {
document.querySelectorAll("#firefox_option_hide_other_groups_tabs_firefox").forEach(function(s) { document.querySelectorAll("#firefox_option_hide_other_groups_tabs_firefox").forEach(function(s) {
s.style.display = "none"; s.style.display = "none";
}); });

View File

@ -1,4 +1,4 @@
function Folders_AddNewFolder(p) { // folderId: string, ParentId: string, Name: string, Index: int, ExpandState: ("o","c"), AdditionalClass: string, SetEvents: bool function Folders_AddNewFolder(p) { // folderId: string, ParentId: string, InsertAfterId: tabId or folderId, Name: string, Index: int, ExpandState: ("o","c"), AdditionalClass: string, SkipSetEvents: bool
let newId = p.folderId ? p.folderId : Folders_GenerateNewFolderID(); let newId = p.folderId ? p.folderId : Folders_GenerateNewFolderID();
tt.folders[newId] = {id: newId, parent: (p.ParentId ? p.ParentId : ""), index: (p.Index ? p.Index : 0), name: (p.Name ? p.Name : labels.noname_group), expand: (p.ExpandState ? p.ExpandState : "")}; tt.folders[newId] = {id: newId, parent: (p.ParentId ? p.ParentId : ""), index: (p.Index ? p.Index : 0), name: (p.Name ? p.Name : labels.noname_group), expand: (p.ExpandState ? p.ExpandState : "")};
Folders_AppendFolder({folderId: newId, Name: tt.folders[newId].name, InsertAfterId: p.InsertAfterId, ParentId: p.ParentId, ExpandState: p.ExpandState, SkipSetEvents: p.SkipSetEvents, AdditionalClass: p.AdditionalClass}); Folders_AppendFolder({folderId: newId, Name: tt.folders[newId].name, InsertAfterId: p.InsertAfterId, ParentId: p.ParentId, ExpandState: p.ExpandState, SkipSetEvents: p.SkipSetEvents, AdditionalClass: p.AdditionalClass});

View File

@ -270,7 +270,7 @@ function Manager_ExportGroup(groupId, filename, save_to_manager) {
GroupToSave.favicons.push(favicon); GroupToSave.favicons.push(favicon);
favicon_index = GroupToSave.favicons.length; favicon_index = GroupToSave.favicons.length;
} }
(GroupToSave.tabs).push({id: tab.id,parent: s.parentNode.parentNode.id,index: Array.from(s.parentNode.children).indexOf(s), expand: (s.classList.contains("c") ? "c" : (s.classList.contains("o") ? "o" : "")), url: tab.url, title: tab.title, favicon: favicon_index}); (GroupToSave.tabs).push({id: tab.id, parent: s.parentNode.parentNode.id, index: Array.from(s.parentNode.children).indexOf(s), expand: (s.classList.contains("c") ? "c" : (s.classList.contains("o") ? "o" : "")), url: tab.url, title: tab.title, favicon: favicon_index});
} }
if (tab.id == lastId) { if (tab.id == lastId) {
if (filename) File_SaveFile(filename, "tt_group", GroupToSave); if (filename) File_SaveFile(filename, "tt_group", GroupToSave);
@ -308,45 +308,50 @@ function Manager_RecreateGroup(LoadedGroup) {
let RefTabs = {}; let RefTabs = {};
let NewTabs = []; let NewTabs = [];
let NewGroupId = Groups_AddNewGroup(LoadedGroup.group.name, LoadedGroup.group.font); let NewGroupId = Groups_AddNewGroup(LoadedGroup.group.name, LoadedGroup.group.font);
let FailedTabs = 0;
for (var folder in LoadedGroup.folders) { for (var folder in LoadedGroup.folders) {
let newId = Folders_AddNewFolder({parent: NewGroupId, name: LoadedGroup.folders[folder].name, expand: LoadedGroup.folders[folder].expand}); let newId = Folders_AddNewFolder({ParentId: NewGroupId, Name: LoadedGroup.folders[folder].name, ExpandState: LoadedGroup.folders[folder].expand});
RefFolders[folder] = newId; RefFolders[folder] = newId;
NewFolders[newId] = {id: newId, parent: (((LoadedGroup.folders[folder].parent).startsWith("g_") || (LoadedGroup.folders[folder].parent == "tab_list")) ? NewGroupId : LoadedGroup.folders[folder].parent), index: LoadedGroup.folders[folder].index, name: LoadedGroup.folders[folder].name, expand: LoadedGroup.folders[folder].expand}; NewFolders[newId] = {id: newId, parent: (((LoadedGroup.folders[folder].parent).startsWith("g_") || (LoadedGroup.folders[folder].parent == "tab_list")) ? NewGroupId : LoadedGroup.folders[folder].parent), index: LoadedGroup.folders[folder].index, name: LoadedGroup.folders[folder].name, expand: LoadedGroup.folders[folder].expand};
} }
for (var new_folder in NewFolders) { for (var new_folder in NewFolders) {
if ((NewFolders[new_folder].parent).startsWith("f_") && RefFolders[NewFolders[new_folder].parent]) NewFolders[new_folder].parent = RefFolders[NewFolders[new_folder].parent]; if ((NewFolders[new_folder].parent).startsWith("f_") && RefFolders[NewFolders[new_folder].parent]) NewFolders[new_folder].parent = RefFolders[NewFolders[new_folder].parent];
} }
(LoadedGroup.tabs).forEach(function(Tab) { for (let Tab of LoadedGroup.tabs) {
let params; let params;
if (browserId == "F") { if (browserId == "F") {
params = {active: false, windowId: tt.CurrentWindowId, url: Tab.url, discarded: true, title: Tab.title}; params = {active: false, windowId: tt.CurrentWindowId, url: Tab.url, discarded: ((Tab.url).startsWith("about") ? false : true), title: Tab.title};
} else { } else {
params = {active: false, windowId: tt.CurrentWindowId, url: Tab.url}; params = {active: false, windowId: tt.CurrentWindowId, url: Tab.url};
} }
chrome.tabs.create(params, function(new_tab) { chrome.tabs.create(params, function(new_tab) {
if (browserId == "F") browser.sessions.setTabValue(new_tab.id, "CachedFaviconUrl", Tab.favicon); if (new_tab) {
RefTabs[Tab.id] = new_tab.id; if (browserId == "F") browser.sessions.setTabValue(new_tab.id, "CachedFaviconUrl", LoadedGroup.favicons[Tab.favicon]);
Tab.id = new_tab.id; RefTabs[Tab.id] = new_tab.id;
if ((Tab.parent).startsWith("g_") || Tab.parent == "tab_list") Tab.parent = NewGroupId; Tab.id = new_tab.id;
if ((Tab.parent).startsWith("f_") && RefFolders[Tab.parent]) Tab.parent = RefFolders[Tab.parent]; if ((Tab.parent).startsWith("g_") || Tab.parent == "tab_list") Tab.parent = NewGroupId;
NewTabs.push(Tab); if ((Tab.parent).startsWith("f_") && RefFolders[Tab.parent]) Tab.parent = RefFolders[Tab.parent];
if (browserId != "O" && browserId != "F") chrome.runtime.sendMessage({command: "discard_tab", tabId: new_tab.id}); NewTabs.push(Tab);
if (NewTabs.length == LoadedGroup.tabs.length - 1) { if (browserId != "O" && browserId != "F") chrome.runtime.sendMessage({command: "discard_tab", tabId: new_tab.id});
NewTabs.forEach(function(LTab) { } else {
if (RefTabs[LTab.parent]) LTab.parent = RefTabs[LTab.parent]; FailedTabs++;
});
let GiveUp = 3000; // gives up after: 300*3000/1000/60 = 15 minutes
let RecreateTreeS = setInterval(function() {
GiveUp--;
let LastTab = document.getElementById(NewTabs[NewTabs.length - 1].id);
if (LastTab != null || GiveUp < 0) {
Manager_RecreateTreeStructure({}, NewFolders, NewTabs);
clearInterval(RecreateTreeS);
}
}, 300);
} }
}); });
}); }
let GiveUp = 3000; // gives up after: 300*3000/1000/60 = 15 minutes
let RecreateTreeS = setInterval(function() {
GiveUp--;
if (NewTabs.length == (LoadedGroup.tabs.length-FailedTabs) || GiveUp < 0) {
let LastTab = document.getElementById(NewTabs[NewTabs.length-1].id);
if (LastTab) {
Manager_RecreateTreeStructure({}, NewFolders, NewTabs);
clearInterval(RecreateTreeS);
setTimeout(function() {
DOM_RefreshGUI();
}, 1000);
}
}
}, 100);
} }
function Manager_AddGroupToStorage(group, add_to_manager) { function Manager_AddGroupToStorage(group, add_to_manager) {
@ -644,7 +649,9 @@ function Manager_ImportMergeTabs(LoadedWindows) {
} else { } else {
chrome.runtime.sendMessage({command: "remote_update", groups: w.groups, folders: w.folders, tabs: NewTabs, windowId: w.id}); chrome.runtime.sendMessage({command: "remote_update", groups: w.groups, folders: w.folders, tabs: NewTabs, windowId: w.id});
} }
Manager_ShowStatusBar({show: true, spinner: false, message: chrome.i18n.getMessage("status_bar_all_done"), hideTimeout: 2000}); setTimeout(function() {
Manager_ShowStatusBar({show: true, spinner: false, message: chrome.i18n.getMessage("status_bar_all_done"), hideTimeout: 2000});
}, 3000);
}, 6000); }, 6000);
}); });
}); });
@ -704,7 +711,7 @@ function Manager_RecreateTreeStructure(groups, folders, tabs) { // groups and fo
var SortAttempt = setInterval(function() { var SortAttempt = setInterval(function() {
SortAttemptNr--; SortAttemptNr--;
if (SortAttemptNr < 0 || Object.keys(ttTabs).length == tabs.length || tabs.length == 0) { if (SortAttemptNr < 0 || Object.keys(ttTabs).length == tabs.length || tabs.length == 0) {
Tabs_RearrangeTree(ttTabs, folders, false); Tabs_RearrangeTree(ttTabs, folders, true);
clearInterval(SortAttempt); clearInterval(SortAttempt);
Groups_UpdateBgGroupsOrder(); Groups_UpdateBgGroupsOrder();
setTimeout(function() { setTimeout(function() {

View File

@ -30,6 +30,16 @@
} }
.scroller {
width: var(--scrollbar_width);
height: var(--scrollbar_height);
scrollbar-color: var(--scrollbar_thumb) var(--scrollbar_track);
scrollbar-width: thin;
overflow-y: scroll;
}
div { div {
background-repeat: no-repeat; background-repeat: no-repeat;
-webkit-mask-repeat:no-repeat; -webkit-mask-repeat:no-repeat;