Skip to content

Instantly share code, notes, and snippets.

View wholypantalones's full-sized avatar

Jason Dare wholypantalones

View GitHub Profile
@wholypantalones
wholypantalones / head.html
Created May 9, 2012 14:18
jQuery ui map init
/* head */
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="/shared/plugins/jquery.ui.map.js"></script>
<script type="text/javascript" src="/shared/plugins/jquery.ui.map.overlays.js"></script>
<script type="text/javascript" src="/shared/plugins/jquery.ui.map.extensions.js"></script>
/* style */
<style>
.ui-mobile-rendering>*{visibility:visible;}
#map_canvas {
@wholypantalones
wholypantalones / year.jsp
Created May 9, 2012 14:28
Java Year Detection
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%= new SimpleDateFormat("yyyy").format(new Date()) %>
@wholypantalones
wholypantalones / timer.js
Created May 9, 2012 20:48
Determine script loading time/completion
//top of script
var startTime = (new Date()).getTime();
//complete function or bottom
var endTime = (new Date()).getTime();
var millisecondsLoading = endTime - startTime;
$("#timer").append("Loaded in: " + millisecondsLoading + " seconds");
@wholypantalones
wholypantalones / inputs.html
Created May 15, 2012 21:01
Show/Hide password fields
<input type="password" id="OLD_PASSWORD" name="OLD_PASSWORD" value="" />
<input type="checkbox" value="option" id="showPass" name="showPass" />
@wholypantalones
wholypantalones / gist:2710740
Created May 16, 2012 14:25
jQuery validate notEqual function
//usage
NEW_PASSWORD: {
required: true,
minlength: 7,
notEqual: "#OLD_PASSWORD",
},
//function
jQuery.validator.addMethod("notEqual", function(value, element, param) {
return this.optional(element) || value != $(param).val();
}, "Please specify a different (non-default) value");
@wholypantalones
wholypantalones / gist:2875939
Created June 5, 2012 16:02
JSON makeMenu()
function makeMenu(json) {
var html = "<ul>";
$.each(json,function(key,val){
html += "\n<li>";
if (typeof val === "object")
html += key +"\n" + makeMenu(val);
else
html += key + ": " + val;
html += "\n</li>";
});
@wholypantalones
wholypantalones / jqueury.numeric.js
Created July 10, 2012 13:52
jQuery ForceNumericOnly Plugin
jQuery.fn.ForceNumericOnly =
function()
{
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
return (
@wholypantalones
wholypantalones / cookies.js
Created July 10, 2012 13:53
Set, Get and Null Cookies with jQuery
//set cookies
$("#div").toggle(function() { //create div toggle
$("#div").slideUp("slow"); //create effect
$.cookie('cookie_name', 'value', {expires: 7}); //set cookie expire in 7 days
},
function () { //continue the toggle
$("#div").slideDown("slow"); //create effect
$.cookie('cookie_name', 'value'); //set cookie
});
@wholypantalones
wholypantalones / doMyBidding.html
Created July 10, 2012 14:02
Submit A Form With A Link
<a href="javascript:{}" onclick="document.getElementById('theFormName').submit();">submit</a>
or
<a href="#" onclick="return doMyBidding();">submit</a>
@wholypantalones
wholypantalones / datFitBounds.js
Last active October 7, 2015 03:28
Google Maps Zoom To Fit All Markers
// create an array of coordinates to zoom on
var latlng = [{
name: "South West Marker",
latlng: new google.maps.LatLng(swLat, swLng)
}, {
name: "North East Marker",
latlng: new google.maps.LatLng(neLat, neLng)
}];
var latlngbounds = new google.maps.LatLngBounds();
for (var i = 0; i < latlng.length; i++) {