diff options
| author | Shulhan <ms@kilabit.info> | 2021-07-25 05:14:06 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-07-26 02:06:40 +0700 |
| commit | 1a49542d36fcc715b3839facee0ccac9952d5ecd (patch) | |
| tree | 11b1b0d3ec1755774a46cd37698aa30a29c19b3c /vfs/example.html | |
| download | pakakeh.ts-1a49542d36fcc715b3839facee0ccac9952d5ecd.tar.xz | |
vfs: implement virtual file system explorer
The vfs.js implement the web user interface for virtual file system
explorer.
Diffstat (limited to 'vfs/example.html')
| -rw-r--r-- | vfs/example.html | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/vfs/example.html b/vfs/example.html new file mode 100644 index 0000000..0fb1f82 --- /dev/null +++ b/vfs/example.html @@ -0,0 +1,139 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>WUI - Virtual File System (vfs)</title> + </head> + <body onload="main()"> + <div id="vfs"></div> + + <script> + var exports = {} + </script> + <script src="vfs.js"></script> + <script> + let dummyfs = { + "/": { + name: "/", + path: "/", + is_dir: true, + childs: [ + { + name: "Dir 1", + path: "/Dir 1", + is_dir: true, + childs: [ + { + name: "File 1.1", + path: "/Dir 1/File 1.1", + }, + { + name: "File 1.2", + path: "/Dir 1/File 1.2", + }, + ], + }, + { + name: "Dir 2", + path: "/Dir 2", + is_dir: true, + childs: [ + { + name: "File 2.1", + path: "/Dir 2/File 2.1", + }, + { + name: "File 2.2", + path: "/Dir 2/File 2.2", + }, + ], + }, + ], + }, + "/Dir 1": { + name: "Dir 1", + path: "/Dir 1", + is_dir: true, + childs: [ + { + name: "File 1.1", + path: "/Dir 1/File 1.1", + }, + { + name: "File 1.2", + path: "/Dir 1/File 1.2", + }, + ], + }, + "/Dir 2": { + name: "Dir 2", + path: "/Dir 2", + is_dir: true, + childs: [ + { + name: "File 2.1", + path: "/Dir 2/File 2.1", + }, + { + name: "File 2.2", + path: "/Dir 2/File 2.2", + }, + ], + }, + } + + function main() { + let opts = { + id: "vfs", + is_editable: true, + ListNodes: doListNodes, + GetNode: doGetNode, + } + + let vfs = new Vfs(opts) + } + + function doListNodes() { + let res = { + code: 200, + data: dummyfs, + } + return res + } + + function doGetNode(path) { + let res = { + code: 200, + data: { + name: "", + path: path, + content: "", + }, + } + + switch (path) { + case "/Dir 1/File 1.1": + res.data.name = "File 1.1" + res.data.content = "This is the content of " + res.data.name + break + case "/Dir 1/File 1.2": + res.data.name = "File 1.2" + res.data.content = "This is the content of " + res.data.name + break + case "/Dir 2/File 2.1": + res.data.name = "File 2.1" + res.data.content = "This is the content of " + res.data.name + break + case "/Dir 2/File 2.2": + res.data.name = "File 2.1" + res.data.content = "This is the content of " + res.data.name + break + default: + res.code = 404 + res.message = "path not found" + } + return res + } + </script> + </body> +</html> |
