Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <title>Special Characters for LCD Display</title>
- <!-- written by Martin Thaller / Vienna / Austria -->
- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=" crossorigin="anonymous"></script>
- <script>
- <!--
- $(document).ready(function() {
- $('td.lcd').on('click', function(){
- $(this).toggleClass('sel');
- calc();
- });
- calc();
- });
- function calc() {
- $('tr').each(function(){
- var $id = $(this).prop('id');
- var val=0;
- $('#'+$id+' td.sel').each(function(){
- val+= 1.0*$(this).data('val');
- });
- $('#'+$id+' .calc').html('0x'+(val.toString(16).length<2?'0':'')+val.toString(16));
- });
- var code = new Array();
- $('.calc').each(function(){ code.push($(this).html()); });
- $('code').html(JSON.stringify(code).replace(/"/g,''));
- }
- -->
- </script>
- <style>
- <!--
- body { font-family:Arial,Helvetica; font-size: 12px; }
- table { border-collapse:collapse; background-color: #F1F1F1; margin: 0 0 10px 0; font-family:Arial,Helvetica; font-size: 12px; }
- td { padding:0; border:1px solid #fff; }
- .lcd { min-width: 16px; min-height:16px; }
- .sel { background-color: #0000FF; }
- .calc { min-width: 3em; text-align:right; background-color: #fff; }
- fieldset { display:inline-block; }
- -->
- </style>
- </head>
- <body>
- <form>
- <fieldset>
- <legend>Create your character</legend>
- <table>
- <?php
- for($row=0; $row < 8; $row++) {
- echo "\n<tr id='r".$row."'>";
- for($col=4; $col > -1; $col--) {
- echo "<td class='lcd' data-val='".pow(2,$col)."'></td>";
- }
- echo "<td class='calc'>0</td>";
- echo "\n</tr>";
- }
- ?>
- </table>
- <input type="reset" onclick="$('.sel').removeClass('sel'); calc();" />
- </fieldset>
- </form>
- <code></code>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement