diff options
| author | Shulhan <ms@kilabit.info> | 2021-09-05 21:46:40 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-09-05 21:46:40 +0700 |
| commit | 903561a9074da0632e1e001db3879cc45f974493 (patch) | |
| tree | ae0fa5cb0d44dbb086eb37a8d174ebb1cf3bc65a /vfs/example.html | |
| parent | caf0f69ed09d01ff6053cf095b720606077e442c (diff) | |
| download | pakakeh.ts-903561a9074da0632e1e001db3879cc45f974493.tar.xz | |
vfs: refactor example to use TypeScript loaded with type="module"
Diffstat (limited to 'vfs/example.html')
| -rw-r--r-- | vfs/example.html | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/vfs/example.html b/vfs/example.html deleted file mode 100644 index 4e28bf8..0000000 --- a/vfs/example.html +++ /dev/null @@ -1,144 +0,0 @@ -<!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 = {} - var wui_vfs - </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", - }, - ], - }, - } - - async function main() { - let opts = { - id: "vfs", - Open: Open, - OpenNode: OpenNode, - } - - wui_vfs = new WuiVfs(opts) - wui_vfs.OpenDir("/") - } - - function Open(path, is_dir) { - console.log("Open:", path, is_dir) - let res = { - code: 200, - } - - if (is_dir) { - res.data = dummyfs[path] - return res - } - - res.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" - } - - console.log("Open:", res) - } - - function OpenNode(node) { - Open(node.path, node.is_dir) - } - </script> - </body> -</html> |
