Skip to content

Commit 41cc81f

Browse files
committed
add promise helper function
1 parent a2c390b commit 41cc81f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

public/js/filemanager.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Open file manager and return selected files.
3+
* Promise is never resolved if window is closed.
4+
*
5+
* @returns Promise<array> Array of selected files with properties:
6+
* icon string
7+
* is_file bool
8+
* is_image bool
9+
* name string
10+
* thumb_url string|null
11+
* time int
12+
* url string
13+
*/
14+
window.filemanager = function filemanager() {
15+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/filemanager';
16+
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'FileManager';
17+
var features = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'width=900,height=600';
18+
return new Promise(function (resolve) {
19+
window.open(url, target, features);
20+
window.SetUrl = resolve;
21+
});
22+
};

0 commit comments

Comments
 (0)