Added manifest to make it work like a chrome extension.
This commit is contained in:
@@ -17,7 +17,7 @@ body {
|
||||
padding-bottom: 35px; }
|
||||
.main #search-bar {
|
||||
width: 50%;
|
||||
margin: 0 auto;
|
||||
margin: 0 auto 50px auto;
|
||||
height: 45px; }
|
||||
.main #search-bar input {
|
||||
height: inherit;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<div id="main" class="main">
|
||||
<div id="message">
|
||||
<h1>Hey Deepjyoti, Good Morning!</h1>
|
||||
<h1 id="message-text">Hey Deepjyoti, Good Morning!</h1>
|
||||
</div>
|
||||
<div id="search-bar">
|
||||
<input id="search-bar-input" placeholder="Search something on Google"></input>
|
||||
@@ -46,8 +46,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- JQuery -->
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<!--Custom JS-->
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
15
js/main.js
15
js/main.js
@@ -3,7 +3,7 @@ window.onload = function() {
|
||||
}
|
||||
|
||||
searchBarId = "search-bar-input"
|
||||
messageId = "message h1"
|
||||
messageId = "message-text"
|
||||
userName = "Deepjyoti"
|
||||
|
||||
function initBody() {
|
||||
@@ -14,9 +14,9 @@ function initBody() {
|
||||
* other things.
|
||||
*/
|
||||
// Clear the search bar on load, just in case
|
||||
$("#" + searchBarId).val("")
|
||||
$("#" + searchBarId).on("keypress", (event) => {
|
||||
if (event.which != 13) return
|
||||
document.getElementById(searchBarId).value = ""
|
||||
document.getElementById(searchBarId).addEventListener("keypress", (event) => {
|
||||
if (event.key != 'Enter') return
|
||||
|
||||
// Open google with the search results.
|
||||
googleSearchUrl = "https://www.google.com/search?q="
|
||||
@@ -28,7 +28,8 @@ function initBody() {
|
||||
builtMsg = buildMsg()
|
||||
builtMsg == "" ?
|
||||
builtMsg = `Hello ${userName}` : builtMsg = `Hey ${userName}, ${builtMsg}!`
|
||||
$("#" + messageId).text(builtMsg)
|
||||
console.log(builtMsg)
|
||||
document.getElementById(messageId).textContent = builtMsg
|
||||
}
|
||||
|
||||
function buildMsg() {
|
||||
@@ -41,7 +42,7 @@ function buildMsg() {
|
||||
* 9 - 11:59 : Have a good day ahead
|
||||
* 12 - 16:59 : Good Afternoon
|
||||
* 17 - 19:59 : Good Evening
|
||||
* 20 - 23:59 : Get away from the computer
|
||||
* 20 - 23:59 : It's time to wrap up for the day
|
||||
*/
|
||||
date = new Date()
|
||||
currentHour = date.getHours()
|
||||
@@ -59,7 +60,7 @@ function buildMsg() {
|
||||
if (inRange(currentTime, 17, 19.59))
|
||||
return "Good Evening"
|
||||
if (inRange(currentTime, 20, 24))
|
||||
return "Get away from the computer"
|
||||
return "It's time to wrap up for the day"
|
||||
else
|
||||
return ""
|
||||
}
|
||||
|
||||
18
manifest.json
Normal file
18
manifest.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "minimal-startpage",
|
||||
"short_name": "minimal-startpage",
|
||||
"version": "1.0",
|
||||
"description": "Overrides the browsers newtab page with a custom startpage.",
|
||||
"author": "deepjyoti30",
|
||||
|
||||
"icons": {
|
||||
"48": "img/icon48.png",
|
||||
"96": "img/icon96.png",
|
||||
"128": "img/icon128.png",
|
||||
"192": "img/icon192.png"
|
||||
},
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "index.html"
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ body {
|
||||
|
||||
#search-bar {
|
||||
width: 50%;
|
||||
margin: 0 auto;
|
||||
margin: 0 auto 50px auto;
|
||||
height: 45px;
|
||||
|
||||
input {
|
||||
|
||||
Reference in New Issue
Block a user