Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/file_shell/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/junkfix/file-shell/issues",
"requirements": [],
"version": "1.0.2"
"version": "1.0.3"
}
17 changes: 0 additions & 17 deletions custom_components/file_shell/www/file_shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,6 @@ body {
overflow: hidden;
}

nav {
display: flex;
align-items: center;
gap: 12px;
padding: 0 8px;
background: var(--panel);
}

nav button,
#files button{
background-color: var(--panel2);
color: var(--text);
border: 1px solid var(--border);
border-radius: 6px;
padding: 2px 8px;
cursor: pointer;
}

button:hover{
border-color: var(--accent);
Expand Down
17 changes: 9 additions & 8 deletions custom_components/file_shell/www/file_shell.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
"use strict";

console.log("File Shell 1.0");
console.log("File Shell 1.0.3");
const _id = (id) => document.getElementById(id);
const _qsa = (q, el) => Array.from((el || document).querySelectorAll(q));
const _qs = (q, el) => (el || document).querySelector(q);
Expand Down Expand Up @@ -54,7 +54,6 @@ const localTag = 'file_shell';
const localGet = (e) => localStorage.getItem(localTag+e);
const localSet = (k, v) => v == null ? localStorage.removeItem(localTag + k) : localStorage.setItem(localTag + k, v);

const getExt = (t)=>{const o=t.split("/").pop().split(".");return o.length>1?o.pop().toLowerCase():"";};

const opt = {
multi: 0,
Expand Down Expand Up @@ -302,11 +301,13 @@ function popup(html='', head='Message', options={}){

}

const isText = (e) => e.type !== "dir" && "txt.md.yaml.yml.jinja.json.xml.csv.log.ini.conf.cfg.py.js.ts.php.htm.html.css.sh".split('.').some(ext => getExt(e.name).endsWith('.' + ext));
const getExt = (t)=>{const o=t.split("/").pop().split(".");return o.length>1?o.pop().toLowerCase():"";};
const ext_zip = new Set(["zip", "tar", "gz", "tgz"]);
const ext_text = new Set(["txt", "md", "yaml", "yml", "jinja", "json", "xml", "csv", "log", "ini", "conf", "cfg", "py", "js", "ts", "php", "htm", "html", "css", "sh"]);
const isText = (e) => e.type !== "dir" && ext_text.has(getExt(e.name));
const isZipFile = (e) => e.type !== "dir" && ext_zip.has(getExt(e.name));
const iconFor = (e) => e.type === "dir" ? "folder" : isZipFile(e) ? "zip" : isText(e) ? "doc" : "file";

const isZipFile = (e) => e?.type === "file" && [".zip", ".tar", ".gz", ".tgz"].some(ext => getExt(e.name).endsWith(ext));

const escapeHtml = (s) => String(s).replace(/[&<>]/g, (c) => ({ '&':'&amp;', '<':'&lt;', '>':'&gt;' })[c]);

const filesize = (s,t='file') => {
Expand Down Expand Up @@ -456,13 +457,13 @@ async function validate(){
}else if(['yaml','yml','py'].includes(ext)){
r = await apiPost("valid", { ext, content: c});
if (r.valid) { r = ''; }else{
r = `${r.error}, line ${r.line}, column ${r.column}`;
r = escapeHtml(r.error)+'<p>line '+ r.line+', column '+r.column+'</p>';
}
}else{
r = 'Unsupported file: '+ext;
}
if (r) {
toast('Error: '+r, { theme: 'red', timeout: 15 });
toast('Error: '+r, { theme: 'red', timeout: 0, close: 1 });
}else{
toast("No Errors");
}
Expand Down Expand Up @@ -2119,4 +2120,4 @@ async function init() {
init();


})();
})();