View phoneField_1.js
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
var filter = []; | |
//since we're looking for phone numbers, we need | |
//to allow digits 0 - 9 (they can come from either | |
//the numeric keys or the numpad) | |
const keypadZero = 48; | |
const numpadZero = 96; | |
//add key codes for digits 0 - 9 into this filter | |
for(var i = 0; i <= 9; i++){ |
View phoneField_2.js
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
/******************************************************* | |
* formatPhoneText | |
* returns a string that is in XXX-XXX-XXXX format | |
*******************************************************/ | |
function formatPhoneText(value){ | |
value = this.replaceAll(value.trim(),"-",""); | |
if(value.length > 3 && value.length <= 6) | |
value = value.slice(0,3) + "-" + value.slice(3); | |
else if(value.length > 6) |
View phoneField_3.js
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
/******************************************************* | |
* validatePhone | |
* return true if the string 'p' is a valid phone | |
*******************************************************/ | |
function validatePhone(p){ | |
var phoneRe = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/; | |
var digits = p.replace(/\D/g, ""); | |
return phoneRe.test(digits); | |
} |
View phoneField_4.js
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
/******************************************************* | |
* onKeyUp(e) | |
* when a key is pressed up, grab the contents in that | |
* input field, format them in line with XXX-XXX-XXXX | |
* format and validate if the text is infact a complete | |
* phone number. Adjust the border color based on the | |
* result of that validation | |
*******************************************************/ | |
function onKeyUp(e){ | |
var input = e.target; |
View phoneField_5.js
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
/******************************************************* | |
* setupPhoneFields | |
* Now let's rig up all the fields with the specified | |
* 'className' to work like phone number input fields | |
*******************************************************/ | |
function setupPhoneFields(className){ | |
var lstPhoneFields = document.getElementsByClassName(className); | |
for(var i=0; i < lstPhoneFields.length; i++){ | |
var input = lstPhoneFields[i]; |
View jqueryGetGoogle.js
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
$.get("http://google.com",function(googPageHtml){ | |
console.log("-->",googPageHtml) | |
}); |
View basicPromise.js
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
var promise = new Promise(function(resolve,reject){ | |
/* | |
* Do things here (synchronous or asynchronous) | |
* some examples: | |
* -- run loops | |
* -- perform ajax requests | |
* -- count sheep! | |
*/ | |
View googleMapWithPolygon.js
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
/******************************************************************** | |
* initialize() | |
* setup the google map, draw the polygon on it, set event handlers | |
********************************************************************/ | |
function initialize() { | |
//create the google map | |
var map = new google.maps.Map(document.getElementById("map"), { | |
zoom: 4, | |
center: new google.maps.LatLng(22.7964, 79.8456), | |
mapTypeId: google.maps.MapTypeId.HYBRID |
View basicGoogleMap.html
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 onload="initialize()"> | |
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script> | |
<div id="map" style="width:900px; height: 600px;"> | |
</div> | |
</body> |
View injectUpdateAndDelete.js
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
//create a global variable that will point to the tooltip in the DOM | |
var tipObj = null; | |
//offset along x and y in px | |
var offset = { | |
x: 20, | |
y: 20 | |
}; | |
/******************************************************************** |
OlderNewer