From 81ea801e7c2e909bbaaf0d13c4ad6812ed4a82f2 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Wed, 7 Sep 2022 11:27:35 +0200 Subject: [PATCH] added bookmark size setting --- db.go | 8 ++++---- settings.go | 2 ++ static/customize.js | 8 +++++++- templates/customize.html | 12 ++++++++++++ templates/index.html | 2 ++ text.go | 3 +++ 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/db.go b/db.go index 9730f8e..3e178ef 100644 --- a/db.go +++ b/db.go @@ -20,8 +20,8 @@ var ( GetBookmarksBySessionIdOrdered = advsql.QueryMany(Database, "SELECT * FROM bookmarks WHERE session_id = ? ORDER BY order_priority", ScanBookmarkPkFirst) DeleteBookmarksBySessionID = advsql.Delete(Database, "DELETE FROM bookmarks WHERE session_id = ?") - InsertSettings = advsql.Insert(Database, "INSERT INTO settings VALUES (?, ?, ?, ?, ?)", ScanSettingsPkFirst) - UpdateSettings = advsql.Update(Database, "UPDATE settings SET background_color = ?, foreground_color = ?, search_query = ?, border_radius = ? WHERE session_id = ?", ScanSettingsPkLast) + InsertSettings = advsql.Insert(Database, "INSERT INTO settings VALUES (?, ?, ?, ?, ?, ?)", ScanSettingsPkFirst) + UpdateSettings = advsql.Update(Database, "UPDATE settings SET background_color = ?, foreground_color = ?, search_query = ?, border_radius = ?, bookmark_size = ? WHERE session_id = ?", ScanSettingsPkLast) GetSettingsBySessionID = advsql.QueryOne(Database, "SELECT * FROM settings WHERE session_id = ?", ScanSettingsPkFirst) ) @@ -83,9 +83,9 @@ func ScanBookmarkPkLast(u *Bookmark, encode advsql.ScanFunc) error { } func ScanSettingsPkFirst(u *Settings, encode advsql.ScanFunc) error { - return encode(&u.SessionID, &u.Background, &u.Foreground, &u.Search, &u.BorderRadius) + return encode(&u.SessionID, &u.Background, &u.Foreground, &u.Search, &u.BorderRadius, &u.BookmarkSize) } func ScanSettingsPkLast(u *Settings, encode advsql.ScanFunc) error { - return encode(&u.Background, &u.Foreground, &u.Search, &u.BorderRadius, &u.SessionID) + return encode(&u.Background, &u.Foreground, &u.Search, &u.BorderRadius, &u.BookmarkSize, &u.SessionID) } diff --git a/settings.go b/settings.go index 230184e..e5e4469 100644 --- a/settings.go +++ b/settings.go @@ -7,6 +7,7 @@ type Settings struct { Foreground string `json:"foreground_color"` Search string `json:"search_query"` BorderRadius string `json:"border_radius"` + BookmarkSize string `json:"bookmark_size"` } func DefaultSettings() *Settings { @@ -15,5 +16,6 @@ func DefaultSettings() *Settings { Foreground: "#ffffff", Search: "https://duckduckgo.com/?q=%s", BorderRadius: "1.5%", + BookmarkSize: "10em", } } diff --git a/static/customize.js b/static/customize.js index 7909284..9b57224 100644 --- a/static/customize.js +++ b/static/customize.js @@ -4,10 +4,15 @@ function main() { const bgColor = document.querySelector("#bg-color"); const fgColor = document.querySelector("#fg-color"); const borderRadius = document.querySelector("#border-radius"); + const bookmarkSize = document.querySelector("#bookmark-size"); bgColor.addEventListener("change", () => document.body.style.backgroundColor = bgColor.value); fgColor.addEventListener("change", () => document.body.style.color = fgColor.value); borderRadius.addEventListener("change", () => document.querySelector(":root").style.setProperty("--bookmark-border-radius", borderRadius.value)); + bookmarkSize.addEventListener("change", () => { + document.querySelector(":root").style.setProperty("--bookmark-width", bookmarkSize.value); + document.querySelector(":root").style.setProperty("--bookmark-height", bookmarkSize.value); + }); const save = document.querySelector("#button"); save.addEventListener("click", saveChanges); @@ -37,7 +42,8 @@ function saveChanges() { background_color: document.querySelector("#bg-color").value, foreground_color: document.querySelector("#fg-color").value, search_query: document.querySelector("#search-string").value, - border_radius: document.querySelector("#border-radius").value + border_radius: document.querySelector("#border-radius").value, + bookmark_size: document.querySelector("#bookmark-size").value }; const data = { bookmarks, settings } diff --git a/templates/customize.html b/templates/customize.html index 55a96e2..b8f4b47 100644 --- a/templates/customize.html +++ b/templates/customize.html @@ -11,6 +11,8 @@