Skip to content

Commit

Permalink
made compatible with iPad after much suffering
Browse files Browse the repository at this point in the history
  • Loading branch information
Electogenius committed Nov 28, 2021
1 parent 989f28a commit a83a944
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
6 changes: 4 additions & 2 deletions cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ hmm.$ = (cm, c) => {
let l = hmm.$.token(cm)
if (l[0] == "") return;
if (l[0] in hmm.storage.cmd) {
return new Function("return {" + hmm.storage.cmd[l[0]] + "}")()[l[0]](c, l.slice(1))
let fn=hmm.storage.cmd[l[0]]
,e=l.slice(1)
return eval(fn.slice(fn.indexOf("{")+1,-1))
} else {
c.err("Command not found")
}
Expand Down Expand Up @@ -39,7 +41,7 @@ open: opens an app`)
err(c, e) {
c.err(e.join(" "))
},
open(_, e) {
open(c, 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}
Expand Down
5 changes: 3 additions & 2 deletions fe.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
window._AppName = "fe"
back=window.parent.hmm.t("apps.fe.goback")
</script>
<link rel="stylesheet" href="style.css">
<style>
Expand Down Expand Up @@ -28,12 +29,12 @@
<span id="pathlabel"></span>
<div id="files"></div>
<script>
hmm = window.top.hmm;
hmm = window.parent.hmm;
path = "/"
loadpath=()=>{
document.getElementById('pathlabel').innerText = path
document.getElementById('files').innerHTML = (path != "/") ? `
<div class="file" style="color:#05d" onclick="path=path.slice(0,path.slice(0,-1).lastIndexOf('/')+1);loadpath()">&larr; back</div>
<div class="file" style="color:#05d" onclick="path=path.slice(0,path.slice(0,-1).lastIndexOf('/')+1);loadpath()">&larr; ${back}</div>
`: ''
Object.keys(hmm.pathToJs(path)).sort().forEach(e => {
var el = document.createElement('div')
Expand Down
6 changes: 6 additions & 0 deletions langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ hmm.storage.i18n.en = {
"settings": {
"lang": "System language",
"name": "Settings"
},
"fe":{
goback:"back"
}
}
}
Expand All @@ -20,6 +23,9 @@ hmm.storage.i18n.cd = {
settings: {
lang: "kãiod moi",
name: "māthrdhng"
},
fe:{
goback:"pnād"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function e(query) {
}
window.hmm = {
testcommand: function () {
hmm.openApp("textpad.hmm", "$open /apps/textpad.hmm/code");
hmm.openApp("fe.hmm");
},
restart: function () {
window.location = window.location.href
Expand Down Expand Up @@ -58,13 +58,14 @@ hmm.storage = {
"fe.hmm": {
title: { en: "Files", cd:"kōpnge" },
type: "iframe",
code: `<script id=start>
code: `<script class=ev>
window.onmessage=e=>window.arg=e.data
fetch('./fe.html').then(e=>e.text()).then(e=>{
window.onload=()=>{fetch('./fe.html').then(e=>e.text()).then(e=>{
document.body.innerHTML=e
document.querySelectorAll('script:not(#start)').forEach(e=>{eval(e.innerHTML)})
document.querySelectorAll('script:not(.ev)').forEach(e=>{eval(e.innerHTML)})
})
</script>`
}
</script><body></body>`
},
"textpad.hmm": {
title: { en: "TextPad" },
Expand All @@ -84,7 +85,7 @@ hmm.storage = {
<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")
eval("window.parent."+window.parent.hmm.pathToDot(window.arg.slice(6))+"=t.value")
}
}},100)</script>
`
Expand All @@ -104,7 +105,6 @@ hmm.storage = {
}
}
}

window.onload = () => {
localforage.getItem("hmm-fs").then((val) => {
if (null !== val) {
Expand Down
4 changes: 2 additions & 2 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ <h1 data-t="name"></h1>
</div>
<script>
let e=q=>document.getElementById(q)
if(window.top!==window.self){
if(true){
let hmm = {}
hmm=window.top.hmm
hmm=window.parent.hmm
e("lang").value = hmm.storage.opts.lang
e("lang").onchange =()=>{
hmm.storage.opts.lang = e("lang").value
Expand Down

0 comments on commit a83a944

Please sign in to comment.