User:Canadabonk/sandbox.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 6:
color: black;
padding:10px;
color-scheme:light;
}
#cosmostweaks-coloreditor td, #cosmostweaks-coloreditor th {
Line 52 ⟶ 53:
text = "";
for (const x of CSSvarsList) {
text += `<tr data-row="${x}"><th>${x}</th><td class="lightcol">${createinput(lightmodevars[x])}</td><td class="darkcol">${createinput(darkmodevars[x])}</td></tr>\n`;
}
return text;
}
function updatecolors(){
const
val = $(this).val(),
variable = $(this).closest('tr').attr('data-row');
$(this).siblings('input').attr('value', val);
switch($(this).parent().attr('class')) {
case 'lightcol':
lightmodevars[variable] = val;
break;
case 'darkcol':
darkmodevars[variable] = val;
}
printcolors(lightmodevars);
printcolors(darkmodevars);
}
function printcolors(list) {
colorlist = "";
for (const x in list) {
colorlist += x + ": " + list[x] + '\n';
}
$('.' + list).text(colorlist);
}
$('#cosmostweaks-coloreditor input').change(updatecolors());
$('#cosmostweaks-coloreditor').html(`
Line 66 ⟶ 93:
${CSSvarsRows()}
</table>
<p>Light mode colors:</p>
<pre class="lightmodevars">
</pre>
<p>Dark mode colors:</p>
<pre class="darkmodevars">
</pre>
`);
}
259

edits