File tree 1 file changed +6
-0
lines changed 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,9 @@ function download (type) {
128
128
} else {
129
129
return ;
130
130
}
131
+
132
+ // Add an anchor element that has the data as the href attribute, then click
133
+ // the element to download the data.
131
134
const str = `data:text/json;charset=utf-8,${ data } ` ;
132
135
const downloadLink = document . createElement ( 'a' ) ;
133
136
downloadLink . setAttribute ( 'href' , str ) ;
@@ -138,11 +141,14 @@ function download (type) {
138
141
downloadLink . click ( ) ;
139
142
downloadLink . remove ( ) ;
140
143
}
144
+
141
145
function clear ( ) {
146
+ // Delete cached form data and reload the page.
142
147
delete window . localStorage . cachedForm ;
143
148
window . location . reload ( ) ;
144
149
}
145
150
151
+ // Bind buttons to functions
146
152
$ ( '#download-json' ) . click ( ( ) => download ( 'json' ) ) ;
147
153
$ ( '#download-yaml' ) . click ( ( ) => download ( 'yml' ) ) ;
148
154
You can’t perform that action at this time.
0 commit comments