瀏覽代碼

center the search bar if user doesn't have any bookmarks set

TheBaum123 1 年之前
父節點
當前提交
0d0a1cb7e2
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      scripts/getPreferences.js

+ 8 - 1
scripts/getPreferences.js

@@ -64,7 +64,7 @@ let enableCustomWallpapers =
 
 //bookmarks
 let bookmarks = JSON.parse(localStorage.getItem("text-startpage:bookmarks"));
-if (!bookmarks) {
+if (!bookmarks && !bookmarks == "") {
     const xhr = new XMLHttpRequest();
     xhr.open("GET", "json/defaultBookmarks.json");
     xhr.responseType = "json";
@@ -87,6 +87,13 @@ if (!bookmarks) {
     };
 }
 
+if (bookmarks == "") {
+    document.body.removeChild(document.getElementById("bookmarks-container"));
+    document.getElementById("search-container").style.top = "50vh";
+    document.getElementById("search-container").style.transform =
+        "translate(-50%, -50%)";
+}
+
 //set the theme
 if (localStorage.getItem("text-startpage:theme") == "custom") {
     const colorsToInject = document.createElement("style");