serenity/Base/res/ladybird/newtab.html
2024-01-13 13:41:09 -05:00

97 lines
3.1 KiB
HTML

<!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="resource://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('github')">GitHub</button>
<button type="button" onclick="search('google')">Google</button>
<button type="button" onclick="search('wiby')">Wiby</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 == "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 == "wiby") {
url = new URL("https://wiby.me");
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>