User:Crashaholic/citizen.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
(shortened it for a quicker response)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
var r = $(':root');
var r = document.querySelector(':root');


// Create a function for getting a variable value
// Create a function for getting a variable value
Line 16: Line 16:
}
}


if ($(".skin-citizen-light"))
if ($('html').hasClass("skin-citizen-light"))
{
{
set_var("--color-primary__h", "39");
set_var("--color-primary__h", "rgb(240, 234, 214)");
set_var("--color-primary__s", "63%");
set_var("--color-primary__s", "rgb(240, 234, 214)");
set_var("--color-primary__l", "59%");
set_var("--color-primary__l", "rgb(240, 234, 214)");
set_var("--color-surface-0", "rgb(240, 234, 214)");
set_var("--color-surface-0", "rgb(240, 234, 214)");
set_var("--color-surface-1", "rgb(243, 235, 205)");
set_var("--color-surface-1", "rgb(243, 235, 205)");
Line 27: Line 26:
set_var("--color-surface-3", "rgb(231, 210, 147)");
set_var("--color-surface-3", "rgb(231, 210, 147)");
set_var("--color-surface-4", "rgb(226, 201, 132)");
set_var("--color-surface-4", "rgb(226, 201, 132)");
set_var("--color-base", "hsl(var(--color-primary__h),var(--color-primary__s),calc(var(--color-primary__l) * 0.3))");
set_var("--color-base--emphasized", "hsl(var(--color-primary__h),var(--color-primary__s),calc(var(--color-primary__l) * 0.2))");
set_var("--color-base--subtle", "hsl(var(--color-primary__h),var(--color-primary__s),calc(var(--color-primary__l) * 0.5))");
}
}
function refreshPage()
{
location.reload();
return false;
}
function attachRefresh()
{
$('#citizen-pref-theme-option-auto').attr('onClick', 'refreshPage();');
$('#citizen-pref-theme-option-dark').attr('onClick', 'refreshPage();');
$('#citizen-pref-theme-option-light').attr('onClick', 'refreshPage();');
}
function attachRefreshDelay()
{
setTimeout(attachRefresh, 10);
}
setTimeout(function () {$('#citizen-pref-toggle').attr('onClick', 'attachRefreshDelay();');}, 200);

Latest revision as of 15:30, 9 September 2023

var r = document.querySelector(':root');

// Create a function for getting a variable value
function get_var(name) 
{
  // Get the styles (properties and values) for the root
  var rs = getComputedStyle(r);
  rs.getPropertyValue(name);
}

// Create a function for setting a variable value
function set_var(name, value) 
{
  // Set the value of variable --blue to another value (in this case "lightblue")
  r.style.setProperty(name, value);
}

if ($('html').hasClass("skin-citizen-light"))
{
	set_var("--color-primary__h", "39");
	set_var("--color-primary__s", "63%");
	set_var("--color-primary__l", "59%");
	set_var("--color-surface-0", "rgb(240, 234, 214)");
	set_var("--color-surface-1", "rgb(243, 235, 205)");
	set_var("--color-surface-2", "rgb(240, 226, 179)");
	set_var("--color-surface-3", "rgb(231, 210, 147)");
	set_var("--color-surface-4", "rgb(226, 201, 132)");
	set_var("--color-base", "hsl(var(--color-primary__h),var(--color-primary__s),calc(var(--color-primary__l) * 0.3))");
	set_var("--color-base--emphasized", "hsl(var(--color-primary__h),var(--color-primary__s),calc(var(--color-primary__l) * 0.2))");
	set_var("--color-base--subtle", "hsl(var(--color-primary__h),var(--color-primary__s),calc(var(--color-primary__l) * 0.5))");
}

function refreshPage()
{
	location.reload();
	return false;
}

function attachRefresh()
{
	$('#citizen-pref-theme-option-auto').attr('onClick', 'refreshPage();');
	$('#citizen-pref-theme-option-dark').attr('onClick', 'refreshPage();');
	$('#citizen-pref-theme-option-light').attr('onClick', 'refreshPage();');
}

function attachRefreshDelay()
{
	setTimeout(attachRefresh, 10);
}

setTimeout(function () {$('#citizen-pref-toggle').attr('onClick', 'attachRefreshDelay();');}, 200);