Skip to content

Instantly share code, notes, and snippets.

View Octagon-simon's full-sized avatar
Turning red flags into red tests that pass.

Simon Ugorji (Octagon) Octagon-simon

Turning red flags into red tests that pass.
View GitHub Profile
//store table data element
const tableDataElem = document.querySelector('#append_data');
//function to build table
function buildTable(matchingIDs){
//reset table data
tableDataElem.innerHTML = "";
//check if parameter is provided
if(typeof matchingIDs === "undefined"){
//our loop index
let ind = 0;
//our table's data
const tableData = {
1 : ["Simon ugorji", "simon@gmail.com", "01234", "Germany"],
2 : ["Tony ugorji", "tony@gmail.com", "013234", "Turkey"],
3 : ["Victor ugorji", "victor@gmail.com", "014234", "Germany"],
4 : ["Felix ugorji", "felix@gmail.com", "011234", "Canada"],
5 : ["Jordan ugorji", "jordan@gmail.com", "016234", "Costa Rica"],
6 : ["Henry ugorji", "henry@gmail.com", "0166234", "Belgium"],
7 : ["Frank Sams", "simon@gmail.com", "01234", "Nigeria"],
8 : ["John Doe", "jonny@gmail.com", "0123466", "Australia"],
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
html{
font-family: "Roboto", sans-serif;
width:100%;
}
const userQuery = {
uname : "Simon",
pass : "OctaHenryX6D"
}
//store url
let url = doQuery('http://mywebsite.com/check-record', userQuery);
//send to the browser
window.location.href=url;
function doQuery(url, userQuery){
//construct a new url
let res = new URL(url);
//check if userquery contians properties
if(Object.keys(userQuery).length !== 0){
//loop through object
let ind = 0;
while (ind < Object.keys(userQuery).length){
//get the parameter
const param = Object.keys(userQuery)[ind];
<div class="form-group">
<label>Password</label>
<input octavalidate="R,PASS" ov-required:msg="Your password is required" id="inp_pwd" type="password" placeholder="Your Password">
</div>
<div class="form-group">
<label>Re-enter Password</label>
<input octavalidate="R" equalto="inp_pwd" ov-required:msg="Please re-enter your password"
ov-eqaulto:msg="Both passwords do not match" id="inp_pwd2" type="password" placeholder="Re-enter your Password">
</div>
<form class="form" id="form_register" method="post">
<div class="form-group">
<label>Username</label>
<input id="inp_uname" type="text" octavalidate="R,USERNAME" ov-required:msg="Your username is required" placeholder="Your Username">
</div>
<div class="form-group">
<label>Email</label>
<input id="inp_email" type="email" octavalidate="R,EMAIL" ov-required:msg="Your email address is required" placeholder="Your Email Address">
</div>
<div class="form-group">
//create new instance of the object
let watch = new StopWatch();
//start the watch
watch.start();
//stop the watch after 5 seconds
watch.stop();
//caculate duration
console.log(watch.duration());
function StopWatch(){
let isStart = false; //start the watch
let startCount = 0; //record time started
let stopCount = 0; //record time stopped
let durationCount = 0; //calculate duration
let preDuration = 0; //calculate previous duration
//start method
this.start = function(){
//check if watch is started
if(isStart === true){
function StopWatch(){
this.reset = function(){
durationCount = startCount = stopCount = preDuration = 0;
isStart = false;
return true;
}
}