瀏覽代碼

added more onm dev-en-HK 5.md

tobychui 5 年之前
父節點
當前提交
7ab472ee1b
共有 1 個文件被更改,包括 94 次插入0 次删除
  1. 94 0
      docs/lang/dev-en-HK/5.md

+ 94 - 0
docs/lang/dev-en-HK/5.md

@@ -200,3 +200,97 @@ move.php?from={source_path}&to={target_path}
 ```
 
 ## File Selector
+ArOZ Online File System provide a simple way to access the file list and allow users to select files within the file system of your host device - The File Selector. 
+
+The file selector API can be called via the following two commands
+
+```
+//Under VDI Mode, popup as a new floatWindow
+ao_module_openFileSelector(uid,callBackFunctionName, windowWidth = 1080, windowHeight = 645, allowMultiple = false, selectMode = "file")
+
+//Under Normal Mode, popup as a new tab window (Require localStorage)
+ao_module_openFileSelectorTab(uid, aor,allowMultiple = false, selectMode = "file",callBack=console.log
+```
+
+Here is a table showing the different meaning of each parameters.
+
+<table>
+  <tr>
+    <th>Variable</th>
+    <th>Meanings</th>
+  </tr>
+  <tr>
+    <td>uid</td>
+    <td>Unique ID for this floatWindow</td>
+  </tr>
+  <tr>
+    <td>aor</td>
+    <td>ArOZ Online Root, usually ../ for WebApp moduiles</td>
+  </tr>
+  <tr>
+    <td>windowWidth</td>
+    <td>The width of the file selector window. Default 1080px</td>
+  </tr>
+  <tr>
+    <td>windowHeight</td>
+    <td>The height of the file selector window. Default 645px</td>
+  </tr>
+  <tr>
+    <td>alowMultiple</td>
+    <td>Allow selecting multiple items in the selector.</td>
+  </tr>
+  <tr>
+    <td>selectMode</td>
+    <td>Select file / folder / all. Default "file", accept {file / folder/ mix}<br></td>
+  </tr>
+  <tr>
+    <td>callBackFunctionName (floatWindow Mode Only)</td>
+    <td>Function name that expect the selector to return the result to. THIS FUNCTION NAME IS IN STRING FORMAT</td>
+  </tr>
+  <tr>
+    <td>callBack (Non floatWindow Mode Only)</td>
+    <td>Function that expect the selector to return the result to. THIS IS THE POINTER OF THE FUNCTION.</td>
+  </tr>
+</table>
+
+### Example Codes
+To start the file selector, you need to first include the ao_module into your WebApp module with the following code in the head section of your HTML / PHP file.
+
+```
+<script src="../script/ao_module.js"></script>
+```
+
+Now, assume you want the file explorer to pop up while the user press a button. Here is an example for the process.
+
+```
+<button onClick="openFileSelector();">Select File</button>
+```
+
+As you need to use different file selector mode in or out of VDI mode, here is an example script to open file selector in different mode with VDI checking.
+
+```
+if (ao_module_virtualDesktop){
+	var uid = ao_module_utils.getRandomUID();
+	ao_module_openFileSelector(uid,"addFileFromSelector",undefined,undefined,true);
+}else{
+	var uid = ao_module_utils.getRandomUID();
+	ao_module_openFileSelectorTab(uid,"../",true,"file",addFileFromSelector);
+}
+```
+
+The returned file selector results will be an array in JSON format. Here is an example of the code which can catch the returned results.
+
+```
+function addFileFromSelector(fileData){
+	result = JSON.parse(fileData);
+		for (var i=0; i < result.length; i++){
+		var filename = result[i].filename;
+		var filepath = result[i].filepath;
+		//DO SOMETHING HERE
+   }
+}
+```
+
+## File Explorer Shortcuts
+
+## File Extension Default Opener