diff options
-rw-r--r-- | index.html | 53 |
1 files changed, 45 insertions, 8 deletions
@@ -1,34 +1,71 @@ -<textarea rows="5" cols="80" id="input"> +<title> + HexScraper: scrape hex colors from text +</title> + +<h1> + HexScraper: scrape hex colors from text +</h1> +<body style="font-family:sans;"> +<textarea rows="20" cols="80" id="input"> </textarea> <br> <button value="Go" onclick="scrape()"/>Go</button> +<input id="labels" type="checkbox" name="labels" checked=True>Labels?</input> +<input id="space" type="checkbox" name="spaces" checked=True>Spacing?</input> +<input id="big" type="checkbox" name="big" checked=True>Big Blocks?</input> </br> <hr> <div id='results'> </div> +</body> <script> +body = "" + function write(stuff) { -document.getElementById('results').innerHTML += stuff; +body += stuff; +} + +function reset() { + body = "" +} + +function flush() { +document.getElementById('results').innerHTML = body; } function scrape() { - document.getElementById('results').innerHTML = "" + reset(); + flush(); + data = document.getElementById("input").value i=0; regex = /#[0-9a-f]{3,6}[^[0-9a-f]/gi, result = [] + size="70x70"; + if(document.getElementById("big").checked) { + size="180x180"; + } while ( (result = regex.exec(data)) ) { i++; - console.log(result[0]); - write('<div>'); - write(result[0]); - write('<img src="http://dummyimage.com/40x40/' + result[0].slice(1, result[0].length) + '&text=+">'); - write('</div>') + if(document.getElementById("space").checked) { + write('<div style="float:left; padding: 1em; display:inline;">'); + } + else { + write('<div style="float:left;">') + } + if(document.getElementById("labels").checked) { + write(result[0]); + write("<br>"); + } + write('<img title=' + result[0] + 'src="http://dummyimage.com/' + size + '/' + result[0].slice(1, result[0].length) + '&text=+" style="border: 2px black solid;">'); + write('</div>'); } if(i == 0) { write('nothing found'); } + flush(); + } </script> |