Skip to content

Commit 26187b7

Browse files
authored
Update index.html
1 parent 13644f4 commit 26187b7

1 file changed

Lines changed: 16 additions & 33 deletions

File tree

index.html

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -116,43 +116,23 @@ <h1>ScriptJSON Downloads</h1>
116116
<h2>Download JSON Files</h2>
117117
<p>Click the buttons below to download the JSON files:</p>
118118
<div class="buttons">
119-
<a href="4ndyPi.json" download="4ndyPi.json" class="button">
120-
4ndyPi.json
121-
</a>
122-
<a href="4ndyPhi.json" download="4ndyPhi.json" class="button">
123-
4ndyPhi.json
124-
</a>
125-
<a href="4ndyProfanities.json" download="4ndyProfanities.json" class="button">
126-
4ndyProfanities.json
127-
</a>
128-
<a href="4ndyGreetingsAndFarewells.json" download="4ndyGreetingsAndFarewells.json" class="button">
129-
4ndyGreetingsAndFarewells.json
130-
</a>
131-
<a href="4ndyEuler.json" download="4ndyEuler.json" class="button">
132-
4ndyEuler.json
133-
</a>
134-
<a href="4ndyRandomCities.json" download="4ndyRandomCities.json" class="button">
135-
4ndyRandomCities.json
136-
</a>
137-
<a href="4ndyRandomUsernames.json" download="4ndyRandomUsernames.json" class="button">
138-
4ndyRandomUsernames.json
139-
</a>
119+
<button class="button" data-file="4ndyPi.json">Download 4ndyPi.json</button>
120+
<button class="button" data-file="4ndyPhi.json">Download 4ndyPhi.json</button>
121+
<button class="button" data-file="4ndyProfanities.json">Download 4ndyProfanities.json</button>
122+
<button class="button" data-file="4ndyGreetingsAndFarewells.json">Download 4ndyGreetingsAndFarewells.json</button>
123+
<button class="button" data-file="4ndyEuler.json">Download 4ndyEuler.json</button>
124+
<button class="button" data-file="4ndyRandomCities.json">Download 4ndyRandomCities.json</button>
125+
<button class="button" data-file="4ndyRandomUsernames.json">Download 4ndyRandomUsernames.json</button>
140126
</div>
141127
</section>
142128

143129
<section id="js-files">
144130
<h2>Download JavaScript Files</h2>
145131
<p>Click the buttons below to download the JavaScript files:</p>
146132
<div class="buttons">
147-
<a href="4ndyMath.js" download="4ndyMath.js" class="button">
148-
4ndyMath.js
149-
</a>
150-
<a href="4ndyUserData.js" download="4ndyUserData.js" class="button">
151-
4ndyUserData.js
152-
</a>
153-
<a href="4ndyBetterIframes.js" download="4ndyBetterIframes.js" class="button">
154-
4ndyBetterIframes.js
155-
</a>
133+
<button class="button" data-file="4ndyMath.js">Download 4ndyMath.js</button>
134+
<button class="button" data-file="4ndyUserData.js">Download 4ndyUserData.js</button>
135+
<button class="button" data-file="4ndyBetterIframes.js">Download 4ndyBetterIframes.js</button>
156136
</div>
157137
</section>
158138

@@ -163,9 +143,12 @@ <h2>Download JavaScript Files</h2>
163143

164144
<script>
165145
document.querySelectorAll('.button').forEach(button => {
166-
button.addEventListener('click', (event) => {
167-
event.preventDefault();
168-
window.location.href = button.getAttribute('href');
146+
button.addEventListener('click', function () {
147+
const file = this.getAttribute('data-file');
148+
const link = document.createElement('a');
149+
link.href = file;
150+
link.download = file;
151+
link.click();
169152
});
170153
});
171154
</script>

0 commit comments

Comments
 (0)