Skip to content

Instantly share code, notes, and snippets.

@miwebguy
miwebguy / javascriptfilter
Created March 18, 2025 15:11
concept: Javascript filter with querystring
<html>
<head>
<script>
//<![CDATA[
//Not Tested for Accessiblity
/**
* List Filter
* @usage: <input type="search" onkeyup="Listfilter(this,'_id')" />
* where _id is the id of the list container
*/
@miwebguy
miwebguy / datalistcheck.html
Last active September 17, 2024 19:10
Datalist Check final value against list optoins
<html>
<head>
<script>
function peopleCheck(el)
{
var options = el.list.options;
for (var i = 0; i< options.length; i++) {
if (el.value == options[i].value)
//option matches: work is done
return;
@miwebguy
miwebguy / CSSImageRotations.html
Created June 17, 2024 19:03
CSS Image Rotations
<style>
.fadein {position:relative;height:300px;width:450px}
@keyframes fade { 0% {opacity:0} 11.11% {opacity:1} 33.33% {opacity:1} 44.44% {opacity:0} 100% {opacity:0}}
.fadein img {position:absolute;left:0;right:0;opacity:0;animation-name:fade;animation-duration:18s;animation-iteration-count:infinite}
.fadein img:nth-child(1) {animation-delay:0s}
.fadein img:nth-child(2) {animation-delay:3s}
.fadein img:nth-child(3) {animation-delay:6s}
.fadein img:nth-child(4) {animation-delay:9s}
</style>
<div class='fadein'>
@miwebguy
miwebguy / validinputfromdatalist.html
Last active March 25, 2024 16:15
Only allow valid data from html datalist
//https://stackoverflow.com/questions/30499199/html5-datalist-to-select-only-predefined-options
<script>
function peopleCheck(el)
{
// nothing is done if no value selected - allow empty
if (el.value == "") return;
var options = el.list.options;
for (var i = 0; i< options.length; i++) {
if (el.value == options[i].value)
@miwebguy
miwebguy / OutlookExternalEmailAddress.txt
Last active March 11, 2024 15:31
Show External Email Address in Outlook
To add a full-email field:
Click View > Add Columns
In the Show Columns dialog do the following:
Click New Column button
In the New Column dialog specify a name for the new column
@miwebguy
miwebguy / N2.js
Last active February 16, 2024 19:59
Vanilla JS Notify (toast)
class N2 {
// based on Rick Hopkins MooTools Notify
//<button onclick="n2 = new N2({title:'My Title',content:'My body'})">My N2 Notify</button>
//<button onclick="n2 = new N2({text:'MyCombined Title::My combined body',classes:['inlineNotice']})">My N2 text Notify</button>
//<button onclick="n2 = new N2({text:'MyCombined Title::My combined body',classes:['notify-warn']})">My N2 text Warn</button>
//<button onclick="n2 = new N2({text:'MyCombined Title::My combined body',classes:['notify-alert']})">My N2 text Alert</button>
constructor (opts) {
@miwebguy
miwebguy / consentx.js
Last active February 15, 2024 19:20
ConsentX Cookie Consent Banner
class ConsentX {
// based on Creare's 'Implied Consent' EU Cookie Law Banner v:2.4
// Conceived by Robert Kent, James Bavington & Tom Foyster
constructor () {
this.dropCookie = true; // false disables the cookie, allowing you to style the banner
this.cookieDuration = 14; // days before the cookie expires, and the banner reappears
this.cookieName = 'complianceCookie'; // name of our cookie
this.cookieValue = 'on'; // initial value of cookie
@miwebguy
miwebguy / qf2.js
Last active February 15, 2024 19:21
Vanilla JS QuickForm
class QF2 {
// based on MooTools QuickForm, created by Rick Hopkins
//<button onclick="QF = new QF2({title:'This is a Title',content:'Hello'});">QF Content</button>
//<button onclick="QF = new QF2({title:'This is a Title',url:'https://testing0.micore.us/qf2/form.html'});">QF Url</button>
//<button onclick="QF = new QF2({title:'This is a Title',url:'https://testing0.micore.us/qf2/form.html',data:{key:'value'}});">QF Url with Post Data</button>
constructor (opts) {
// clear all previously made QuickForms
var qf = document.querySelector('.quickform');
@miwebguy
miwebguy / jshtmltoword.html
Last active December 26, 2023 19:05
JStoDoc (no Images)
https://stackoverflow.com/questions/63460485/exporting-html-to-word
<script>
//<![CDATA[
function Export2Doc(element, filename = ''){
var preHtml = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head> <meta charset='utf-8'><title>Export HTML To Doc</title></head><body>";
var postHtml = "</body></html>";
var html = preHtml+document.getElementById(element).innerHTML+postHtml;
var blob = new Blob(['\ufeff', html], {
type: 'application/msword'
@miwebguy
miwebguy / phoneformat.html
Created December 26, 2023 19:02
Phone Number Formatting
<p>https://stackoverflow.com/questions/30058927/format-a-phone-number-as-a-user-types-using-pure-javascript</p>
<input id="phoneNumber" placeholder="Phone Number" maxlength="16" />
<script>
isNumericInput = (event) => {
const key = event.keyCode;
return ((key >= 48 && key <= 57) || // Allow number line
(key >= 96 && key <= 105) // Allow number pad