This repository was archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolors.html
More file actions
100 lines (99 loc) · 5.36 KB
/
colors.html
File metadata and controls
100 lines (99 loc) · 5.36 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<html>
<head>
<style>
table, td, th {
border: none;
border: 0.5px solid #888;
}
td {
min-width: 200px;
height: 40px;
}
input {
width: 70px;
}
td:nth-child(-n+6) {
background-color: black;
color: white;
}
td:nth-child(5),
td:nth-child(6),
td:nth-child(7),
td:nth-child(10) {
font-size: 24px;
}
textarea {
width: 100%;
height: 200px;
}
.sp-replacer {
display: none !important;
}
td:hover .sp-replacer,
td:focus .sp-replacer {
display: inline-block !important;
}
</style>
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.css"/>
<body>
<table width="100%" cellspacing="0" cellpadding="0"></table>
<button id="import">Import</button>
<button id="export">Export</button>
<textarea id="results">
{ "grey":["#000000","#111111","#222222","#444444","#666666","#999999","#bbbbbb","#dddddd","#eeeeee","#ffffff"] ,"accent":["#000000","#111111","#222222","#444444","#666666","#999999","#bbbbbb","#dddddd","#eeeeee","#ffffff"] ,"red":["#520000","#670000","#850000","#ac0000","#ee0000","#ff2222","#fd5151","#ff7474","#ff8f8f","#ffaeae"] ,"pink":["#5a0020","#78002b","#980036","#b80042","#da004e","#ff3996","#fd60aa","#ff73b5","#ff87c0","#ffa5cf"] ,"purple":["#33003a","#490052","#6c0079","#8a009b","#a500ba","#ce00e8","#ed61ff","#f07cff","#f49cff","#f4affd"] ,"deepPurple":["#2a0049","#3a0063","#4c0081","#5d009f","#7e00d8","#9500ff","#b44aff","#bb63f9","#c97eff","#d79fff"] ,"indigo":["#100049","#160063","#20008c","#2801b0","#3a00ff","#835fff","#9373ff","#9e82ff","#af97ff","#c3b2ff"] ,"blue":["#001947","#002569","#003494","#0041bb","#0059ff","#4083ff","#5892fd","#74a5ff","#95baff","#acc9ff"] ,"lightBlue":["#002850","#003f7d","#0055a8","#0066ca","#007ffc","#41a1ff","#58adff","#65b3ff","#92c9ff","#a1d1ff"] ,"cyan":["#002c38","#003f50","#006681","#0089ae","#009dc7","#00c9ff","#1ccfff","#33d4ff","#77e2ff","#9beaff"] ,"teal":["#002a20","#003829","#004e3a","#007658","#009d75","#00ff9c","#29ffac","#56ffbd","#79ffcb","#98ffd7"] ,"green":["#002a11","#003d18","#005a23","#00762e","#008c37","#00f961","#24ff70","#49ff88","#79ffa7","#acffc9"] ,"lightGreen":["#143000","#1b3f00","#296100","#357f00","#429d00","#6fff00","#8efd38","#a1fd5a","#b1ff75","#c7ff9b"] ,"lime":["#223400","#293f00","#3b5a00","#4d7600","#649900","#aeff00","#bdff2d","#caff58","#d4ff77","#dfff9b"] ,"yellow":["#303000","#454400","#676600","#818000","#929100","#f6f600","#ffff3a","#ffff7c","#ffff90","#ffffac"] ,"amber":["#302500","#413200","#614b00","#876800","#b28900","#ffc500","#ffc235","#ffcf5e","#ffd677","#ffdf92"] ,"orange":["#3d1c00","#612d00","#833d00","#ae5100","#e56a00","#ff9625","#ff9e36","#ffb05c","#ffbd75","#ffca92"] ,"deepOrange":["#3a0c00","#561100","#8a1c00","#b92500","#f53100","#ff6c3c","#ff7649","#ff8a64","#ffa588","#ffb299"] ,"brown":["#2c140e","#3b1e15","#5b3328","#724539","#85574a","#a47060","#ac7868","#b68373","#c59485","#d8a696"] ,"blueGrey":["#182023","#1e282c","#2f3e45","#40535b","#56707c","#718892","#7a8f98","#8d9fa7","#9badb6","#b1c5ce"] }</textarea>
<script>
window.onload = function(){
let makeTable = function(){
let html = '',results = document.getElementById('results').value.trim();
let json = JSON.parse(results);
for(color in json){
if(json.hasOwnProperty(color)){
html+= '<tr><th>'+color;
for (let i=0; i < json[color].length;i++){
html+= '<td class="td">Color: <input value="'+json[color][i]+'"></td>';
}
html+= '</tr>';
}
}
document.querySelector('table').innerHTML = html;
let tds = document.querySelectorAll('td');
for (let i=0; i < tds.length;i++){
let input = tds[i].querySelector('input');
tds[i].style.backgroundColor = input.value;
$(input).spectrum({
preferredFormat: "hex",
replacerClassName: 'td',
change: function(color){
$(tds[i]).css('backgroundColor',color.toHexString());
tds[i].style.backgroundColor = input.value;
}
}).show();
tds[i].addEventListener('change',function(){
$(input).spectrum("set", $(input).val());
tds[i].style.backgroundColor = input.value;
});
}
};
makeTable();
document.getElementById('import').addEventListener('click',function(){
makeTable();
});
document.getElementById('export').addEventListener('click',function(){
let data = {}, tr = document.querySelectorAll('tr');
for (let i=0; i<tr.length;i++){
let data2 = [], th = tr[i].querySelector('th').innerText, colors = tr[i].querySelectorAll('input');
for (let j=0; j<colors.length;j++){
data2.push(colors[j].value);
}
data[th] = data2;
}
document.getElementById('results').innerText = JSON.stringify(data).replace(/]/g,']\n\t').replace(/{/g,'{\n\t').replace(/}/g,'\n}');
});
};
</script>
</body></html>