mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 21:55:07 +00:00
Base+Browser+BrowserSettings: Add default page for new tab
This commit is contained in:
parent
6571455499
commit
b691269912
3 changed files with 99 additions and 2 deletions
97
Base/res/html/misc/new-tab.html
Normal file
97
Base/res/html/misc/new-tab.html
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>New Tab</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
text-align: center;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=search] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<br>
|
||||||
|
<img src="/res/icons/32x32/app-browser.png" width="64" height="64"><br><br>
|
||||||
|
<form>
|
||||||
|
<input type="search" name="q" id="user_query"><br><br>
|
||||||
|
<div id="search-buttons">
|
||||||
|
<button type="button" onclick="search('bing')">Bing</button>
|
||||||
|
<button type="button" onclick="search('duckduckgo')">DuckDuckGo</button>
|
||||||
|
<button type="button" onclick="search('frogfind')">FrogFind</button>
|
||||||
|
<button type="button" onclick="search('github')">GitHub</button>
|
||||||
|
<button type="button" onclick="search('google')">Google</button>
|
||||||
|
<button type="button" onclick="search('yandex')">Yandex</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<br><br>
|
||||||
|
<p>Your user agent is: <b><span id="ua"></span></b></p>
|
||||||
|
<p>This page loaded in <b><span id="loadtime"></span></b> ms</p>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
document.getElementById("ua").innerHTML = navigator.userAgent;
|
||||||
|
document.getElementById("loadtime").innerHTML = performance.now();
|
||||||
|
});
|
||||||
|
|
||||||
|
function search(searchEngine) {
|
||||||
|
let query = document.getElementById("user_query").value;
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url;
|
||||||
|
if (searchEngine == "bing") {
|
||||||
|
url = new URL("https://www.bing.com/search");
|
||||||
|
url.searchParams.set("q", query);
|
||||||
|
} else if (searchEngine == "duckduckgo") {
|
||||||
|
url = new URL("https://duckduckgo.com");
|
||||||
|
url.searchParams.set("q", query);
|
||||||
|
} else if (searchEngine == "frogfind") {
|
||||||
|
url = new URL("https://frogfind.com");
|
||||||
|
url.searchParams.set("q", query);
|
||||||
|
} else if (searchEngine == "github") {
|
||||||
|
url = new URL("https://github.com/search");
|
||||||
|
url.searchParams.set("q", query);
|
||||||
|
} else if (searchEngine == "google") {
|
||||||
|
url = new URL("https://google.com/search");
|
||||||
|
url.searchParams.set("q", query);
|
||||||
|
} else if (searchEngine == "yandex") {
|
||||||
|
url = new URL("https://yandex.com/search");
|
||||||
|
url.searchParams.set("text", query);
|
||||||
|
}
|
||||||
|
window.location.href = url.toString();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -95,7 +95,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto app_icon = GUI::Icon::default_icon("app-browser");
|
auto app_icon = GUI::Icon::default_icon("app-browser");
|
||||||
|
|
||||||
Browser::g_home_url = Config::read_string("Browser", "Preferences", "Home", "file:///res/html/misc/welcome.html");
|
Browser::g_home_url = Config::read_string("Browser", "Preferences", "Home", "file:///res/html/misc/welcome.html");
|
||||||
Browser::g_new_tab_url = Config::read_string("Browser", "Preferences", "NewTab", "file:///res/html/misc/welcome.html");
|
Browser::g_new_tab_url = Config::read_string("Browser", "Preferences", "NewTab", "file:///res/html/misc/new-tab.html");
|
||||||
Browser::g_search_engine = Config::read_string("Browser", "Preferences", "SearchEngine", {});
|
Browser::g_search_engine = Config::read_string("Browser", "Preferences", "SearchEngine", {});
|
||||||
Browser::g_content_filters_enabled = Config::read_bool("Browser", "Preferences", "EnableContentFilters", true);
|
Browser::g_content_filters_enabled = Config::read_bool("Browser", "Preferences", "EnableContentFilters", true);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
|
|
||||||
static String default_homepage_url = "file:///res/html/misc/welcome.html";
|
static String default_homepage_url = "file:///res/html/misc/welcome.html";
|
||||||
static String default_new_tab_url = "file:///res/html/misc/welcome.html";
|
static String default_new_tab_url = "file:///res/html/misc/new-tab.html";
|
||||||
static String default_search_engine = "";
|
static String default_search_engine = "";
|
||||||
static String default_color_scheme = "auto";
|
static String default_color_scheme = "auto";
|
||||||
static bool default_show_bookmarks_bar = true;
|
static bool default_show_bookmarks_bar = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue