cyp/app/js/elements/path.js

29 lines
568 B
JavaScript
Raw Normal View History

2020-03-13 06:03:26 +08:00
import Item from "../item.js";
import * as html from "../html.js";
function baseName(path) {
return path.split("/").pop();
}
export default class Path extends Item {
constructor(data) {
super();
this.data = data;
// FIXME spis ._data a .url
}
connectedCallback() {
let path;
if ("directory" in this.data) {
this.appendChild(html.icon("folder"));
path = this.data["directory"];
} else {
this.appendChild(html.icon("music"));
path = this.data["file"];
}
2020-03-13 17:10:32 +08:00
this._buildTitle(baseName(path));
2020-03-13 06:03:26 +08:00
}
}
customElements.define("cyp-path", Path);