Created
March 1, 2019 11:06
-
-
Save kostasx/8b4d9714b2073ff6eca429dad5249fb8 to your computer and use it in GitHub Desktop.
EventLoop | HTML Input Elements
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
<table> | |
<thead> | |
<tr> | |
<th colspan="4"><h2>HTML5 Input Types</h2></th> | |
</tr> | |
</thead> | |
<tr> | |
<th>Type</th> | |
<th>Output</th> | |
<th>Copy</th> | |
<th>Code</th> | |
</tr> | |
<!-- type="text" --> | |
<tr> | |
<td><input type="text" /></td> | |
<td> | |
<input type="text" name="username" placeholder="Enter text" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="password" --> | |
<tr> | |
<td><input type="password" /></td> | |
<td> | |
<input type=password name="password"/> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="checkbox" --> | |
<tr> | |
<td><input type="checkbox" /></td> | |
<td> | |
<input checked=true type="checkbox" id="check" /> | |
<label for="check">I Agree:</label> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
<!-- type="radio" --> | |
</tr> | |
<!-- type="radio" --> | |
<tr> | |
<td><input type="radio" /></td> | |
<td> | |
<input type="radio" id="brand" name="brand"/> | |
<label for="brand">Linux</label> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="button" --> | |
<tr> | |
<td><input type="button" /></td> | |
<td> | |
<input type="button" name="send" value="Send" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="submit" --> | |
<tr> | |
<td><input type="submit" /></td> | |
<td> | |
<input type="submit" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="reset" --> | |
<tr> | |
<td><input type="reset" /></td> | |
<td> | |
<input type="reset" value="Reset form" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="file" --> | |
<tr> | |
<td><input type="file" /></td> | |
<td> | |
<input type="file" name="cv" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="hidden" --> | |
<tr> | |
<td><input type="hidden" /></td> | |
<td> | |
<input type="hidden" name="enabled" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="image" --> | |
<tr> | |
<td><input type="image" /></td> | |
<td> | |
<input type="image" width="140px" src="https://stickeroid.com/uploads/pic/full-pngmart/4da657659d41559216e05239d4601e6b21a7f3dd.png"/> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="datetime-local" --> | |
<tr> | |
<td><input type="datetime-local" /></td> | |
<td> | |
<input type="datetime-local" name="booking" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="date" --> | |
<tr> | |
<td><input type="date" /></td> | |
<td> | |
<input type="date" name="arrivale_date" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="month" --> | |
<tr> | |
<td><input type="month" /></td> | |
<td> | |
<input type="month" name="book_month" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="time" --> | |
<tr> | |
<td><input type="time" /></td> | |
<td> | |
<input type="time" name="appointment_time" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="week" --> | |
<tr> | |
<td><input type="week" /></td> | |
<td> | |
<input type="week" name="booking_week" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="number" --> | |
<tr> | |
<td><input type="number" /></td> | |
<td> | |
<input type="number" name="persons" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="range" --> | |
<tr> | |
<td><input type="range" /></td> | |
<td> | |
<label for="range">Volume</label> | |
<input type="range" min="0" max="10" value="5" id="range"/> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="email" --> | |
<tr> | |
<td><input type="email" /></td> | |
<td> | |
<input type="email" placeholder="your@email.here" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="url" --> | |
<tr> | |
<td><input type="url" /></td> | |
<td> | |
<input type="url" name="yoursite" placeholder="Your site URL" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="search" --> | |
<tr> | |
<td><input type="search" /></td> | |
<td> | |
<label for="search">Search site:</label> | |
<input type="search" name="search" id="search" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="tel" --> | |
<tr> | |
<td><input type="tel" /></td> | |
<td> | |
<input type="tel" name="phone" placeholder="Your phone" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<!-- type="color" --> | |
<tr> | |
<td><input type="color" /></td> | |
<td> | |
<input type="color" name="theme" /> | |
</td> | |
<td><button>Copy Code</button></td> | |
<td><textarea name="" rows="2"></textarea></td> | |
</tr> | |
<tfoot> | |
<tr> | |
<td colspan="4">Click on an element in the <strong>Type</strong> Column to be taken to a Reference page for the selected input element</td> | |
</tr> | |
</tfoot> | |
</table> |
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
console.clear(); | |
// Copy Code to Clipboard | |
let clipboard = new ClipboardJS( 'button', { | |
text: function( trigger ) { | |
return trigger.parentElement.previousElementSibling.innerHTML.trim(); | |
} | |
}); | |
clipboard.on('success', function(e) { | |
e.trigger.style.backgroundColor = "limegreen"; | |
e.trigger.textContent = "Copied!"; | |
setTimeout(function(){ | |
e.trigger.style.backgroundColor = "gray"; | |
e.trigger.textContent = "Copy Code"; | |
}, 2000 ); | |
e.clearSelection(); | |
}); | |
document | |
.querySelectorAll("input") | |
.forEach(function($input){ | |
$input.parentElement.nextElementSibling.nextElementSibling.firstChild.value = $input.parentElement.innerHTML.trim(); | |
}); | |
document.querySelectorAll("td:nth-child(1)").forEach(function($td){ | |
$td.addEventListener("click", function(e){ | |
let split = e.target.textContent.match(/type="([a-zA-Z-]+)"/); | |
window.open( "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/"+split[1], "_blank"); | |
}) | |
}) |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script> |
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
body { | |
font-family: Helvetica, Arial, sans-serif; | |
font-size: 0.9em; | |
} | |
thead h2 { | |
margin: 0; | |
} | |
thead th { | |
background: indigo; | |
color: white; | |
} | |
th { | |
background: #dfdfdf; | |
padding: 15px; | |
} | |
table { | |
margin: 0 auto; | |
padding: 15px; | |
} | |
td:nth-child(3), | |
td:nth-child(2), | |
td:nth-child(1) { | |
text-align: center; | |
padding: 2px 8px; | |
} | |
td:nth-child(2){ | |
border-bottom: 1px solid #ddd; | |
} | |
td:nth-child(1){ | |
min-width: 200px; | |
cursor: pointer; | |
transition: all 300ms ease; | |
font-family: courier; | |
font-size: 0.9em; | |
border: none; | |
text-align:center; | |
background: #f2f2f2; | |
} | |
td:nth-child(1):hover{ | |
background: gray; | |
color: white; | |
} | |
button { | |
cursor: pointer; | |
background-color: gray; | |
color: white; | |
border: none; | |
padding: 15px 6px; | |
font-size: 0.9em; | |
width: 80px; | |
} | |
textarea { | |
background: #f0f0f0; | |
font-size: 0.9em; | |
font-family: courier; | |
width: 400px; | |
padding: 10px; | |
border: none; | |
} | |
table tfoot td { | |
padding: 20px !important; | |
background-color: orange !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment