@@ -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 ( ) {
@@ -124,23 +134,11 @@ function resizeText(multiplier) {
124134 document . getElementById ( "text" ) . style . fontSize = parseFloat ( document . getElementById ( "text" ) . style . fontSize ) + ( multiplier * 0.2 ) + "em" ;
125135}
126136
127- function printConsoleArt ( ) {
128- const consoleStr = `
129- ███████ ██████ ██ ████████ ██████ █████ ██████
130- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
131- █████ ██ ██ ██ ██ ██████ ███████ ██ ██
132- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
133- ███████ ██████ ██ ██ ██ ██ ██ ██████
134-
135-
136- Github: https://github.com/shweshi/editpad
137- `
138- console . log ( consoleStr ) ;
139- }
140-
141137// Close the dropdown menu if the user clicks outside of it
142138window . onclick = function ( event ) {
143- if ( event . target . matches ( '.font' ) || event . target . matches ( '.color-button' ) ) {
139+ if ( event . target . matches ( '.font' ) || event . target . matches ( '.color-button' ) || event . target . matches ( '.share-button' ) || event . target . matches ( '.bottom' )
140+ || event . target . matches ( '.input' ) || event . target . matches ( '.shareLinkButton' ) || event . target . matches ( 'h3' ) || event . target . matches ( '.share-div' )
141+ || event . target . matches ( '.copied' ) ) {
144142 event . stopPropagation ( ) ;
145143 } else {
146144 if ( ! event . target . matches ( '.dropbtn' ) ) {
@@ -153,5 +151,69 @@ window.onclick = function (event) {
153151 }
154152 }
155153 }
154+
155+ if ( ! event . target . matches ( '.share-button' ) ) {
156+ document . getElementById ( 'bottom' ) . style . display = 'none' ;
157+ }
158+ }
159+ }
160+
161+ function share ( ) {
162+ var tooltip = document . getElementById ( 'bottom' ) ;
163+ if ( tooltip . style . display != 'block' ) {
164+ tooltip . style . display = 'block' ;
165+ const input = document . getElementById ( 'shareLink' ) ;
166+ input . value = 'https://editpad.shashi.dev?content=' + getEncodedContent ( ) ;
167+ input . select ( ) ;
168+ } else {
169+ tooltip . style . display = 'none' ;
156170 }
171+ }
172+
173+ function getEncodedContent ( ) {
174+ const content = document . getElementById ( "text" ) . value ;
175+ return window . btoa ( content ) ;
176+ }
177+
178+ function copyToClipboard ( ) {
179+ const content = document . getElementById ( "shareLink" ) ;
180+
181+ content . select ( ) ;
182+ content . setSelectionRange ( 0 , 99999 ) ; /* For mobile devices */
183+ document . execCommand ( "copy" ) ;
184+
185+ var copied = document . getElementById ( 'copied' ) ;
186+ if ( copied . style . display != 'block' ) {
187+ copied . style . display = 'block' ;
188+ } else {
189+ copied . style . display = 'none' ;
190+ }
191+ }
192+
193+ function setContent ( ) {
194+ let params = ( new URL ( document . location ) ) . searchParams ;
195+ let content = params . get ( "content" ) ;
196+ if ( content ) {
197+ let textarea = document . querySelector ( 'textarea' )
198+
199+ text = window . atob ( content ) ;
200+ textarea . value = text ;
201+ setCleanRequired ( 0 ) ;
202+ }
203+ }
204+
205+ function printConsoleArt ( ) {
206+ const consoleStr = `
207+ ███████ ██████ ██ ████████ ██████ █████ ██████
208+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
209+ █████ ██ ██ ██ ██ ██████ ███████ ██ ██
210+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
211+ ███████ ██████ ██ ██ ██ ██ ██ ██████
212+
213+
214+ Github: https://github.com/shweshi/editpad
215+
216+ Version: 1.0.1
217+ `
218+ console . log ( consoleStr ) ;
157219}
0 commit comments