Created
July 20, 2021 20:03
-
-
Save sweeneyapps/5ec2ace9b0551b31f784a0e6c065b057 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>ASCII to Binary</title> | |
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script> | |
<style> | |
body { | |
background-color: black; | |
color: #fff; | |
letter-spacing: 0.5px; | |
font-family: monospace; | |
} | |
input { | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app"> | |
<h1>ASCII-Binary Converter</h1> | |
<input v-model="message" type="text"> <button v-on:click="clear">Clear</button> | |
<p> {{ binary }} </p> | |
</div> | |
<script> | |
var app = new Vue({ | |
el: '#app', | |
data: { | |
message: 'I am awesome!' | |
}, | |
computed: { | |
binary: function () { | |
return this.message.split('').map(function (char) { | |
return char.charCodeAt(0).toString(2).padStart(8, '0') | |
}).join(' ') | |
} | |
}, | |
methods: { | |
clear: function () { | |
this.message = '' | |
} | |
} | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment