let util = {
async alert(inp) {
let promise = new Promise(async (res, rej) => {
bu = [];
if (inp.buttons == undefined) {
bu = ["ok", "no"];
} else {
bu = inp.buttons;
}
let buttons = "";
let i = document.getElementsByClassName("window").length;
for (let b of bu) {
buttons +=
"";
}
await window_create(
i,
inp.title == undefined ? "Alert" : inp.title,
`
`,
{ width: 220, height: 110, resize: false }
);
for (let b of bu) {
document.getElementById(i + "-content-button-" + b).onclick = () => {
res(b);
};
}
});
return promise;
},
async fd(inp) {
let promise = new Promise(async (res, rej) => {
let i = document.getElementsByClassName("window").length;
let sel = [];
await window_create(i, "fs", "");
function load() {
let ll = new jssh(fs, "/", i, "null", "null", window_create);
let tfs = ll.set_wd(ll.clean_path(inp.path));
let files = "";
for (let f of tfs) {
if (f.dir) {
files +=
"
" +
f.name +
"
";
} else {
files +=
"
" +
f.name +
"
";
}
}
let opts = "";
for (let uwu of fs_types) {
opts +=
"";
}
files +=
"
File name:
" +
"
" +
"
File type:
" +
"
" +
"
";
document.getElementById(i + "-content-content").innerHTML = files;
for (let f of tfs) {
let tt = document.getElementById(i + "-id-name-" + f.name);
let dou = false;
tt.onclick = (ev) => {
if (dou) {
console.log(f, inp);
if (f.dir) {
inp.path += f.name;
} else {
if (f.name.includes(".exe"))
ll.ex_file(inp.path + "/" + f.name);
else {
if (inp.open_file == true || inp.open_file == undefined) {
let iii = ll.ex_file("/apps/notepad.exe");
document.getElementById(
iii + "-content-content"
).firstChild.value = ll.get_file(
inp.path + "/" + f.name
).content;
} else {
return inp.path + "/" + f.name;
}
//console.log();
}
}
load();
dou = false;
} else {
dou = true;
tt.style.backgroundColor = "blue";
setTimeout(() => {
if (dou) {
if (ev.ctrlKey) {
if (sel.includes(f.name)) {
sel.splice(sel.indexOf(f.name), 1);
} else sel.push(f.name);
} else sel = [f.name];
//sel = [f.name];
document.getElementById(i + "-fd-bottom-sel").value =
sel.join(",") + (sel.length == 0 ? "Untitled" : "");
for (let aa of tfs) {
let ttt = document.getElementById(
i + "-id-name-" + aa.name
);
if (sel.includes(aa.name)) {
ttt.style.backgroundColor = "blue";
} else {
ttt.style.backgroundColor = "";
}
}
//load();
dou = false;
}
}, 200);
}
};
}
}
load();
});
return promise;
},
};