@@ -31,7 +31,7 @@ var debug;
31
31
32
32
// Set DOM javascript controls
33
33
document . getElementById ( "prompterStyle" ) . setAttribute ( "onclick" , "setStyleEvent(value);" ) ;
34
- document . getElementById ( "promptIt" ) . setAttribute ( " onclick" , "submitTeleprompter(); return false;" ) ;
34
+ document . getElementById ( "promptIt" ) . onclick = submitTeleprompter ;
35
35
36
36
// Set default style
37
37
setStyle ( ) ;
@@ -124,17 +124,20 @@ var debug;
124
124
console . log ( "Save pressed" ) ;
125
125
}
126
126
127
- // Initialize objects after DOM is loaded
128
- if ( document . readyState === "interactive" || document . readyState === "complete" )
129
- // Call init if the DOM (interactive) or document (complete) is ready.
130
- init ( ) ;
131
- else
132
- // Set init as a listener for the DOMContentLoaded event.
133
- document . addEventListener ( "DOMContentLoaded" , init ) ;
134
-
135
- } ( ) ) ;
136
-
137
- // DOM Level functions, allow UI click interaction
127
+ function resetTeleprompter ( event ) {
128
+ // Stops the event but continues executing he code.
129
+ event . preventDefault ( ) ;
130
+ // INFO: event.target === document.getElementById("promptIt") and more efficient.
131
+ event . target . textContent = "Prompt It!" ;
132
+ event . target . onclick = submitTeleprompter ;
133
+ document . getElementById ( "content" ) . style . display = "" ;
134
+ document . getElementById ( "editorcontainer" ) . style . display = "" ;
135
+ document . getElementById ( "footer" ) . style . display = "" ;
136
+ // Hide prompter frame
137
+ document . getElementById ( "framecontainer" ) . style . display = "none" ;
138
+ }
139
+
140
+ // DOM Level functions, allow UI click interaction
138
141
// On change Prompter Style
139
142
function setStyleEvent ( prompterStyle ) {
140
143
if ( setStyle ) {
@@ -152,7 +155,9 @@ function setStyleEvent(prompterStyle) {
152
155
}
153
156
154
157
// On "Prompt It!" clicked
155
- function submitTeleprompter ( ) {
158
+ function submitTeleprompter ( event ) {
159
+ // Stops the event but continues executing the code.
160
+ event . preventDefault ( ) ;
156
161
// Get html from editor
157
162
var htmldata = tinymce . get ( "prompt" ) . getContent ( ) ;
158
163
@@ -173,7 +178,9 @@ function submitTeleprompter() {
173
178
document . getElementById ( "framecontainer" ) . style . display = "block" ;
174
179
// Load teleprompter
175
180
document . getElementById ( "teleprompterframe" ) . src = "teleprompter.html?debug=1" ;
176
- document . getElementById ( "promptIt" ) . innerHTML = "<strong>Reset...</strong>" ;
181
+ // INFO: event.target === document.getElementById("promptIt") and more efficient.
182
+ event . target . textContent = "Reset..." ;
183
+ event . target . onclick = resetTeleprompter ;
177
184
}
178
185
179
186
// "Secondary"
@@ -197,3 +204,13 @@ function submitTeleprompter() {
197
204
}
198
205
*/
199
206
}
207
+
208
+ // Initialize objects after DOM is loaded
209
+ if ( document . readyState === "interactive" || document . readyState === "complete" )
210
+ // Call init if the DOM (interactive) or document (complete) is ready.
211
+ init ( ) ;
212
+ else
213
+ // Set init as a listener for the DOMContentLoaded event.
214
+ document . addEventListener ( "DOMContentLoaded" , init ) ;
215
+
216
+ } ( ) ) ;
0 commit comments