-
-
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
Showing
11 changed files
with
263 additions
and
37 deletions.
There are no files selected for viewing
Binary file not shown.
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,10 @@ | ||
{ | ||
"ExpandedNodes": [ | ||
"", | ||
"\\projects", | ||
"\\_includes", | ||
"\\_includes\\layouts" | ||
], | ||
"SelectedNode": "\\index.njk", | ||
"PreviewInSolutionExplorer": false | ||
} |
Binary file not shown.
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,46 @@ | ||
// Index | ||
// LIVE ON WEBSITE | ||
// 1. Tip Calculate | ||
// 2. Form Validation | ||
// 3. Simple form | ||
// 4. Simple calculator 1 | ||
// 5. Countdown Timer | ||
|
||
//1. Tip Calculate starts here | ||
function calculateTip() { | ||
var billAmt = document.getElementById("billamt").value; | ||
var serviceQual = document.getElementById("serviceQual").value; | ||
var numOfPeople = document.getElementById("peopleamt").value; | ||
//validate input | ||
if (billAmt === "" || serviceQual == 0) { | ||
alert("Please enter values"); | ||
return; | ||
} | ||
//Check to see if this input is empty or less than or equal to 1 | ||
if (numOfPeople === "" || numOfPeople <= 1) { | ||
numOfPeople = 1; | ||
document.getElementById("each").style.display = "none"; | ||
} else { | ||
document.getElementById("each").style.display = "block"; | ||
} | ||
//Calculate tip | ||
var total = (billAmt * serviceQual) / numOfPeople; | ||
//round to two decimal places | ||
total = Math.round(total * 100) / 100; | ||
//next line allows us to always have two digits after decimal point | ||
total = total.toFixed(2); | ||
//Display the tip | ||
document.getElementById("totalTip").style.display = "block"; | ||
document.getElementById("tip").innerHTML = total; | ||
|
||
} | ||
//Hide the tip amount on load | ||
document.getElementById("totalTip").style.display = "none"; | ||
document.getElementById("each").style.display = "none"; | ||
//click to call function | ||
document.getElementById("calculate").onclick = function () { | ||
calculateTip(); | ||
}; | ||
// Tip Calculate ends here | ||
|
||
// --------------------------------------------------------------------------------------- |
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,49 @@ | ||
--- | ||
layout: layouts/home.njk | ||
title: Projects | ||
templateClass: tmpl-post | ||
eleventyNavigation: | ||
key: Projects | ||
order: 2 | ||
--- | ||
<!-- JavaScript Projects starts here --> | ||
<div class="text-center"> | ||
<h1>JavaScript Projects</h1> | ||
<hr> | ||
</div> | ||
<div class="row"> | ||
<!-- Tip Calculator Starts here --> | ||
<div class="col-lg-4"> | ||
<form class="form-control form-signin"> | ||
<h2>Tip Calculator</h2> | ||
<p>Enter your bill amount and select the percentage of tip you would like to give. If there is only one person paying, you can either leave the number of people blank or enter 1.</p> | ||
<hr> | ||
<label>Bill amount<br> | ||
<span>£ </span><input id="billamt" type="text" placeholder="Bill amount"> | ||
</label> | ||
<label>How much tip would you like to give?<br> | ||
<select id="serviceQual"> | ||
<option disabled selected value="0">Choose an percentage</option> | ||
<option value="0.05">5%</option> | ||
<option value="0.1">10%</option> | ||
<option value="0.15">15%</option> | ||
<option value="0.3">30%</option> | ||
<option value="0.4">40%</option> | ||
<option value="0.5">50%</option> | ||
</select> | ||
</label> | ||
<label>How many people are sharing the bill? | ||
<input id="peopleamt" type="text" placeholder="Number of People"> | ||
</label> | ||
<button class="btn" type="button" id="calculate">Calculate!</button> | ||
<!--calculator end--> | ||
<div id="totalTip"> | ||
<h5 id="each">You will each pay a tip of:</h5> | ||
<h2><sup>£</sup><span id="tip">0.00</span> </h2> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<!-- Tip Calculator Ends here --> | ||
<!-- JavaScript Projects ends here --> | ||
<script src="/js/projects.js"></script> |