Skip to content

Commit

Permalink
added dark mode in the application
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravWalia19 committed May 3, 2020
1 parent c1948b7 commit f0de45e
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 113 deletions.
102 changes: 70 additions & 32 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Treasure JS Available Apis</title>
<link rel="icon" href="treasureapi.png"/>
<link rel="stylesheet" href="styles/index.css"/>
<link rel="icon" href="treasureapi.png" />
<link rel="stylesheet" href="styles/index.css" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
<script src="scripts/index.js" defer></script>
<!-- FONT AWESOME -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
</head>

<body>
<!-- HEADER -->
<header>
Expand All @@ -29,17 +35,28 @@
<a href="#v2_search_github" class="fifth greenNav">/api/v2/search/github</a>
</div>
<div>
<img src="treasureapi.png" />
<div>
<i class="fas fa-8x fa-meteor" id="modeButton"></i>
</div>
<div id="meteorBack"></div>
<h1 id="header-h1">Treasure APIs</h1>
</div>
</header>

<!-- NAVIGATION BUTTON -->
<div>
<button" id="navButton" title="click here to go top">
<i class="fab fa-2x fa-autoprefixer"></i>
</button>
</div>


<!-- version1 section -->
<section>
<h2>APIs Version 1 Endpoints</h2>
<div class="endpoint-div" id="v1_search">
<h3>/api/v1/search</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v1/search?
<span class="green">find=as</span>&<span class="green">size=1</span>
</span>
Expand All @@ -53,10 +70,10 @@ <h4>Query Parameters</h4>
</ul>
</div>
</div>

<div class="endpoint-div" id="v1_search_description">
<h3>/api/v1/search/description</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v1/search/description?
<span class="green">find=as</span>&<span class="green">size=1</span>
</span>
Expand All @@ -70,10 +87,10 @@ <h4>Query Parameters</h4>
</ul>
</div>
</div>

<div class="endpoint-div" id="v1_search_docs">
<h3>/api/v1/search/docs</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v1/search/docs?
<span class="green">find=as</span>&<span class="green">size=1</span>
</span>
Expand All @@ -87,10 +104,10 @@ <h4>Query Parameters</h4>
</ul>
</div>
</div>

<div class="endpoint-div" id="v1_search_website">
<h3>/api/v1/search/website</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v1/search/website?
<span class="green">find=as</span>&<span class="green">size=1</span>
</span>
Expand All @@ -104,10 +121,10 @@ <h4>Query Parameters</h4>
</ul>
</div>
</div>

<div class="endpoint-div" id="v1_search_github">
<h3>/api/v1/search/github</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v1/search/github?
<span class="green">find=as</span>&<span class="green">size=1</span>
</span>
Expand All @@ -121,10 +138,10 @@ <h4>Query Parameters</h4>
</ul>
</div>
</div>

<div class="endpoint-div" id="v1_search_other">
<h3>/api/v1/search/other</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v1/search/other?
<span class="green">find=as</span>&<span class="green">size=1</span>
</span>
Expand All @@ -140,17 +157,18 @@ <h4>Query Parameters</h4>
</div>
</section>

<hr class="horizontalRule"/>
<hr class="horizontalRule" />

<!-- version2 section -->
<section>
<h2>APIs Version 2 Endpoints</h2>

<div class="endpoint-div" id="v2_search">
<h3>/api/v2/search</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v2/search?
<span class="green">find=as</span>&<span class="green">size=1</span>&<span class="green">exact=false</span>&<span class="green">projection=["name"]</span>
<span class="green">find=as</span>&<span class="green">size=1</span>&<span
class="green">exact=false</span>&<span class="green">projection=["name"]</span>
</span>
</p>
<p> this api will check the name from the start</p>
Expand All @@ -160,16 +178,20 @@ <h4>Query Parameters</h4>
<li>find - string to search</li>
<li>size - We can restrict the response size using this</li>
<li>exact - We can use exact boolean flag to get exact match response</li>
<li>projection - We can restrict the values we need from the API response. You can see the values you can use with projection to work <a href="#projectionList">here</a>.</li>
<li>projection - We can restrict the values we need from the API response. You can see the
values
you can use with projection to work <a href="#projectionList" class="projectionLink">here</a>.
</li>
</ul>
</div>
</div>

<div class="endpoint-div" id="v2_search_description">
<h3>/api/v2/search/description</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v2/search/description?
<span class="green">find=as</span>&<span class="green">size=1</span>&<span class="green">exact=false</span>&<span class="green">projection=["name"]</span>
<span class="green">find=as</span>&<span class="green">size=1</span>&<span
class="green">exact=false</span>&<span class="green">projection=["name"]</span>
</span>
</p>
<p> this api will search the description of the libraries</p>
Expand All @@ -179,16 +201,20 @@ <h4>Query Parameters</h4>
<li>find - string to search</li>
<li>size - We can restrict the response size using this</li>
<li>exact - We can use exact boolean flag to get exact match response</li>
<li>projection - We can restrict the values we need from the API response. You can see the values you can use with projection to work <a href="#projectionList">here</a>.</li>
<li>projection - We can restrict the values we need from the API response. You can see the
values
you can use with projection to work <a href="#projectionList" class="projectionLink">here</a>.
</li>
</ul>
</div>
</div>

<div class="endpoint-div" id="v2_search_docs">
<h3>/api/v2/search/docs</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v2/search/docs?
<span class="green">find=as</span>&<span class="green">size=1</span>&<span class="green">exact=false</span>&<span class="green">projection=["name"]</span>
<span class="green">find=as</span>&<span class="green">size=1</span>&<span
class="green">exact=false</span>&<span class="green">projection=["name"]</span>
</span>
</p>
<p> this api will search the docs of the libraries</p>
Expand All @@ -198,16 +224,20 @@ <h4>Query Parameters</h4>
<li>find - string to search</li>
<li>size - We can restrict the response size using this</li>
<li>exact - We can use exact boolean flag to get exact match response</li>
<li>projection - We can restrict the values we need from the API response. You can see the values you can use with projection to work <a href="#projectionList">here</a>.</li>
<li>projection - We can restrict the values we need from the API response. You can see the
values
you can use with projection to work <a href="#projectionList" class="projectionLink">here</a>.
</li>
</ul>
</div>
</div>

<div class="endpoint-div" id="v2_search_website">
<h3>/api/v2/search/website</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v2/search/website?
<span class="green">find=as</span>&<span class="green">size=1</span>&<span class="green">exact=false</span>&<span class="green">projection=["name"]</span>
<span class="green">find=as</span>&<span class="green">size=1</span>&<span
class="green">exact=false</span>&<span class="green">projection=["name"]</span>
</span>
</p>
<p> this api will search the website of the libraries</p>
Expand All @@ -217,16 +247,20 @@ <h4>Query Parameters</h4>
<li>find - string to search</li>
<li>size - We can restrict the response size using this</li>
<li>exact - We can use exact boolean flag to get exact match response</li>
<li>projection - We can restrict the values we need from the API response. You can see the values you can use with projection to work <a href="#projectionList">here</a>.</li>
<li>projection - We can restrict the values we need from the API response. You can see the
values
you can use with projection to work <a href="#projectionList" class="projectionLink">here</a>.
</li>
</ul>
</div>
</div>

<div class="endpoint-div" id="v2_search_github">
<h3>/api/v2/search/github</h3>
<p>API URL:
<p>API URL:
<span class="blue">https://treasurejsapi.herokuapp.com/api/v2/search/github?
<span class="green">find=as</span>&<span class="green">size=1</span>&<span class="green">exact=false</span>&<span class="green">projection=["name"]</span>
<span class="green">find=as</span>&<span class="green">size=1</span>&<span
class="green">exact=false</span>&<span class="green">projection=["name"]</span>
</span>
</p>
<p> this api will search the github of the libraries</p>
Expand All @@ -236,7 +270,10 @@ <h4>Query Parameters</h4>
<li>find - string to search</li>
<li>size - We can restrict the response size using this</li>
<li>exact - We can use exact boolean flag to get exact match response</li>
<li>projection - We can restrict the values we need from the API response. You can see the values you can use with projection to work <a href="#projectionList">here</a>.</li>
<li>projection - We can restrict the values we need from the API response. You can see the
values
you can use with projection to work <a href="#projectionList" class="projectionLink">here</a>.
</li>
</ul>
</div>
</div>
Expand All @@ -262,4 +299,5 @@ <h3>Projection Values</h3>
&copy; TechOUs &copy; TreasureAPIs 2020
</footer>
</body>

</html>
104 changes: 104 additions & 0 deletions public/scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
let modeButton = document.getElementById('modeButton');
let modeFlag = false;
const PINK = "#f89494";
const YELLOW = "#ecd501";
const lightBlack = "rgb(41, 43, 44)";
const darkBlack = "rgb(18, 18, 18)";

modeButton.addEventListener('click', () => {
if (modeFlag == false) {
modeFlag = true;
enableDarkMode();
} else {
modeFlag = false;
enableLightMode();
}
})

//Get the button
let navButton = document.getElementById("navButton");
navButton.addEventListener('click' , ()=>{
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
})

handleNavigationButton()

// When the user scrolls down 80px from the top of the document, show the button
window.onscroll = ()=> {
handleNavigationButton();
};

function handleNavigationButton(){
if (document.body.scrollTop > 150 || document.documentElement.scrollTop > 150) {
navButton.style.display = "block";
} else {
navButton.style.display = "none";
}
}

function enableDarkMode() {
modeButton.style.color = YELLOW;
let body = document.getElementsByTagName('body')[0];
body.style.color = "white";
body.style.backgroundColor = darkBlack;
document.getElementById('meteorBack').style.backgroundColor = PINK;

let endpointsDiv = document.getElementsByClassName('endpoint-div');
for (let i = 0; i < endpointsDiv.length; i++) {
endpointsDiv[i].style.backgroundColor = lightBlack;
}

let blues = document.getElementsByClassName('blue');
for (let i = 0; i < blues.length; i++) {
blues[i].style.color = "cyan";
}

let greens = document.getElementsByClassName('green');
for (let i = 0; i < greens.length; i++) {
greens[i].style.color = "lightgreen";
}

let projectionLink = document.getElementsByClassName('projectionLink');
for (let i = 0; i < projectionLink.length; i++) {
projectionLink[i].style.color = "cyan";
}

let footer = document.getElementsByTagName('footer')[0];
footer.style.backgroundColor = lightBlack;

navButton.style.backgroundColor = lightBlack;
}

function enableLightMode() {
modeButton.style.color = PINK;
let body = document.getElementsByTagName('body')[0];
body.style.color = "black";
body.style.backgroundColor = "white";
document.getElementById('meteorBack').style.backgroundColor = YELLOW;

let endpointsDiv = document.getElementsByClassName('endpoint-div');
for (let i = 0; i < endpointsDiv.length; i++) {
endpointsDiv[i].style.backgroundColor = "white";
}

let blues = document.getElementsByClassName('blue');
for (let i = 0; i < blues.length; i++) {
blues[i].style.color = "blue";
}

let greens = document.getElementsByClassName('green');
for (let i = 0; i < greens.length; i++) {
greens[i].style.color = "green";
}

let projectionLink = document.getElementsByClassName('projectionLink');
for (let i = 0; i < projectionLink.length; i++) {
projectionLink[i].style.color = "blue";
}

let footer = document.getElementsByTagName('footer')[0];
footer.style.backgroundColor = PINK;

navButton.style.backgroundColor = PINK;
}
Loading

0 comments on commit f0de45e

Please sign in to comment.