@@ -27,12 +27,12 @@ document.addEventListener("DOMContentLoaded", function () {
27
27
nodeGradient . style . backgroundImage = tempImage ;
28
28
var nodeActions = document . createElement ( "div" ) ;
29
29
nodeActions . classList . add ( "ch-actions" ) ;
30
- var nodeCode = document . createElement ( "span " ) ;
30
+ var nodeCode = document . createElement ( "a " ) ;
31
31
nodeCode . classList . add ( "ch-code" ) ;
32
32
nodeCode . dataset . colorFrom = tempColorFrom ;
33
33
nodeCode . dataset . colorTo = tempColorTo ;
34
34
35
- var nodeGrab = document . createElement ( "span " ) ;
35
+ var nodeGrab = document . createElement ( "a " ) ;
36
36
nodeGrab . classList . add ( "ch-grab" ) ;
37
37
nodeGrab . dataset . colorFrom = tempColorFrom ;
38
38
nodeGrab . dataset . colorTo = tempColorTo ;
@@ -121,7 +121,10 @@ document.addEventListener("DOMContentLoaded", function () {
121
121
tempGradient . addColorStop ( 1 , eventColorTo ) ;
122
122
ctx . fillStyle = tempGradient ;
123
123
ctx . fillRect ( 0 , 0 , 500 , 500 ) ;
124
- window . open ( canvas . toDataURL ( ) ) ;
124
+ var dataURL = canvas . toDataURL ( ) ;
125
+ event . target . href = dataURL ;
126
+ var fileName = "coolHue-" + eventColorFrom . slice ( 1 , 7 ) + "-" + eventColorTo . slice ( 1 , 7 ) ;
127
+ event . target . setAttribute ( "download" , fileName ) ;
125
128
}
126
129
}
127
130
0 commit comments