Skip to content

Commit ac99531

Browse files
replace more instances of Filer with tb.fs and move qwick to a stash on my pc
1 parent 87be114 commit ac99531

File tree

7 files changed

+28
-109
lines changed

7 files changed

+28
-109
lines changed

public/apps/browser.tapp/newtab.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<script src="/assets/libs/filer.min.js"></script>
1010
<script>
1111
const main = async () => {
12-
const favs = JSON.parse(await Filer.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/favorites.json`, "utf8"))
13-
const settings = await Filer.fs.promises.readFile(`/home/${await window.parent.tb.user.username()}/settings.json`, "XOR")
12+
const favs = JSON.parse(await window.parent.parent.tb.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/favorites.json`, "utf8"))
13+
const settings = await window.parent.parent.tb.fs.promises.readFile(`/home/${await window.parent.tb.user.username()}/settings.json`, "XOR")
1414
const favsDiv = document.getElementById("favs");
1515
for (const item of favs) {
1616
console.log(item);

public/apps/browser.tapp/userscripts.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
const getAll = async () => {
3939
const ujsDiv = document.getElementById("ujs");
40-
const userScripts = JSON.parse(await Filer.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, "utf8"))
40+
const userScripts = JSON.parse(await window.parent.parent.tb.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, "utf8"))
4141
if (userScripts.length === 0) {
4242
ujsDiv.innerHTML = "<span class='text-gray-500'>No UserScripts found</span>";
4343
} else {
@@ -64,14 +64,14 @@
6464
value: "f"
6565
}],
6666
onOk: async (val) => {
67-
const userScripts = JSON.parse(await Filer.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, "utf8"));
67+
const userScripts = JSON.parse(await window.parent.parent.tb.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, "utf8"));
6868
switch(val) {
6969
case 'f':
7070
window.parent.tb.dialog.FileBrowser({
7171
title: "Select a Userscript to load",
7272
defualtDir: "//",
7373
onOk: async (path) => {
74-
const fileData = await Filer.fs.promises.readFile(path, "utf8");
74+
const fileData = await window.parent.parent.tb.fs.promises.readFile(path, "utf8");
7575
const scrMeta = await getMeta(fileData);
7676
userScripts.push({
7777
name: scrMeta.name || "userscript",
@@ -82,7 +82,7 @@
8282
file: path,
8383
icon: scrMeta.icon || "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=",
8484
})
85-
await Filer.fs.promises.writeFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, JSON.stringify(userScripts, null, 2));
85+
await window.parent.parent.tb.fs.promises.writeFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, JSON.stringify(userScripts, null, 2));
8686
getAll();
8787
}
8888
});
@@ -92,10 +92,10 @@
9292
title: "Select a Userscript to load",
9393
defualtDir: "//",
9494
onOk: async (path) => {
95-
const dir = await Filer.fs.promises.readdir(path);
95+
const dir = await window.parent.parent.tb.fs.promises.readdir(path);
9696
for (const file of dir) {
9797
if (file.endsWith(".user.js")) {
98-
const fileData = await Filer.fs.promises.readFile(`${path}/${file}`, "utf8");
98+
const fileData = await window.parent.parent.tb.fs.promises.readFile(`${path}/${file}`, "utf8");
9999
const scrMeta = await getMeta(fileData);
100100
userScripts.push({
101101
name: scrMeta.name || "userscript",
@@ -108,7 +108,7 @@
108108
})
109109
};
110110
};
111-
await Filer.fs.promises.writeFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, JSON.stringify(userScripts, null, 2))
111+
await window.parent.parent.tb.fs.promises.writeFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, JSON.stringify(userScripts, null, 2))
112112
getAll()
113113
}
114114
});
@@ -121,7 +121,7 @@
121121
});
122122

123123
document.getElementById("ujs-rm").addEventListener("click", async () => {
124-
const userScripts = JSON.parse(await Filer.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, "utf8"))
124+
const userScripts = JSON.parse(await window.parent.parent.tb.fs.promises.readFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, "utf8"))
125125
let opts = []
126126
for (const sr of userScripts) {
127127
opts.push({
@@ -136,7 +136,7 @@
136136
const idx = userScripts.indexOf(val);
137137
if (idx !== -1) {
138138
userScripts.splice(idx, 1);
139-
await Filer.fs.promises.writeFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, JSON.stringify(userScripts, null, 2));
139+
await window.parent.parent.tb.fs.promises.writeFile(`/apps/user/${await window.parent.tb.user.username()}/browser/userscripts.json`, JSON.stringify(userScripts, null, 2));
140140
getAll();
141141
}
142142
}

public/apps/settings.tapp/accounts/index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const tb = parent.window.tb;
22
const currentAccountsEl = document.querySelector(".current-accounts");
33

44
const getAccounts = async () => {
5-
const entries = await Filer.fs.promises.readdir("/home/");
5+
const entries = await tb.fs.promises.readdir("/home/");
66
const accounts = await Promise.all(
77
entries.map(async entry => {
88
try {
9-
const account = JSON.parse(await Filer.fs.promises.readFile(`/home/${entry}/user.json`, "utf8"));
9+
const account = JSON.parse(await tb.fs.promises.readFile(`/home/${entry}/user.json`, "utf8"));
1010
return {
1111
name: entry,
1212
id: account["id"],
@@ -24,10 +24,10 @@ const getAccounts = async () => {
2424
};
2525

2626
const deleteAccount = async id => {
27-
const sudoUsers = JSON.parse(await Filer.fs.promises.readFile("/system/etc/terbium/sudousers.json", "utf8"));
27+
const sudoUsers = JSON.parse(await tb.fs.promises.readFile("/system/etc/terbium/sudousers.json", "utf8"));
2828
let sudoWithPassword = null;
2929
for (const sudoUser of sudoUsers) {
30-
const sudoUserData = JSON.parse(await Filer.fs.promises.readFile(`/home/${sudoUser}/user.json`, "utf8"));
30+
const sudoUserData = JSON.parse(await tb.fs.promises.readFile(`/home/${sudoUser}/user.json`, "utf8"));
3131
if (sudoUserData.password !== false) {
3232
sudoWithPassword = sudoUser;
3333
break;
@@ -48,7 +48,7 @@ const deleteAccount = async id => {
4848
defaultUsername: sudoUsers[0],
4949
onOk: async (username, password) => {
5050
const pass = await tb.crypto(password);
51-
if (pass === JSON.parse(await Filer.fs.promises.readFile(`/home/${sudoUsers[0]}/user.json`, "utf8")).password) {
51+
if (pass === JSON.parse(await tb.fs.promises.readFile(`/home/${sudoUsers[0]}/user.json`, "utf8")).password) {
5252
tb.system.users.remove(id);
5353
document.getElementById(id).remove();
5454
} else {
@@ -62,7 +62,7 @@ const deleteAccount = async id => {
6262
},
6363
});
6464
} else {
65-
const pw = JSON.parse(await Filer.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8")).password;
65+
const pw = JSON.parse(await tb.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8")).password;
6666
if (pw === false) {
6767
await tb.system.users.remove(id);
6868
document.getElementById(id).remove();
@@ -88,7 +88,7 @@ const deleteAccount = async id => {
8888
};
8989

9090
const changePerm = async () => {
91-
const data = JSON.parse(await Filer.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8"));
91+
const data = JSON.parse(await tb.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8"));
9292
if (data["password"] === false) {
9393
await tb.dialog.Select({
9494
title: "Enter the permission level you wish to set (Ex: Admin, User, Group, Public)",
@@ -114,7 +114,7 @@ const changePerm = async () => {
114114
if (perm === data["perm"]) return;
115115
data["perm"] = perm;
116116
permEl.innerHTML = perm.charAt(0).toUpperCase() + perm.slice(1);
117-
await Filer.fs.promises.writeFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, JSON.stringify(data));
117+
await tb.fs.promises.writeFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, JSON.stringify(data));
118118
},
119119
});
120120
} else {
@@ -149,7 +149,7 @@ const changePerm = async () => {
149149
if (perm === data["perm"]) return;
150150
data["perm"] = perm;
151151
permEl.innerHTML = perm.charAt(0).toUpperCase() + perm.slice(1);
152-
await Filer.fs.promises.writeFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, JSON.stringify(data));
152+
await tb.fs.promises.writeFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, JSON.stringify(data));
153153
},
154154
});
155155
} else {
@@ -161,7 +161,7 @@ const changePerm = async () => {
161161
};
162162

163163
const changePfp = async id => {
164-
const data = JSON.parse(await Filer.fs.promises.readFile(`/home/${id.id}/user.json`, "utf8"));
164+
const data = JSON.parse(await tb.fs.promises.readFile(`/home/${id.id}/user.json`, "utf8"));
165165
const pfpInp = document.createElement("input");
166166
pfpInp.type = "file";
167167
pfpInp.accept = "image/*";
@@ -176,7 +176,7 @@ const changePfp = async id => {
176176
img: e.target.result,
177177
onOk: async img => {
178178
data["pfp"] = img;
179-
await Filer.fs.promises.writeFile(`/home/${id.id}/user.json`, JSON.stringify(data));
179+
await tb.fs.promises.writeFile(`/home/${id.id}/user.json`, JSON.stringify(data));
180180
parent.window.dispatchEvent(new Event("accUpd"));
181181
renderAccounts();
182182
},
@@ -329,10 +329,10 @@ const createAccount = async () => {
329329
});
330330
};
331331

332-
const sudoUsers = JSON.parse(await Filer.fs.promises.readFile("/system/etc/terbium/sudousers.json", "utf8"));
332+
const sudoUsers = JSON.parse(await tb.fs.promises.readFile("/system/etc/terbium/sudousers.json", "utf8"));
333333
let sudoWithPassword = null;
334334
for (const sudoUser of sudoUsers) {
335-
const sudoUserData = JSON.parse(await Filer.fs.promises.readFile(`/home/${sudoUser}/user.json`, "utf8"));
335+
const sudoUserData = JSON.parse(await tb.fs.promises.readFile(`/home/${sudoUser}/user.json`, "utf8"));
336336
if (sudoUserData.password !== false) {
337337
sudoWithPassword = sudoUser;
338338
break;
@@ -352,7 +352,7 @@ const createAccount = async () => {
352352
defaultUsername: sudoWithPassword,
353353
onOk: async (username, password) => {
354354
const pass = await tb.crypto(password);
355-
if (pass === JSON.parse(await Filer.fs.promises.readFile(`/home/${sudoWithPassword}/user.json`, "utf8")).password) {
355+
if (pass === JSON.parse(await tb.fs.promises.readFile(`/home/${sudoWithPassword}/user.json`, "utf8")).password) {
356356
askNewAccountDetails();
357357
} else {
358358
tb.dialog.Alert({
@@ -365,7 +365,7 @@ const createAccount = async () => {
365365
},
366366
});
367367
} else {
368-
const user = JSON.parse(await Filer.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8"));
368+
const user = JSON.parse(await tb.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8"));
369369
if (user["password"] === false) {
370370
askNewAccountDetails();
371371
} else {
@@ -374,7 +374,7 @@ const createAccount = async () => {
374374
defaultUsername: sessionStorage.getItem("currAcc"),
375375
onOk: async (username, password) => {
376376
const pass = await tb.crypto(password);
377-
if (pass === JSON.parse(await Filer.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8")).password) {
377+
if (pass === JSON.parse(await tb.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8")).password) {
378378
askNewAccountDetails();
379379
} else {
380380
tb.dialog.Alert({

public/apps/settings.tapp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ <h2 class="text-2xl font-bold">Account</h2>
245245
<div class="settings-category absolute flex flex-col gap-3 overflow-y-auto overflow-x-hidden rounded-md size-full opacity-0 pointer-events-none scale-[1.01] duration-75 ease-in" category="other" data-visible="false">
246246
<h2 class="text-2xl font-bold">Import/Export Settings</h2>
247247
<div class="flex gap-1.5">
248-
<button class="w-max py-2 px-4 rounded-md font-semibold bg-[#ffffff10] shadow-[0px_0px_6px_0px_#00000052,_inset_0_0_0_0.5px_#ffffff38] hover:bg-[#ffffff20] duration-150" onmousedown="const input = document.createElement('input'); input.type = 'file'; input.accept = '.json'; input.onchange = async () => { let file = input.files[0]; let reader = new FileReader(); reader.onload = async () => { let settings = JSON.parse(reader.result); await Filer.fs.promises.writeFile(`/home/${await window.tb.user.username()}/settings.json`, JSON.stringify(settings), 'utf8'); parent.window.location.reload() }; reader.readAsText(file); }; input.click();">Import</button>
248+
<button class="w-max py-2 px-4 rounded-md font-semibold bg-[#ffffff10] shadow-[0px_0px_6px_0px_#00000052,_inset_0_0_0_0.5px_#ffffff38] hover:bg-[#ffffff20] duration-150" onmousedown="const input = document.createElement('input'); input.type = 'file'; input.accept = '.json'; input.onchange = async () => { let file = input.files[0]; let reader = new FileReader(); reader.onload = async () => { let settings = JSON.parse(reader.result); await window.parent.tb.fs.promises.writeFile(`/home/${await window.tb.user.username()}/settings.json`, JSON.stringify(settings), 'utf8'); parent.window.location.reload() }; reader.readAsText(file); }; input.click();">Import</button>
249249
<button class="w-max py-2 px-4 rounded-md font-semibold bg-[#ffffff10] shadow-[0px_0px_6px_0px_#00000052,_inset_0_0_0_0.5px_#ffffff38] hover:bg-[#ffffff20] duration-150" onmousedown="exportSettings()">Export</button>
250250
</div>
251251
<h2 class="text-2xl font-bold">Import TBS File</h2>

public/apps/terminal.tapp/scripts/info.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,5 @@
237237
"name": "exit",
238238
"description": "Exit the terminal",
239239
"usage": "exit"
240-
},
241-
{
242-
"name": "qwick_install",
243-
"description": "Installs qwick",
244-
"usage": "qwick_install"
245-
},
246-
{
247-
"name": "qwick",
248-
"description": "Qwick package manager",
249-
"usage": "qwick [subcmd] [subcmd] ... <input?> <args?>"
250240
}
251241
]

public/apps/terminal.tapp/scripts/qwick.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

public/apps/terminal.tapp/scripts/qwick_install.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)