mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
Major 3.0 (#118)
Co-authored-by: Maison da Silva <maisonmdsgreen@hotmail.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { CollectionItem, GroupItem, TabItem } from "@/models/CollectionModels";
|
||||
|
||||
export default function serializeCollections(collections: CollectionItem[]): string
|
||||
{
|
||||
let data: string = "";
|
||||
|
||||
for (const collection of collections)
|
||||
{
|
||||
data += getCollectionString(collection);
|
||||
|
||||
for (const item of collection.items)
|
||||
{
|
||||
if (item.type === "group")
|
||||
{
|
||||
data += getGroupString(item);
|
||||
|
||||
for (const tab of item.items)
|
||||
data += `\t${getTabString(tab)}`;
|
||||
}
|
||||
else if (item.type === "tab")
|
||||
data += getTabString(item);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function getCollectionString(collection: CollectionItem): string
|
||||
{
|
||||
let data: string = `c${collection.timestamp}`;
|
||||
|
||||
if (collection.color)
|
||||
data += `/${collection.color}`;
|
||||
|
||||
if (collection.title)
|
||||
data += `|${collection.title}`;
|
||||
|
||||
data += "\n";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function getGroupString(group: GroupItem): string
|
||||
{
|
||||
let data: string = "\tg";
|
||||
|
||||
if (group.pinned === true)
|
||||
data += "/p";
|
||||
else
|
||||
{
|
||||
data += `/${group.color}`;
|
||||
|
||||
if (group.title)
|
||||
data += `|${group.title}`;
|
||||
}
|
||||
|
||||
data += "\n";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function getTabString(tab: TabItem): string
|
||||
{
|
||||
let data: string = "\tt";
|
||||
|
||||
data += `|${tab.url}|`;
|
||||
|
||||
if (tab.title)
|
||||
data += tab.title;
|
||||
|
||||
data += "\n";
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user