Created
September 20, 2024 22:03
-
-
Save wilyJ80/71fe599ca6aa2e9d7ad1a17990039bba to your computer and use it in GitHub Desktop.
Poke download
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Try poking!</h1> | |
<button>POKE</button> | |
<p>Pokes: 0</p> | |
<a href="#">Download poke count</a> | |
<script src="./script.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
let pokes = 0; | |
let blob; | |
const button = document.querySelector('button'); | |
const pokesEl = document.querySelector('p'); | |
button.addEventListener('click', ()=> { | |
pokes++; | |
pokesEl.textContent = `Pokes: ${pokes}`; | |
blob = new Blob([pokes.toString()]); | |
}); | |
const anchor = document.querySelector("a"); | |
anchor.addEventListener('click', ()=> { | |
let url = URL.createObjectURL(blob); | |
anchor.href = url; | |
anchor.download = 'pokes.txt'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment