diff options
| author | Shulhan <ms@kilabit.info> | 2021-08-29 13:57:33 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-08-29 13:57:33 +0700 |
| commit | 1364ab29de697993bc34832cf77d4e99ee037223 (patch) | |
| tree | b8dcb3e89020c736d02a04277bad0a16933e5224 /vfs/example.html | |
| parent | 7940feda7d50c404fb245b645c8261d6cb4dd768 (diff) | |
| download | pakakeh.ts-1364ab29de697993bc34832cf77d4e99ee037223.tar.xz | |
vfs: simplify the handlers on WuiVfsOptions
Previously, the WuiVfsOptions contains two handlers: ListNodes to
retrieve list of files and OnClickNode for triggering changes when
user click a path or item in the list.
This changes simplify it into single handler: Open, which accept
path and boolean is_dir.
Diffstat (limited to 'vfs/example.html')
| -rw-r--r-- | vfs/example.html | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/vfs/example.html b/vfs/example.html index 3d8a772..1ebc1b4 100644 --- a/vfs/example.html +++ b/vfs/example.html @@ -9,7 +9,7 @@ <script> var exports = {} - var wui_vfs; + var wui_vfs </script> <script src="vfs.js"></script> <script> @@ -86,38 +86,28 @@ async function main() { let opts = { id: "vfs", - ListNodes: doListNodes, - OnClickNode: OnClickNode, + Open: Open, } - let res = await NewWuiVfs(opts) - if (res.code != 200) { - console.error(res) - return - } - wui_vfs = res.data + wui_vfs = new WuiVfs(opts) + wui_vfs.OpenDir("/") } - function doListNodes() { + function Open(path, is_dir) { + console.log("Open:", path, is_dir) let res = { code: 200, - data: dummyfs, } - return res - } - function OnClickNode(path, is_dir) { if (is_dir) { - return + res.data = dummyfs[path] + return res } - let res = { - code: 200, - data: { - name: "", - path: path, - content: "", - }, + res.data = { + name: "", + path: path, + content: "", } switch (path) { @@ -142,7 +132,7 @@ res.message = "path not found" } - console.log(res) + console.log("Open:", res) } </script> </body> |
