* * @param {Array >} [extra] * @param {"file"|"dir"|"all"} [type] * @param {string} [title] * @returns {Promise }
(extra, type = "all", title = strings["open recent"])
| 77 | * @returns {Promise<RecentPathData>} |
| 78 | */ |
| 79 | select(extra, type = "all", title = strings["open recent"]) { |
| 80 | const all = []; |
| 81 | const MAX = 20; |
| 82 | const shortName = (name) => { |
| 83 | name = helpers.getVirtualPath(name); |
| 84 | |
| 85 | if (name.length > MAX) { |
| 86 | return "..." + name.substr(-MAX - 3); |
| 87 | } |
| 88 | return name; |
| 89 | }; |
| 90 | |
| 91 | if (type === "dir" || type === "all") { |
| 92 | let dirs = this.folders; |
| 93 | for (let dir of dirs) { |
| 94 | const { url } = dir; |
| 95 | |
| 96 | const dirValue = { |
| 97 | type: "dir", |
| 98 | val: dir, |
| 99 | }; |
| 100 | |
| 101 | const tailElement = tag("span", { |
| 102 | className: "icon clearclose", |
| 103 | dataset: { |
| 104 | action: "clear", |
| 105 | }, |
| 106 | }); |
| 107 | |
| 108 | all.push({ |
| 109 | value: dirValue, |
| 110 | text: shortName(url), |
| 111 | icon: "folder", |
| 112 | tailElement: tailElement, |
| 113 | ontailclick: (e) => { |
| 114 | const $item = e.currentTarget.closest(".tile"); |
| 115 | if ($item) $item.remove(); |
| 116 | this.removeFolder(dir.url); |
| 117 | }, |
| 118 | }); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | if (type === "file" || type === "all") { |
| 123 | let files = this.files; |
| 124 | for (let file of files) { |
| 125 | if (!file) continue; |
| 126 | const name = shortName(Url.parse(file).url); |
| 127 | |
| 128 | const fileValue = { |
| 129 | type: "file", |
| 130 | val: file, |
| 131 | }; |
| 132 | const tailElement = tag("span", { |
| 133 | className: "icon clearclose", |
| 134 | dataset: { |
| 135 | action: "clear", |
| 136 | }, |