diff options
| author | Shulhan <ms@kilabit.info> | 2021-08-28 22:23:27 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-08-28 22:24:51 +0700 |
| commit | c246299101e47c28e064dbeacdbe718909bd7f17 (patch) | |
| tree | 71ba2799017c5172b4b917ed0b73d4bd17584f8a /vfs/example.html | |
| parent | 50c57f048eecab68570a0568f20922044935ecca (diff) | |
| download | pakakeh.ts-c246299101e47c28e064dbeacdbe718909bd7f17.tar.xz | |
all: use the WuiResponseInterface for non-void return type
This commit changes the WuiVfsOptions.istNodes and
WuiEditorOptions.OpenFile to WuiResponseInterface.
WuiResponseInterface define an interface that will be returned by function
or method with non-void type.
If the function/method success, the code should be set to 200 (equal to
HTTP OK), and the data will contains the expected data for that function.
If the function/method call failed, the code should be set to other value
beside 200 with a message describe why its failed.
Diffstat (limited to 'vfs/example.html')
| -rw-r--r-- | vfs/example.html | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/vfs/example.html b/vfs/example.html index 0fb1f82..3d8a772 100644 --- a/vfs/example.html +++ b/vfs/example.html @@ -9,6 +9,7 @@ <script> var exports = {} + var wui_vfs; </script> <script src="vfs.js"></script> <script> @@ -82,15 +83,19 @@ }, } - function main() { + async function main() { let opts = { id: "vfs", - is_editable: true, ListNodes: doListNodes, - GetNode: doGetNode, + OnClickNode: OnClickNode, } - let vfs = new Vfs(opts) + let res = await NewWuiVfs(opts) + if (res.code != 200) { + console.error(res) + return + } + wui_vfs = res.data } function doListNodes() { @@ -101,7 +106,11 @@ return res } - function doGetNode(path) { + function OnClickNode(path, is_dir) { + if (is_dir) { + return + } + let res = { code: 200, data: { @@ -132,7 +141,8 @@ res.code = 404 res.message = "path not found" } - return res + + console.log(res) } </script> </body> |
