let util = {
context_menu(target,opt){
/*
opt = {"menu":[
{"name":string,
"callback": function}
, ...
],!"settings":{
x:int,
y:int,
height:int,
width:int
}}
! is optional
*/
(()=>{
target.oncontextmenu = ((ev)=>{
console.log(ev)
try{document.getElementById(target.id+"-menu").remove()}catch(e){}
let aa = ""
for(let op of opt.menu){
aa+=`
${op.name}
`
}
target.innerHTML += "
"+aa+"
"
for(let op of opt.menu){
document.getElementById(`${target.id}-menu-${opt.menu.indexOf(op)}`).onclick = (()=>{
op.callback()
})
}
return false
})
})()
},
scrollbar(uid,minor_uid,root,target){
(()=>{
//root is the base of the window, only used for measuring
//--
//target is where the scrollbar will be placed, this element should be
//larger than the root with scrollable overflow
let scrolling = false
console.log(uid,minor_uid)
//try{document.getElementById(uid + "-" + minor_uid + "-content-scrollbar").remove()}catch(e){console.log(e)}
if(undefined==procs[uid])
procs[uid] = {}
console.log("'" + uid + "-" + minor_uid + "-content-scrollbar'")
target.innerHTML += "
`,
{ width: 220, height: 110, resize: false,left:r_x,top:r_y }
);
for (let b of bu) {
document.getElementById(i + "-content-button-" + b).onclick = () => {
res(b);
};
}
});
return promise;
},
async fd(inp) {
let i = document.getElementsByClassName("window").length;
let promise = new Promise(async (res, rej) => {
if(undefined==procs[i])
procs[i] = {}
let sel = [];
let sel_t_n = 0
let sel_t = fs_types[sel_t_n]
l_b_width = 80
window_create(i, "fs", "",{scroll:false});
let ll = await new jssh(fs, "/", i, "null", "null", window_create);
async function load() {
let fil = []
let tfs = ll.set_wd(ll.clean_path(inp.path));
//console.log(sel_t)
let files = "";
files += "
"
//left bar
//console.log(inp.path)
let ppp = inp.path.split("/").filter(rem_emp)
function rec_bar_fun(cdir,target_full,target_ind,padding,patt){
let ret = ""
for(let f of cdir){
if(f.dir){
//console.log(f.name,target_full,target_ind)
let t_ret = ''
let ttu = false
if(f.name==target_full[target_ind]){
ttu = true
t_ret += rec_bar_fun(f.content,target_full,target_ind+1,padding+5,patt+"/"+f.name)
}
ret += "
"+(ttu?"v ":"> ")+f.name+"
" + t_ret
//console.log(false,f.name)
}
}
return ret
}
let bar_opt = "
v /
"
+ (rec_bar_fun(fs,ppp,0,5,''))
/*
for(let dd of ppp){
paa+=5
cur_pat.push(dd)
console.log(cur_pat,dd)
tt_ppp = "/" + cur_pat.join("/")
console.log(dd)
let ttwd = (ll.set_wd(tt_ppp))
for(let ff of ttwd){
if(ff.dir){
bar_opt+="