v0.0.22 - Theme toggle: instant visual response via JS class toggle, then save via XHR without page reload
This commit is contained in:
+14
-2
@@ -507,9 +507,21 @@ static char *sovereign_page_head(const char *title) {
|
||||
/* Build the theme-toggle button + closing </body></html>.
|
||||
* Returns a newly-allocated string (g_free). */
|
||||
static char *sovereign_page_foot(void) {
|
||||
/* The theme toggle uses JavaScript to immediately flip the CSS class
|
||||
* on <html> for an instant visual response, then saves the setting
|
||||
* via XHR without a page reload. */
|
||||
return g_strdup_printf(
|
||||
"<a class='theme-toggle' href='sovereign://settings/set?feature=theme_dark'>"
|
||||
"%s</a>\n"
|
||||
"<a class='theme-toggle' href='#' onclick='"
|
||||
"var h=document.documentElement;"
|
||||
"var isDark=h.classList.contains(\"dark\");"
|
||||
"if(isDark){h.classList.remove(\"dark\");}"
|
||||
"else{h.classList.add(\"dark\");}"
|
||||
"this.textContent=isDark?\"Night Mode\":\"Day Mode\";"
|
||||
"var x=new XMLHttpRequest();"
|
||||
"x.open(\"GET\",\"sovereign://settings/set?feature=theme_dark\",false);"
|
||||
"x.send();"
|
||||
"return false;"
|
||||
"'>%s</a>\n"
|
||||
"</body></html>\n",
|
||||
settings_get()->theme_dark ? "Day Mode" : "Night Mode");
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@
|
||||
#ifndef SOVEREIGN_BROWSER_VERSION_H
|
||||
#define SOVEREIGN_BROWSER_VERSION_H
|
||||
|
||||
#define SB_VERSION "v0.0.21"
|
||||
#define SB_VERSION "v0.0.22"
|
||||
#define SB_VERSION_MAJOR 0
|
||||
#define SB_VERSION_MINOR 0
|
||||
#define SB_VERSION_PATCH 21
|
||||
#define SB_VERSION_PATCH 22
|
||||
|
||||
#endif /* SOVEREIGN_BROWSER_VERSION_H */
|
||||
|
||||
Reference in New Issue
Block a user