aboutsummaryrefslogtreecommitdiff
path: root/index.html
blob: 3d04a5560da7d1fdc5314f3d9d270ecca63cec5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<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) {
body += stuff;
}

function reset() {
	body = ""
}

function flush() {
document.getElementById('results').innerHTML = body;
}

function scrape() {
	reset();
	flush();

	data = document.getElementById("input").value
	data = data + ' .'
	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++;
		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>