Skip to content

Commit

Permalink
File explorer done, handler system, textpad done
Browse files Browse the repository at this point in the history
  • Loading branch information
Electogenius committed Nov 28, 2021
1 parent 0a385c3 commit 02c7af3
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 18 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
._*
._*
.vscode
.DS_Store
10 changes: 6 additions & 4 deletions cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ open: opens an app`)
err(c, e) {
c.err(e.join(" "))
},
open(c, e) {
if (c) {

}
open(_, e) {
let fname=e.join` `,h=true
Object.keys(hmm.storage['.pr'].handlers).forEach(e=>{
if(fname.endsWith(e)){hmm.openApp(hmm.storage['.pr'].handlers[e],"$open "+fname);h=false}
})
if(h)hmm.openApp('textpad.hmm',"$open "+fname)
},
"#"() { },
}
Expand Down
Binary file modified cursors-move.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions fe.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@
path += e + '/'
loadpath()
}
}else{
el.onclick=(ev)=>{
hmm.$("open "+path+ev.target.innerText)
}
}
if (e.startsWith('.')) el.style.color = "#aaa"
el.innerText = e
document.getElementById('files').appendChild(el)
})
}
setTimeout(()=>{
if((window.arg||'').startsWith("$open ")){
path=window.arg.slice(6)
loadpath()
}
},100)
loadpath()
</script>
49 changes: 39 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ function e(query) {
}
window.hmm = {
testcommand: function () {
hmm.openApp("fe.hmm", "/.pr");
hmm.openApp("textpad.hmm", "$open /apps/textpad.hmm/code");
},
restart: function () {
window.location = window.location.href
},
opts: {
lang: "en"
},
safe: {},
hasPerms: (name, filename) => {
return eval("hmm.storage['.pr'].perms." + name).includes(filename + " ")
Expand All @@ -28,6 +25,9 @@ window.hmm = {
var cr = hmm.storage;
(p.match(/\/[^/]+/g) || []).forEach((e) => cr = cr[e.slice(1)])
return cr
},
pathToDot(p){
return "hmm.storage[atob('"+p.replace(/^\//,"").split('/').map(btoa).join("')][atob('")+"')]"
}
}
hmm.l.en = new Polyglot({
Expand Down Expand Up @@ -63,11 +63,17 @@ hmm.l.cd = new Polyglot({
}
})
hmm.storage = {
name:"HmmOS (tm)",
apps: {
"app.hmm": {
title: "testapp with a particularly long title",
type: "iframe",
code: `Lorem ipsum<button>dolor</button> sit amet<div class=bar>Test</div><hr>Some text <button class=clickme>BUTTON AAA
code: `
<script>
onload=()=>{
console.log(window.parent)
}
</script>
`
},
"cmd.hmm": {
Expand All @@ -84,13 +90,35 @@ hmm.storage = {
title: "Files",
type: "iframe",
code: `<script id=start>
onmessage=e=>window.arg=e.data
window.onmessage=e=>window.arg=e.data
fetch('./fe.html').then(e=>e.text()).then(e=>{
console.log(e)
document.body.innerHTML=e
document.querySelectorAll('script:not(#start)').forEach(e=>{eval(e.innerHTML)})
})
</script>`
},
"textpad.hmm":{
title:"TextPad",
type:"iframe",
code:`
<textarea id=t contenteditable=true style="
font-family:menlo,monospace;
border:1px solid #fff;
white-space:nowrap;
overflow:auto;
resize:none;
position:absolute;
top:0;left:0;
height:95%;
width:95%
"></textarea>
<script>setTimeout(()=>{if((window.arg||'').startsWith("$open ")){
t.value=window.parent.hmm.pathToJs(window.arg)
t.oninput=()=>{
eval("window.top."+window.parent.hmm.pathToDot(window.arg.slice(6))+"=t.value")
}
}},100)</script>
`
}
},
opts: {
Expand Down Expand Up @@ -223,18 +251,19 @@ hmm.App = class {
if (this.type == "iframe") {
var n = document.createElement("iframe")
if (!hmm.hasPerms("iframe.nosandbox", this.name)) n.sandbox = "allow-scripts allow-forms allow-presentation allow-modals allow-same-origin"
n.srcdoc = "<link rel=stylesheet href=style.css />" + this.code
n.srcdoc = "<link rel=stylesheet href=style.css /><style>body{overflow:auto}</style>" + this.code
n.classList.add("win")
content.style.overflow = "hidden"
content.appendChild(n)
postMessage(arg, n.contentWindow)
setTimeout(()=>{n.contentWindow.arg=arg},100)
}

node.appendChild(content)
var position = { x: 0, y: 0 }
interact(node).draggable({
allowFrom: "taskbar",
modifiers: [],
inertia:true,
listeners: {
start(event) {
if (Math.abs(position.y - window.innerHeight) < 30) {
Expand Down Expand Up @@ -295,7 +324,7 @@ hmm.setMenu = () => {
document.getElementById("apps").appendChild(el)
})
}
hmm.console = (e, run) => {
hmm.console = (e, run) => {//TODO: fix this mess
e.ln = 0
let p = 1,
torun = ""
Expand Down
13 changes: 10 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
}

::-webkit-scrollbar {
width: 5px;
width: 10px;
height:10px
}

::-webkit-scrollbar-track {
Expand Down Expand Up @@ -139,7 +140,7 @@ window {
taskbar {
display: block;
background-color: #05d;
cursor: var('--move');
cursor: var(--cursor);
touch-action: none;
border-radius: 3px;
padding-left: 10px;
Expand All @@ -157,7 +158,7 @@ div.bar {
padding: 2px;
box-shadow: 1px 2px 5px black;
overflow-y: auto;
max-height: 95vh
max-height: 95vh;
}

baritem {
Expand Down Expand Up @@ -325,4 +326,10 @@ canvas.win {

hr {
border: 1px solid #05d;
}

textarea{
background-color: #222;
box-shadow: inset 2px 2px 2px #fff;
color:#fff;
}

0 comments on commit 02c7af3

Please sign in to comment.