@@ -96,6 +96,16 @@ function applyDarkMode() {
9696 for ( i = 0 ; i < dropdown . length ; i ++ ) {
9797 dropdown [ i ] . classList . toggle ( "dark-mode-dropdown-content" ) ;
9898 }
99+
100+ var tooltip = document . getElementsByClassName ( "bottom" ) ;
101+ for ( i = 0 ; i < dropdown . length ; i ++ ) {
102+ tooltip [ i ] . classList . toggle ( "dark-mode-bottom" ) ;
103+ }
104+
105+ var input = document . getElementsByClassName ( "input" ) ;
106+ for ( i = 0 ; i < dropdown . length ; i ++ ) {
107+ input [ i ] . classList . toggle ( "dark-mode-input" ) ;
108+ }
99109}
100110
101111function checkDarkMode ( ) {
@@ -154,4 +164,36 @@ window.onclick = function (event) {
154164 }
155165 }
156166 }
167+ }
168+
169+ function share ( ) {
170+ var tooltip = document . getElementById ( 'bottom' ) ;
171+ if ( tooltip . style . display != 'block' ) {
172+ tooltip . style . display = 'block' ;
173+ const input = document . getElementById ( 'shareLink' ) ;
174+ input . value = 'https://editpad.org?content=' + getEncodedContent ( ) ;
175+ input . select ( ) ;
176+ } else {
177+ tooltip . style . display = 'none' ;
178+ }
179+ }
180+
181+ function getEncodedContent ( ) {
182+ const content = document . getElementById ( "text" ) . value ;
183+ return btoa ( content ) ;
184+ }
185+
186+ function copyToClipboard ( ) {
187+ const content = document . getElementById ( "text" ) ;
188+
189+ content . select ( ) ;
190+ content . setSelectionRange ( 0 , 99999 ) ; /* For mobile devices */
191+ document . execCommand ( "copy" ) ;
192+
193+ var copied = document . getElementById ( 'copied' ) ;
194+ if ( copied . style . display != 'block' ) {
195+ copied . style . display = 'block' ;
196+ } else {
197+ copied . style . display = 'none' ;
198+ }
157199}
0 commit comments