Skip to content

Instantly share code, notes, and snippets.

View MarkMYoung's full-sized avatar

Mark M. Young MarkMYoung

View GitHub Profile
@MarkMYoung
MarkMYoung / printDiv.js
Created December 29, 2020 22:29
Print a target `div` of a web page.
function printDiv( divId )
{
let divContents = document.getElementById( divId ).innerHTML;
let printWindow = window.open( '', '', 'height=200,width=400' );
printWindow.document.write( '<html><head><title>Print DIV Content</title></head><body>' );
printWindow.document.write( divContents );
printWindow.document.write( '</body></html>' );
printWindow.document.close();
printWindow.print();
}
@MarkMYoung
MarkMYoung / dots-fill.css
Created March 10, 2020 21:12
Fill empty (form) space with dots (for visual alignment).
/*
* @example
* <div class="dots-fill">
* <label class="dots-after"></label>
* </div>
* @see https://stackoverflow.com/a/5476886/1757334
*/
.dots-fill
{
overflow:hidden;
@MarkMYoung
MarkMYoung / RegExpToolbox.js
Created September 26, 2019 16:40
Regular Expression Toolbox: Monetary Number Pattern (Up to 2 Decimal Places)
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
let RegExpToolbox =
{
// This regular expression which matches only numbers with up to two decimal
// places, and allowing a preceding decimal (without a zero)
// but not a trailing decimal.
monetaryNumberRegExp:new RegExp( "^(\\d+(?:[\\.]\\d{1,2})?|(?:\\d+)?(?:[\\.]\\d{1,2}))$" ),
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//