Commit c90e2fe 1 parent 151609f commit c90e2fe Copy full SHA for c90e2fe
File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 70
70
< div class ="header ">
71
71
< div class ="left-controls ">
72
72
< span id ="downloadButton " class ="icon "> Download</ span >
73
+ < span id ="clearButton " class ="icon "> Clear</ span >
73
74
</ div >
74
75
</ div >
75
76
82
83
const textarea = document . getElementById ( "editor" ) ;
83
84
const icons = document . querySelectorAll ( ".icon" ) ;
84
85
const downloadButton = document . getElementById ( "downloadButton" ) ;
86
+ const clearButton = document . getElementById ( "clearButton" ) ;
85
87
86
88
// State Variables
87
89
let buttonsHidden = false ;
127
129
URL . revokeObjectURL ( a . href ) ;
128
130
} ;
129
131
132
+ const clearText = ( ) => {
133
+ textarea . style . transition = "opacity 0.3s" ;
134
+ textarea . style . opacity = "0" ;
135
+
136
+ // Fade out, then fade in text
137
+ setTimeout ( ( ) => {
138
+ textarea . value = "" ;
139
+ textarea . style . opacity = "1" ;
140
+ localStorage . removeItem ( "shiroSavedText" ) ;
141
+ } , 300 ) ;
142
+ } ;
143
+
130
144
// Event Handlers
131
145
const setupEventListeners = ( ) => {
132
146
// Text area events
144
158
145
159
// Button events
146
160
downloadButton . addEventListener ( "click" , downloadText ) ;
161
+ clearButton . addEventListener ( "click" , clearText ) ;
147
162
148
163
// Icon hover effects
149
164
icons . forEach ( icon => {
You can’t perform that action at this time.
0 commit comments