HTML Samples
Checkpoint
Source code:
<!DOCTYPE html>
<html>
<head>
<title>Checkpoint</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat">
<style>
body {
margin: 0;
min-width: 250px;
font-family: Montserrat, sans-serif;
}
* {
box-sizing: border-box;
}
/* The list */
ul {
margin: 0;
padding: 0;
}
ul li {
cursor: pointer;
position: relative;
padding: 12px 8px 12px 40px;
list-style-type: none;
background: white;
font-family: Montserrat, sans-serif;
font-size: 18px;
transition: 0.2s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
ul li:hover {
background: #ddd;
}
ul li.checked {
background: #888;
color: #fff;
text-decoration: line-through;
}
ul li.checked::before {
content: '';
position: absolute;
border-color: #fff;
border-style: solid;
border-width: 0 2px 2px 0;
top: 10px;
left: 16px;
transform: rotate(45deg);
height: 15px;
width: 7px;
}
.close {
position: absolute;
right: 0;
top: 0;
padding: 12px 16px 12px 16px;
}
.close:hover {
background-color: lightgray;
color: white;
}
/* Header */
.header {
background-image: linear-gradient(to bottom right, orange, red);
padding: 30px 40px;
color: white;
text-align: center;
}
.header:after {
content: "";
display: table;
clear: both;
}
/* Input */
input {
margin: 0;
border: none;
border-radius: 20px 0px 0px 20px;
width: 80%;
background: rgba(255, 255, 255, 0.75);
backdrop-filter: blur(16px) saturate(180%);
-webkit-backdrop-filter: blur(16px) saturate(180%);
padding: 10px 10px 10px 20px;
float: left;
font-size: 16px;
font-family: Montserrat, sans-serif;
}
input[type=text]:focus {
background-color: lightgray;
outline: none;
}
/* Add button */
.addBtn {
padding: 10px;
width: 20%;
background: white;
color: #555;
float: left;
text-align: center;
font-size: 16px;
cursor: pointer;
transition: 0.3s;
border-radius: 0px 20px 20px 0px;
}
.addBtn:hover {
background-color: lightgray;
}
</style>
</head>
<body>
<div id="myDIV" class="header">
<h1 style="margin:5px">Checkpoint</h1>
<h6 style="margin:5px">A project by <a href="https://www.trevormcfadden.com">Trevor McFadden</a></h6>
<br>
<input type="text" id="myInput" placeholder="What would you like to add?">
<span onclick="newElement()" class="addBtn">+</span>
</div>
<ul id="myUL">
</ul>
<script>
var myNodelist = document.getElementsByTagName("LI");
var i;
for (i = 0; i < myNodelist.length; i++) {
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
myNodelist[i].appendChild(span);
}
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
var div = this.parentElement;
div.style.display = "none";
}
}
var list = document.querySelector('ul');
list.addEventListener('click', function(ev) {
if (ev.target.tagName === 'LI') {
ev.target.classList.toggle('checked');
}
}, false);
function newElement() {
var li = document.createElement("li");
var inputValue = document.getElementById("myInput").value;
var t = document.createTextNode(inputValue);
li.appendChild(t);
if (inputValue === '') {
alert("The textbox cannot be empty. Please try again.");
} else {
document.getElementById("myUL").appendChild(li);
}
document.getElementById("myInput").value = "";
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
li.appendChild(span);
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
var div = this.parentElement;
div.style.display = "none";
}
}
}
</script>
</body>
</html>
Smarticalc
Source code:
<!DOCTYPE html>
<html>
<head>
<title>Smarticalc</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat">
<!-- The CSS for Smarticalc -->
<style>
html {
box-sizing: border-box;
}
body {
margin: 0;
min-width: 250px;
font-family: Montserrat, sans-serif;
text-align: center;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
body {
margin: 0;
}
embed,
iframe,
img,
object,
video {
max-width: 100%;
}
body {
align-items: center;
background-color: white;
display: flex;
height: 100vh;
}
.container {
max-width: 40em;
}
.container > p {
text-align: center;
}
.calculator {
border-radius: 20px;
background: white;
height: 510px;
box-shadow: 0 0 40px 0px rgba(0, 0, 0, 0.15);
margin-left: auto;
margin-right: auto;
margin-top: 0em;
max-width: 40em;
overflow: auto;
padding: 20px 20px;
}
#btn {
height: 40px;
width: 40px
font-family: Verdana, sans-serif;
font-size: 12px;
}
input[type="button"] {
background-color:white;
color: black;
border: none;
padding: 10px 10px;
border-radius: 20px;
height: 40px;
width: 40px
}
input[type="button"]:hover {
background-color: #d3d3d3;
}
input[type="text"] {
background-color: #d3d3d3;
color: white;
border: none;
padding: 10px 10px;
border-radius: 20px;
width:100%
}
#equals {
background-color: orange;
color: black;
border: none;
padding: 10px 10px;
border-radius: 20px;
height: 40px;
width: 40px;
font-family: Verdana, sans-serif;
font-size: 12px;
width:100%
}
#equals:hover {
background-color: #cc8500;
}
</style>
</head>
<!-- The HTML for Smarticalc -->
<body>
<div class = "calculator">
<br>
<h1>Smarticalc</h1>
<h6 style="margin:5px">A project by <a href="https://www.trevormcfadden.com">Trevor McFadden</a></h6>
<br>
<form name = "calc">
<table id = "calc" border = 0>
<tr>
<td colspan=6><input id="btn" name="display" onkeypress="return event.charCode>= 48 && event.charCode <= 57" type="text"></td>
</tr>
<tr>
<td><input id="btn" type="button" value="1" OnClick="calc.display.value+='1'"></td>
<td><input id="btn" type="button" value="2" OnClick="calc.display.value+='2'"></td>
<td><input id="btn" type="button" value="3" OnClick="calc.display.value+='3'"></td>
<td><input id="btn" type="button" value="C" OnClick="calc.display.value=''"></td>
<td><input id="btn" type="button" value="↩" OnClick="backspace(this.form)"></td>
<td><input id="btn" type="button" value="√" OnClick="calc.display.value+='Math.sqrt('"></td>
</tr>
<tr>
<td><input id="btn" type="button" value="4" OnClick="calc.display.value+='4'"></td>
<td><input id="btn" type="button" value="5" OnClick="calc.display.value+='5'"></td>
<td><input id="btn" type="button" value="6" OnClick="calc.display.value+='6'"></td>
<td><input id="btn" type="button" value="-" OnClick="calc.display.value='-'"></td>
<td><input id="btn" type="button" value="%" OnClick="calc.display.value+='%'"></td>
<td><input id="btn" type="button" value="cos" OnClick="calc.display.value='Math.cos('"></td>
</tr>
<tr>
<td><input id="btn" type="button" value="7" OnClick="calc.display.value+='7'"></td>
<td><input id="btn" type="button" value="8" OnClick="calc.display.value+='8'"></td>
<td><input id="btn" type="button" value="9" OnClick="calc.display.value+='9'"></td>
<td><input id="btn" type="button" value="⨉" OnClick="calc.display.value+='*'"></td>
<td><input id="btn" type="button" value="n!" OnClick="calc.display.value+='!'"></td>
<td><input id="btn" type="button" value="sin" OnClick="calc.display.value='Math.sin('"></td>
</tr>
<tr>
<td><input id="btn" type="button" value="." OnClick="calc.display.value+='.'"></td>
<td><input id="btn" type="button" value="0" OnClick="calc.display.value+='0'"></td>
<td><input id="btn" type="button" value="," OnClick="calc.display.value+=','"></td>
<td><input id="btn" type="button" value="+" OnClick="calc.display.value+='+'"></td>
<td><input id="btn" type="button" value="/" OnClick="calc.display.value+='/'"></td>
<td><input id="btn" type="button" value="tan" OnClick="calc.display.value='Math.tan('"></td>
</tr>
<tr>
<td><input id="btn" type="button" value="E" OnClick="calc.display.value+='Math.E'"></td>
<td><input id="btn" type="button" value="𝝅" OnClick="calc.display.value+='Math.PI'"></td>
<td><input id="btn" type="button" value="^" OnClick="calc.display.value+='Math.pow('"></td>
<td><input id="btn" type="button" value="(" OnClick="calc.display.value+='('"></td>
<td><input id="btn" type="button" value=")" OnClick="calc.display.value+=')'"></td>
<td><input id="btn" type="button" value="log" OnClick="calc.display.value='Math.log('"></td>
</tr>
<tr>
<td><input id="btn" type="button" value="ln2" OnClick="calc.display.value+='Math.LN2'"></td>
<td><input id="btn" type="button" value="ln10" OnClick="calc.display.value+='Math.Log10'"></td>
<td><input id="btn" type="button" value="l2e" OnClick="calc.display.value+='Math.LOG2E'"></td>
<td><input id="btn" type="button" value="l10e" OnClick="calc.display.value+='Math.log10'"></td>
<td><input id="btn" type="button" value="exp" OnClick="calc.display.value='Math.exp('"></td>
<td><input id="equals" type="button" value="=" OnClick="calculate(this.form)"></td>
</tr>
</table>
</form>
<br>
</div>
</body>
<!-- The JavaScript for Smarticalc -->
<script>
function backspace(calc) {
size = calc.display.value.length;
calc.display.value = calc.display.value.substring(0, size-1);
}
function calculate(calc) {
if(calc.display.value.includes("!")) {
size = calc.display.value.length;
n = Number(calc.display.value.substring(0, size-1));
f = 1;
for(i = 2; i <= n; i++)
f = f*i;
calc.display.value = f;
}
else if(calc.display.value.includes("%")) {
size = calc.display.value.length;
n = Number(calc.display.value.substring(0, size-1));
calc.display.value = n/100;
}
else
calc.display.value = eval(calc.display.value);
}
</script>
</html>
<!--Final comment: Jesus loves you. If you want to spend eternity with Him, just trust in Him. That's all for now, God bless. -->