-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (59 loc) · 2.17 KB
/
Copy pathscript.js
File metadata and controls
70 lines (59 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// script.js
// Function to display current time and date
function updateTime() {
const now = new Date();
const timeElement = document.querySelector('.time');
const dateElement = document.querySelector('.date');
const options = { hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true };
const timeString = now.toLocaleString('en-US', options);
const dateString = now.toDateString();
timeElement.textContent = `Time: ${timeString}`;
dateElement.textContent = `Date: ${dateString}`;
}
// Update time on page load
updateTime();
// Update time every second
setInterval(updateTime, 1000);
// Function to handle Google search
function googleSearch() {
const googleSearchBar = document.querySelector('.google-search');
const searchTerm = googleSearchBar.value;
if (searchTerm) {
const googleSearchURL = `https://www.google.com/search?q=${searchTerm}`;
window.open(googleSearchURL, '_blank');
}
}
// Function to handle DuckDuckGo search
function duckDuckGoSearch() {
const duckDuckGoSearchBar = document.querySelector('.duckduckgo-search');
const searchTerm = duckDuckGoSearchBar.value;
if (searchTerm) {
const duckDuckGoSearchURL = `https://duckduckgo.com/?q=${searchTerm}`;
window.open(duckDuckGoSearchURL, '_blank');
}
}
// Add event listeners to search bars
const googleSearchBar = document.querySelector('.google-search');
googleSearchBar.addEventListener('keyup', function(event) {
if (event.key === 'Enter') {
googleSearch();
}
});
const duckDuckGoSearchBar = document.querySelector('.duckduckgo-search');
duckDuckGoSearchBar.addEventListener('keyup', function(event) {
if (event.key === 'Enter') {
duckDuckGoSearch();
}
});
$(document).ready(function(){
$("ul.osx-dock li").each(function (type) {
$(this).hover(function () {
$(this).prev("li").addClass("nearby");
$(this).next("li").addClass("nearby");
},
function () {
$(this).prev("li").removeClass("nearby");
$(this).next("li").removeClass("nearby");
});
});
});