aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.js65
-rw-r--r--src/jssh.js16
-rw-r--r--src/window-utils.js28
3 files changed, 104 insertions, 5 deletions
diff --git a/src/common.js b/src/common.js
index f7d2cca..3c8fcb4 100644
--- a/src/common.js
+++ b/src/common.js
@@ -11,4 +11,67 @@ function appendHtml(el, str) {
}
-const rem_emp = function (e) {return e !== "";}; \ No newline at end of file
+const rem_emp = function (e) {return e !== "";};
+
+function indexs_of(inp,sel){
+ if(sel==''){
+ let fm = []
+ for(let n = 0; n<=inp.length;n++){
+ fm.push(n)
+ }
+ //console.log(fm)
+ return fm
+ }
+ let m = []
+ for(let i = inp.indexOf(sel);i>=0;i=inp.indexOf(sel,i+1)){
+ m.push(i)
+ }
+ return m
+}
+function hrx(inp,match){ //hgx for human (readable) regex, a more user friendly regex
+ //similar to the ones used in command lines
+ for(let x in match){
+ //console.log(match[x])
+ if(match[0]=='*'){
+ m = match.split("")
+ m.splice(0,1)
+ m = m.join("")
+ mm = m.split("*")[0]
+ //m = m.join("")
+
+ if(!inp.includes(mm))
+ return false
+
+ //let zz = inp.indexOf(m)
+ let ava = indexs_of(inp,mm)
+ //console.log(m)
+ for(let a of ava){
+ //console.log(a,m)
+ i = inp.split("")
+ i.splice(0,a)
+ i = i.join("")
+ let test = hrx(i,m)
+ if(test)
+ return true
+
+ }
+ return false
+ //match = m
+ //console.log(m,i)
+ } else {
+ //console.log(inp,match)
+ if(inp[0]==match[0]){
+ i = inp.split("")
+ ma = match.split("")
+ i.splice(0,1)
+ ma.splice(0,1)
+ inp=i.join("")
+ match=ma.join("")
+ } else {
+ return false
+ }
+ }
+ }
+ //console.log(inp,match)
+ return (inp==''&&''==match)
+} \ No newline at end of file
diff --git a/src/jssh.js b/src/jssh.js
index 22809e0..15b3100 100644
--- a/src/jssh.js
+++ b/src/jssh.js
@@ -7,6 +7,22 @@ class jssh {
this.uid = uid;
this.window_create = window_create;
}
+ search(fs,target,opt={},path='./'){
+ let match = []
+ for(let f of fs){
+ if(f.dir){
+ let tt = this.search(f.content,target,opt,path+f.name+"/")
+ if(tt!=undefined&&tt.length>0)
+ match.push(...tt)
+ }
+ if((!opt.exact&&hrx(f.name,"*"+target+"*")||(opt.exact&&hrx(f.name,target)))){
+ match.push(path+f.name)
+ }
+ }
+ //console.log(match.length)
+ //if(match.length!=0)
+ return match;
+ }
set_wd(dir) {
//let lwd = fs
let wd = fs;
diff --git a/src/window-utils.js b/src/window-utils.js
index 4744f77..89f56de 100644
--- a/src/window-utils.js
+++ b/src/window-utils.js
@@ -255,9 +255,15 @@ let util = {
}
}*/
//console.log(inp.path)
+
+ //top bar, wip maybe
+ //files+= "<div id='"+i+"-fs-top-bar' onscroll='return false;' style='display:inline-block;overflow:hidden;height:56px;width:100%;background-color:#b1b1b1'>"
+ //put buttons and stuff on top
+ //files+= "<u>S</u>earch: <form style='margin-left:22px;display:inline-block;width:40%'><input style='width:100%;display:inline-block;background:white'></input><input type='submit' style='display: none' /></form>"
+ //files+="</div>"
files+= "<div id='"+i+"-fs-left-bar' onscroll='return false;' style='overflow:hidden;height:100%;width:"+l_b_width+"'>"+bar_opt+"</div>"
files += "<div id='"+i+"-left-pane-resize-e' class='resize-e' style='position:relative;right:1;background-color:#aaaaaa;height:100%;'></div>"
- files += "<div id='"+i+"-fs-inner-cont' style='flex:1;align-content: flex-start;display:flex;flex-direction:row;flex-wrap:wrap'>"
+ files += "<div id='"+i+"-fs-inner-cont' style='flex:1;align-content: flex-start;display:flex;flex-direction:row;flex-wrap:wrap;'>"
for (let f of tfs) {
if (f.dir) {
files +=
@@ -297,7 +303,8 @@ let util = {
i +
"-fd-bottom' class='fd-bottom' ><div id='" +
i +
- "-fd-bar-top'><div style='width:70px;display:inline-block;'> File <u>n</u>ame: </div><div style='background-color:white;display:inline-block;width:40%' ><input style='display:inline-block;text-shadow:none;width:100%;' id='" +
+ "-fd-bottom-bar-top'><div style='width:70px;display:inline-block;'> File <u>n</u>ame: </div><div style='background-color:white;display:inline-block;width:40%' ><div style='background-color:red;position:absolute;margin-top:20px;width:100%'>uwu</br>nyadjkbkcbshvbhfbvjhdfvbdfbvjhdf</div>"
+ +"<input style='display:inline-block;text-shadow:none;width:100%;' id='" +
i +
"-fd-bottom-sel' value='" +
sel.join(",") +
@@ -307,7 +314,7 @@ let util = {
"-content-button-sub' style='width:70px;margin-left:22px;padding-left:15px;padding-right:15px;top:0;text-align: center;display:inline-block;'>save</button></div>" +
"<div id='" +
i +
- "-fd-bar-bottom'>" +
+ "-fd-bottom-bar-bottom'>" +
"<div style='width:70px;display:inline-block;'>File <u>t</u>ype: </div><div style='background-color:white;display:inline-block;width:40%' ><select style='display:inline-block;text-shadow:none;width:100%;' id='" +
i +
"-fd-bottom2-sel' >"+
@@ -316,7 +323,8 @@ let util = {
"<button id='" +
i +
"-content-button2-sub' style='width:70px;margin-left:22px;padding-left:15px;padding-right:15px;top:0;text-align: center;display:inline-block;'>cancel</button></div>" +
- "";
+ "</div></div>";
+
document.getElementById(i + "-content-content").innerHTML = files;
//console.log(tfs)
//util.scrollbar(document.getElementById(i+"-fs-inner-cont"))
@@ -325,6 +333,18 @@ let util = {
let ele = document.getElementById(i+"-fs-inner-cont")
let ele_root = document.getElementById(i+"-content-content")
+ //console.log(document.getElementById(i +"-fd-bottom-sel"))
+ document.getElementById(i +"-fd-bottom-sel").onfocus = ((ev)=>{
+ function zzz(ev){
+ let iuwu = document.getElementById(i +"-fd-bottom-sel").value
+ console.log(ll.search(tfs,iuwu))
+ //console.log()
+ }
+ document.body.addEventListener("input",zzz)
+ document.getElementById(i +"-fd-bottom-sel").onblur = ((ev)=>{
+ document.body.removeEventListener("input",zzz)
+ })
+ })
//console.log(inp.path.split("/").filter(rem_emp))
util.scrollbar(i,'root-bar',ele_root.parentElement,ele)
let contmenu = util.context_menu(ele,{menu:[