Skip to content

Instantly share code, notes, and snippets.

var x=String(229.123 >> 0);
1+parseInt(x.substring(0,1)) + "00000000000".substring(0,x.length-1)
var day_by_date = function(y, m, d){
return (d+=m<3?y--:y-2,Math.floor(23*m/9)+d+4+Math.floor(y/4)-Math.floor(y/100)+Math.floor(y/400))%7;
};
['sun','mon','tue','wed','thu','fri','sat'][day_by_date(1987, 9, 10)]
from clindsey
var DATE_REGEX = /^(\d{2})-(\d{2})-(\d{4})$/
////////////////////////////////////////////////////////////////////////////////
// //
// validateDate([object|string] oHTMLInputElement) - Validates a date value //
// =============================================== //
// You can pass in the id to an &lt;input> Element, an actual //
// oHTMLInputElement or an actual date value in the form of a string //
// //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// addClassName([object|string] oHTMLElement, string classNameToAdd)
// Adds classNameToAdd to an HTMLElement. Guaranteed not to add the same className twice.
// classNameToAdd can be a space separated list of classNames.
// You can pass in the id to an object or the actual object
//
////////////////////////////////////////////////////////////////////////////////
function addClassName(oHTMLElement, classNameToAdd) {
if (typeof(oHTMLElement)=="string") { oHTMLElement = document.getElementById(oHTMLElement); }
////////////////////////////////////////////////////////////////////////////
// UTILITIES - Section contains general-purpose utilties //
// ========= //
////////////////////////////////////////////////////////////////////////////
utilities : {
savedValueOf : new Object(), // savedValueOf will hold "original" values that we override/restore as needed
disableTextSelection : function() {
switch (true) {
case ( typeof document.onselectstart!="undefined" ) : // IE
this.savedValueOf["onselectstart"] = document.onselectstart;
////////////////////////////////////////////////////////////////////////////////
//
// showOrHide([object|string] oHTMLElement, boolean bShowOrHide)
// Shows or Hides an HTMLElement.
// You can pass in the id to an object or the actual object
//
////////////////////////////////////////////////////////////////////////////////
function showOrHide(oHTMLElement, bShowOrHide) {
try {
if (typeof(oHTMLElement)=="string") {
////////////////////////////////////////////////////////////////////////////////
// EnsureMinimumNumberOfRows(element, params) - ensures a table will have a minimum
// ========================================== number of visible rows.
// Supported params are:
// numberOfRows - gives the minimum number of rows that will appear
// rowHeight - height, in pixels for added rows
// *NOTE: Does not support empty tables
////////////////////////////////////////////////////////////////////////////////
function EnsureMinimumNumberOfRows(element, params) {
var minimumNumberOfRows = params.numberOfRows || 10, // default minimumNumberOfRows is 10
////////////////////////////////////////////////////////////////////////////////
// EnsureMinimumNumberOfRows(element, params) - ensures a table will have a minimum
// ========================================== number of visible rows.
// Supported params are:
// numberOfRows - gives the minimum number of rows that will appear
// rowHeight - height, in pixels for added rows
// *NOTE: Does not support empty tables
////////////////////////////////////////////////////////////////////////////////
function EnsureMinimumNumberOfRows(element, params) {
var minimumNumberOfRows = params.numberOfRows || 10, // default minimumNumberOfRows is 10