Skip to content

Commit ab9c5d5

Browse files
committed
Add comments
1 parent 2900756 commit ab9c5d5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ function download (type) {
128128
} else {
129129
return;
130130
}
131+
132+
// Add an anchor element that has the data as the href attribute, then click
133+
// the element to download the data.
131134
const str = `data:text/json;charset=utf-8,${data}`;
132135
const downloadLink = document.createElement('a');
133136
downloadLink.setAttribute('href', str);
@@ -138,11 +141,14 @@ function download (type) {
138141
downloadLink.click();
139142
downloadLink.remove();
140143
}
144+
141145
function clear () {
146+
// Delete cached form data and reload the page.
142147
delete window.localStorage.cachedForm;
143148
window.location.reload();
144149
}
145150

151+
// Bind buttons to functions
146152
$('#download-json').click(() => download('json'));
147153
$('#download-yaml').click(() => download('yml'));
148154

0 commit comments

Comments
 (0)