File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change 10
10
</ code >
11
11
12
12
< input type ="button " value ="Copy " id ="copyBtn ">
13
+ < span id ="feedback "> </ span >
13
14
14
15
< script >
15
16
const input = document . getElementById ( 'input' ) ;
55
56
output . textContent = getAlgo ( ) ( input . value ) ;
56
57
} ) ;
57
58
59
+ var lastFeedbackFade = null ;
58
60
document . getElementById ( 'copyBtn' ) . addEventListener ( 'click' , ( ) => {
61
+ if ( lastFeedbackFade ) {
62
+ clearTimeout ( lastFeedbackFade ) ;
63
+ }
59
64
navigator . clipboard . writeText ( output . textContent ) ;
65
+ const feedback = document . getElementById ( 'feedback' ) ;
66
+ feedback . textContent = 'Copied at ' + new Date ( ) . toLocaleTimeString ( ) ;
67
+ lastFeedbackFade = setTimeout ( ( ) => {
68
+ feedback . textContent = "" ;
69
+ } , 2000 ) ;
60
70
} ) ;
61
71
</ script >
62
72
63
73
< style >
64
74
textarea # input {
75
+ display : block;
65
76
width : 100% ;
66
77
min-height : 6em ;
67
78
background-color : # 202 ;
68
79
border : # fdf 1px solid;
69
80
border-radius : 1em ;
70
81
padding : 1em 1em ;
71
82
color : # fdf ;
72
- margin-bottom : 0.5 em ;
83
+ margin-bottom : 1 em ;
73
84
resize : vertical;
74
85
}
75
86
# outputWrap {
81
92
padding : 1em 1em ;
82
93
margin-top : 1em ;
83
94
}
95
+ # output {
96
+ text-wrap : pretty;
97
+ overflow-wrap : break-word;
98
+ }
84
99
# copyBtn {
85
- display : block;
100
+ display : inline- block;
86
101
margin-top : 1em ;
87
102
background-color : # fdf ;
88
103
border : none;
89
- color : # 000 ;
104
+ color : # 101 ;
90
105
padding : .1em .5em ;
91
106
border-radius : .5em ;
107
+ cursor : pointer;
108
+ }
109
+ # copyBtn : hover {
110
+ background-color : # fff ;
92
111
}
93
112
# algo {
94
113
background-color : # fdf ;
95
114
border : none;
96
- color : # 000 ;
115
+ color : # 101 ;
97
116
padding : .1em .5em ;
98
117
border-radius : .5em ;
118
+ cursor : pointer;
119
+ }
120
+ # algo : hover {
121
+ background-color : # fff ;
99
122
}
100
123
</ style >
You can’t perform that action at this time.
0 commit comments