-
Notifications
You must be signed in to change notification settings - Fork 25
/
splash_screen.js
201 lines (186 loc) · 10.9 KB
/
splash_screen.js
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
var SplashScreen = class SplashScreen {
static the_checkmark_char = "\u2713" //unicode check
static splash_screen_tutorial_label_to_name(label){
if(label.startsWith(this.the_checkmark_char)) { return label.substring(1) }
else { return label.substring(3) }
}
static show_splash_screen_cb(vals){
if(vals.clicked_button_value == "splash_screen_dont_show_checkbox"){
let boolean_to_save = vals.splash_screen_dont_show_checkbox
persistent_set("dont_show_splash_screen_on_launch", boolean_to_save)
if(vals["splash_screen_dont_show_checkbox"]) {
out("The Welcome Dialog box will not come up when you launch DDE.<br/>" +
"You can still see the Welcome Dialog box by clicking<br/>" +
"the help button at the end of the Editor pane menu bar.")
}
}
else if(vals.clicked_button_value == "splash_screen_which_tutorial_id") {
let the_tut_label = vals.splash_screen_which_tutorial_id //includes checkmark or whitespace before actual name
let the_tut_name = SplashScreen.splash_screen_tutorial_label_to_name(the_tut_label)
let the_option_elt
for(let an_option_elt of splash_screen_which_tutorial_id.children){
if(an_option_elt.innerText.includes(the_tut_name)){ //beware, race condition on WinOS can cause a problem here
the_option_elt = an_option_elt
break;
}
}
splash_screen_which_tutorial_id.value = undefined //this "unselects the option, Now a user can click on the same option again
//and the event will make it to show_splash_screen_cb and
//we can operate on it. Otherwise, can't get an event though.
SplashScreen.handle_checking_of_tutorial(the_tut_label, the_tut_name, the_option_elt)
SplashScreen.perform_tutorial_action(the_tut_name)
}
else if(vals.clicked_button_value == "close_button"){
out("You can pop up the Welcome Dialog box by<br/>" +
"clicking the Help button<br/>" +
"at the end of the Editor pane menu bar.")
}
}
//this ensures that the label is checked,
//and if not, checks it and saves out the new vals.
//we now don't let the user uncheck a checkbox.
static handle_checking_of_tutorial(the_tut_label, the_tut_name, the_option_elt){
let is_already_checked = the_tut_label.startsWith(SplashScreen.the_checkmark_char)
if(!is_already_checked){
the_option_elt.innerHTML = "✓" + the_tut_name //check it
let all_options = []
for(let an_option_elt of splash_screen_which_tutorial_id.children){
let text = an_option_elt.innerHTML
all_options.push(text)
}
persistent_set("splash_screen_tutorial_labels", all_options)
}
}
static show(){
show_window({title: 'Welcome to DDE', //The title is used to find the window to auto_close it when user chooses certain tutorials.
// putting this in a span tag and making a smaller font means you can't drag the title bar to reposition the dialog
x: 320, //same as dexter ui on purpose so that dui will "cover up" the splash screen.
y: 100,
width: 310, //380 is splash screen width 480,
height: 375,
background_color: "#bae5fe", // pastel green: "#e7ffef",
callback: "SplashScreen.show_splash_screen_cb",
content:
`<div style="font-size:18px;margin-left:15px;">
<div style="font-size:30px;">Tutorials</div>
Please start with the first tutorial.<br/>
<select id="splash_screen_which_tutorial_id" size="9" data-oninput="true" style="font-size:16px;">` +
this.splash_screen_tutorial_options_html() +
`</select>
<div style="margin-top:5px;">
<input name="splash_screen_dont_show_checkbox" type="checkbox" data-onchange="true"/><span style="font-size:14px;">
Don't show this dialog on DDE launch.<br/>
(You can get it back by clicking
<button>Help</button><br/>
in the Editor pane menu bar.)</span></div>
</div>`})
}
/*
<!--<div style="font-family: 'Creepster';font-size: 60px;color:#7600f5">D o n't P a n i c !</div>
<i>The</i> answer is 42, but for other answers,<br/> -->
• Click <b style='color:blue;font-size:24px;'>?</b> in the upper right of the outer window <b style='font-size:24px;'>➚</b> <i>or</i>,<br/>
<!--• <button onclick="open_doc(help_system_doc_id)">Show Tutorial List</button> <i>or</i><br/>-->
<span style="vertical-align:top;">• Select a tutorial from: </span><br/>*/
static show_maybe(){
if(!persistent_get("dont_show_splash_screen_on_launch")){
this.show()
}
}
static close_window_with_help(){
SW.close_windows_of_title("Welcome to DDE")
out("You can pop up the Welcome Dialog box by<br/>" +
"clicking the Help button<br/>" +
"at the end of the Editor pane menu bar.")
}
//complication: what if I change the tutorials in a new release,
//what with some staying the same and wanting to preserve their checkmarks
static splash_screen_tutorial_options_html(){
let result = ""
let labels = persistent_get("splash_screen_tutorial_labels") //might have checkmarks in them.
for(let name_and_tooltip of this.splash_screen_tutorial_names_and_tooltips){
let name = name_and_tooltip[0]
let label = null
for(let a_label of labels) {
if(a_label.endsWith(name)){
label = a_label //might have a checkmark
break;
}
}
if(!label) { label = " " + name } //default is no checkmark
result += "<option class='splash_screen_item' " +
"title='" + name_and_tooltip[1] +
"' style='cursor:pointer;'>" +
label + "</option>\n"
}
return result
}
static perform_tutorial_action(name) {
for(let name_and_tooltip of this.splash_screen_tutorial_names_and_tooltips){
if(name_and_tooltip[0] == name){
let action = name_and_tooltip[2]
eval(action)
return
}
}
//don't have to have an action for the first step. It could just show a tooltip.
// shouldnt("in SplashScreen.perform_tutorial_action, couldn't find action for: " + name)
}
static start_dui_tutorial(){
//Job.define_and_start_job(__dirname + '/user_tools/dexter_user_interface2.js') //now done after
//user selects simulate or real so that the robt/job picks up the radio button value.
setTimeout(function() {
load_files(__dirname + "/tutorials/dexter_ui_tutorial.js")},
500)
}
static splash_screen_tutorial_names_and_tooltips = [
["Move Dexter", "Control Dexter or a simulation
via an interactive dialog
and learn Kinematics in the process.
Also at: Jobs menu/Dexter UI",
"SplashScreen.start_dui_tutorial()"],
["Configure Dexter", "How to connect your Dexter robot,
to your computer.",
"open_doc(configure_dexter_id)"],
//["Learning JavaScript", "Learn JS by stepping through code.",
// "open_doc(learning_js_doc_id)"],
["Learn JavaScript", "The basics of entering, running and debugging JavaScript.",
"SplashScreen.close_window_with_help(); open_doc(learning_js_doc_id); load_files(__dirname + '/tutorials/learn_js_tour.dde')"],
// ["Tooltips", "Hover the mouse on a widget to learn about it.",
// "open_doc(tooltips_doc_id)"] ,
//["Run JavaScript", "Use the Eval button to evaluate JavaScript.",
// "open_doc(eval_button_doc_id)"],
["Code Examples", "Insert code into the editor via menus.",
"open_doc(code_examples_doc_id)"],
// ["Test Suite examples", "The DDE diagnostic system doubles as code exammples.",
// "open_doc(TestSuite_for_help_doc_id)"],
["Doc Pane", "DDE documentation is contained in the right-hand documentation pane.",
"close_all_details()"],
["Find Button", "Search the documentation.",
"open_doc(find_button_doc_id)"],
// ["Click Help", "Clicking anywhere in the editor shows help in the output pane.",
// "open_doc(click_help_doc_id)"],
["Make Instruction", "Create instructions for a Job via a dialog box.",
"open_doc(make_instruction_pane_doc_id)"],
["Adding JavaScript", "Extend DDE and create applications.",
"open_doc(adding_javascript_doc_id)"],
["Help System", "How DDE helps you learn DDE.",
"open_doc(help_system_doc_id)"]
/* ["Dexter Features", "Videos demonstrating Dexter capabilities
plus an early look at DDE.",
"window.open('https://www.hdrobotic.com/features')"],
["Haddington Videos", "Haddington mission and hardware.",
"window.open('http://hdrobotic.com/videos/')"],
["Webinar Videos", "DDE in depth. 45 to 60 minute videos of the core concepts and syntax.",
"window.open('https://www.hdrobotic.com/blog/programming-in-dexter-development-environment-archive')"],
["JS for Python Programmers", "Instructions for DDE Jobs
look a lot like Python.",
"open_doc(js_for_python_programmers_doc_id)"],
["On-line Documentation", "Full on-line doc, including
release notes of the latest version.",
"window.open('https://www.hdrobotic.com/software')"],
["DDE Source Code", "DDE is open source software that is stored on GitHub.",
"window.open('https://github.com/cfry/dde')"]
*/
]
//called by get_persistent_values_defaults
static splash_screen_tutorial_labels(){
let result = []
for(let name_and_tooltip of this.splash_screen_tutorial_names_and_tooltips){
result.push(" " + name_and_tooltip[0])
}
return result
}
}