cyp/app/js/elements/path.js

31 lines
584 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();
2020-03-13 23:52:24 +08:00
this._data = data;
if ("directory" in this._data) {
this.file = data["directory"];
} else {
this.file = data["file"];
}
2020-03-13 06:03:26 +08:00
}
connectedCallback() {
2020-03-13 23:52:24 +08:00
if ("directory" in this._data) {
2020-03-13 06:03:26 +08:00
this.appendChild(html.icon("folder"));
} else {
this.appendChild(html.icon("music"));
}
2020-03-13 23:52:24 +08:00
this._buildTitle(baseName(this.file));
2020-03-13 06:03:26 +08:00
}
}
customElements.define("cyp-path", Path);