generated from chadbaldwin/simple-blog-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yimche
committed
Oct 14, 2024
1 parent
37ebcf1
commit 2c5d62a
Showing
4 changed files
with
342 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const request = new XMLHttpRequest(); | ||
|
||
request.open('GET', 'https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=yimche&api_key=c70ac96baa4d4d456b3d3de853a3e67b&format=json'); | ||
request.send(); | ||
|
||
request.onreadystatechange = () => { | ||
if (request.status === 200) { | ||
|
||
// look at the response | ||
console.log(request.response); | ||
|
||
const recenttracks = JSON.parse(request.response).recenttracks; | ||
|
||
if (!recenttracks.track || !recenttracks.track.length) { | ||
console.log('track is empty'); | ||
return; | ||
} | ||
|
||
const artist = recenttracks.track[0].artist['#text']; | ||
const song = recenttracks.track[0].name; | ||
|
||
console.log(song); | ||
document.getElementById("now-playing").innerHTML = artist + ' - ' + song; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
const firstName = "julian"; //Update your own name here. | ||
var weekDays = [ | ||
"sunday", | ||
"monday", | ||
"tuesday", | ||
"wednesday", | ||
"thursday", | ||
"friday", | ||
"saturday", | ||
]; | ||
var months = [ | ||
"january", | ||
"february", | ||
"march", | ||
"april", | ||
"may", | ||
"june", | ||
"july", | ||
"august", | ||
"september", | ||
"october", | ||
"november", | ||
"december", | ||
]; | ||
|
||
function getWelcomeTime(hours) { | ||
var welcomeString = ""; | ||
if (5 <= hours && hours < 12) welcomeString = "good morning, "; | ||
else if (12 <= hours && hours < 16) welcomeString = "good afternoon, "; | ||
else if (16 <= hours && hours < 19) welcomeString = "good evening, "; | ||
else welcomeString = "good night, "; | ||
return welcomeString; | ||
} | ||
|
||
function getNumSuffix(num) { | ||
// 1st, 2nd, 3rd, 4th, 5th, | ||
if (num == 1 || num == 21) return "st"; | ||
if (num == 2 || num == 22) return "nd"; | ||
if (num == 3 || num == 23) return "rd"; | ||
else return "th"; | ||
} | ||
|
||
function updateTime() { | ||
var curTime = new Date(); | ||
var hours = curTime.getHours(); | ||
var minutes = curTime.getMinutes(); | ||
if (minutes < 10) { | ||
minutes = "0" + minutes; | ||
} | ||
var day = weekDays[curTime.getDay()]; | ||
var month = months[curTime.getMonth()]; | ||
var dayNum = curTime.getDate(); | ||
|
||
var welcomeString = getWelcomeTime(hours) + firstName + "."; | ||
var clockString = hours + ":" + minutes; | ||
var dateString = day + ", " + month + " " + dayNum + getNumSuffix(dayNum); | ||
|
||
document.getElementById("welcome").innerHTML = welcomeString; | ||
document.getElementById("clock").innerHTML = clockString; | ||
document.getElementById("date").innerHTML = dateString; | ||
} | ||
|
||
setInterval(updateTime, 10); | ||
|
||
//function handleKeyPress(event) { | ||
// if (event.key === 'Enter') { | ||
// performSearch(); | ||
// } | ||
//} | ||
// | ||
//function performSearch() { | ||
// var searchTerm = document.querySelector('input').value; | ||
// if (searchTerm.trim() !== '') { | ||
// if (searchTerm.trim().includes('https://')) { | ||
// window.location.href = searchTerm.trim(); | ||
// } else if ( | ||
// searchTerm.trim().includes('www.') || | ||
// searchTerm.trim().includes('.org') || | ||
// searchTerm.trim().includes('.com') || | ||
// searchTerm.trim().includes('.net') || | ||
// searchTerm.trim().includes('.gov') || | ||
// searchTerm.trim().includes('.edu') || | ||
// searchTerm.trim().includes('.co') || | ||
// searchTerm.trim().includes('.io') | ||
// ) { | ||
// window.location.href = 'https://' + encodeURI(searchTerm.trim()); | ||
// } else if ( | ||
// searchTerm.trim().includes('127.0.0.1') && | ||
// searchTerm.trim().includes('.html') | ||
// ) { | ||
// window.location.href = 'http://' + searchTerm; | ||
// } else { | ||
// // var googleSearchUrl = 'https://www.google.com/search?q=' + encodeURIComponent(searchTerm); | ||
// var duckSearchUrl = 'https://duckduckgo.com/?q=' + encodeURIComponent(searchTerm) | ||
// window.location.href = duckSearchUrl; | ||
// } | ||
// document.querySelector('input').value = ''; | ||
// } | ||
//} | ||
|
||
const search = document.getElementById('search'); | ||
|
||
search.addEventListener('input', function() { | ||
const query = search.value.toLowerCase(); | ||
const allLists = document.querySelectorAll('.links'); | ||
|
||
allLists.forEach(linkList => { | ||
const links = linkList.getElementsByTagName('li'); | ||
|
||
// Loop through the links and show/hide based on the filter | ||
Array.from(links).forEach(link => { | ||
const text = link.textContent || link.innerText; | ||
if (text.toLowerCase().includes(query)) { | ||
link.style.display = ""; // Show the link | ||
} else { | ||
link.style.display = "none"; // Hide the link | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
search.addEventListener('input', resizeInput); | ||
function resizeInput() { | ||
this.style.width = this.value.length + "ch"; | ||
} | ||
|
||
search.addEventListener('keypress', handleKeyPress); | ||
function handleKeyPress(event) { | ||
if (event.key === 'Enter') { | ||
const allLists = document.querySelectorAll('.links'); | ||
let visibleLinks = []; | ||
|
||
allLists.forEach(linkList => { | ||
const links = linkList.getElementsByTagName('li'); | ||
|
||
// Collect visible links | ||
Array.from(links).forEach(link => { | ||
if (link.style.display !== "none") { | ||
visibleLinks.push(link); | ||
} | ||
}); | ||
}); | ||
if (visibleLinks.length === 1) { | ||
const url = visibleLinks[0].querySelector('a').href; // Assuming each li contains an <a> tag | ||
window.location.href = url; // Navigate to the link | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>~/Startpage</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="/style.css"> <!-- fix this --> | ||
<link rel="alternate" type="application/atom+xml" href="/en.atom"> | ||
</head> | ||
<body id="startpage"> | ||
<main> | ||
<div class="search-container"> | ||
<span>> </span> | ||
<input type="text" id="search" placeholder="" autofocus/> | ||
<span class="blinking">_</span> | ||
</div> | ||
<div id="welcome"></div> | ||
<div class="time"> | ||
<span id="clock"></span> | ||
<span id="date"></span> | ||
</div> | ||
|
||
<div class="bookmarks"> | ||
<div class="category"> | ||
<div class="scroll"> | ||
<div class="links"> | ||
<span class="title-uni">uni</span> | ||
<li><a href="https://wattlecourses.anu.edu.au">wattle</a></li> | ||
<li><a href="https://programsandcourses.anu.edu.au/">p and c</a></li> | ||
<li><a href="https://gitlab.cecs.anu.edu.au/">gitlab</a></li> | ||
<li><a href="https://echo360.net.au/courses">echo360</a></li> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="category"> | ||
<div class="scroll"> | ||
<div class="links"> | ||
<span class="title-dev">dev</span> | ||
<li><a href="https://github.com/">github</a></li> | ||
<li><a href="https://wiki.archlinux.org">arch wiki</a></li> | ||
<li><a href="https://hoogle.haskell.org">hoogle</a></li> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="category"> | ||
<div class="scroll"> | ||
<div class="links"> | ||
<span class="title-play">play</span> | ||
<li><a href="https://youtube.com/feed/subscriptions">youtube</a></li> | ||
<li><a href="https://instagram.com/direct">instagram</a></li> | ||
<li><a href="https://last.fm/user/Yimche">last.fm</a></li> | ||
<li><a href="https://www.webtoons.com/en/favorite">webtoons</a></li> | ||
</div> | ||
</div> | ||
</div> | ||
<script src="/meta/scripts/startpage.js"></script> | ||
</main></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters