Skip to content

Commit

Permalink
Merge pull request boradesanket13#104 from AaryaaRam/QbyPerson
Browse files Browse the repository at this point in the history
Sort quotes by person feature
  • Loading branch information
boradesanket13 authored Mar 3, 2023
2 parents 51e8e56 + 404c332 commit 66165a9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
<a href="#" onclick="linkClick(4)" id="4">Contact</a>
</div>
<div class="buttons">
<select name="author" id="person" onchange="OnChange()" style="background: rgba(223, 223, 223, 0.446);">
<option value="" disabled selected hidden>Choose Author</option>
<option value="Albert Einstein">Albert Einstein</option>
<option value="Buddha">Buddha</option>
<option value="Confucius">Confucius</option>
<option value="Winston Churchill">Winston Churchill</option>

</select>
<button class="btn-1" >
<a href="signup.html" style="text-decoration:none ;color:black">Sign Up</a>

Expand Down
40 changes: 39 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,42 @@ topic.addEventListener('click', async () => {
tag_cont.innerHTML = adder;


});
});

function OnChange(){
let url = "";
let flag = true;
let pgNum = Math.floor(Math.random() * (4 - 1) + 1);
let picNum = Math.floor(Math.random() * (10 - 0) + 0);

url = `https://api.unsplash.com/search/photos?page=${pgNum}&query=${
queryText[Math.floor(Math.random() * queryText.length)]
}&orientation=landscape`;
resStr = ".results[0].urls.full";
const fetchImages = async () => {
const res = await axios.get(url, {
headers: {
Authorization: "Client-ID CxQIiufAcwII5UXQuqn0dfm8KAFmJLCeKBBVNcidvUs",
},
});
if (flag) {
body.style.backgroundImage = `url('${res.data.results[picNum].urls.full}')`;
} else {
console.log(res.data.urls.full);
body.style.backgroundImage = `url('${res.data.urls.full}')`;
}
};

fetchImages();

var x=document.getElementById("person").value;
const api_url = `https://api.quotable.io/random?author=${x}`;

async function getapi(url) {
const response = await fetch(url);
var quoteData = await response.json();
quote.innerText = quoteData.content;
person.innerText = quoteData.author;
}
getapi(api_url);
}

0 comments on commit 66165a9

Please sign in to comment.