-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdialogTest.html
105 lines (96 loc) · 4.15 KB
/
dialogTest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!doctype html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script> // this script for module loading
window.globals = { }; // for interscope comms
// must be defined before any modules that use it
function moduleCmd(mod,cmd,arg0,arg1,arg2,arg3,arg4) {
// assumes that window.global[mod][cmd] exists
console.log(mod,cmd,arg0,arg1,arg2);
if(mod === "" && cmd === 'listDir') // only used for test pages
listDir(arg0,arg1,arg2,arg3,arg4);
else
window.globals[mod][cmd](arg0,arg1,arg2,arg3,arg4);
}
</script>
<script type="text/javascript" src="js/dialog.js"></script>
<script>
var dialog = window.globals.dialog;
var simpleProp = 20.0;
var undefProp;
var simpleString = "hello";
function simpleDialog() {
var fs = dialog.openCommon(simpleDialogReturn, ['Okay', 'Cancel']);
var p = '<div id="imgLoadOptionsTitle">Default Image Load Options</div>';
p += '<table>';
p += dialog.propertyRow(simpleProp, 10.0, 'number', 'simple_prop');
p += dialog.propertyRow(undefProp,
{defaultValue:10.0, max:30, min:5, step:5}, 'number', 'undef_prop');
p += dialog.propertyRow(simpleString, 10.0, 'string', 'simple_string');
p += '</table>';
dialog.setContent(p);
dialog.setMove("imgLoadOptionsTitle");
return false;
}
function simpleDialogReturn(reply,prop_values) {
console.log(reply);
if(reply != 'cancel') {
console.log("number = " + prop_values.simple_prop);
console.log("undef number = " + prop_values.undef_prop);
console.log("string = " + prop_values.simple_string);
}
}
function colorDialog() {
dialog.colorSelector(setColor);
}
function setColor(c) {
console.log("Color selected = "+c);
}
// dummy directories for test
var dummy_dir1_list = [{name:"dummy_dir2",type:"dir"},{name:"dummy_file.xxx",type:"file"}];
var dummy_dir1_obj = {type:"dir",path:"",dir:dummy_dir1_list};
var dummy_dir2_list = [{name:"dummy_file2.xxx",type:"file"},{name:"dummy_file3.xxx",type:"file"},{name:"dummy_file4.xxd",type:"file"}]
var dummy_dir2_obj = {type:"dir",path:"dummy_dir2",dir:dummy_dir2_list};
// the dirCommands tells the dialog what to do for directories
// module would normally be either nodeComms or, for loadImage it would be pgdialogs
var dirCommands = { module: "",funct:"listDir"};
var objective, xtns;
function fileSelectDialog() {
objective = "open";
xtns = "xxx,abc";
// the long way to call the dialog file selector is: //dialog.fileSelector(objective,xtns,dummy_dir1_obj,dirCommands,fileSelected);
// but the same can be achieved by
listDir(objective,xtns,"");
}
// dummy directory listing function - recursive for directory entries
function listDir(objective,xtns,path,subpath) {
console.log("listDir("+objective+','+xtns+','+path+")");
var dir_obj; // since we are not looking at real directories
if(typeof subpath !== undefined && subpath == 'parent_directory')
dir_obj = dummy_dir1_obj; // the dummy root directory
else // only other options is the one dummy directory
dir_obj = dummy_dir2_obj; // the dummy sub directory
dialog.fileSelector(objective,xtns,dir_obj,dirCommands,fileSelected);
}
function fileSelected(objective,path,subpath) {
console.log(objective + " from:"+path+" file:"+subpath);
}
function fileSaveDialog() {
objective = "save";
xtns = "xxd";
listDir(objective,xtns,"");
}
</script>
</head>
<body>
<button type="button" onclick="simpleDialog();" class="button" width="300">Simple Dialog</button>
<button type="button" onclick="colorDialog();" class="button" width="300">Color Select Dialog</button>
<button type="button" onclick="fileSelectDialog();" class="button" width="300">File Select Dialog</button>
<button type="button" onclick="fileSaveDialog();" class="button" width="300">File Save Dialog</button>
<div id="clientArea">
</div>
<div id="Dialog"><div id="DlgContent"></div><div id="DlgReplyButtons"></div></div>
</body>
</html>