Skip to content

Instantly share code, notes, and snippets.

View sgentile's full-sized avatar

Steve Gentile sgentile

  • Mile Two
  • Dayton, Ohio
View GitHub Profile
@sgentile
sgentile / Extend
Created December 12, 2011 19:48
Extending Object
function Foo(options) {
if (!(this instanceof Foo)) {
return new Foo(options);
}
options = options || {};
$.extend(this, {
Id: 0,
Bar: null,
Bars: []
}, options);
@sgentile
sgentile / jqueryfilter.js
Created September 10, 2011 05:14
find and not find filter
$(".navigatorModifierSearch").live('keyup', function (event) {
var $navigationelementsContainer = $(this).parent().parent().find(".navigationelementsContainer");
var searchTerm = $(this).val();
if (searchTerm.length > 0) {
$navigationelementsContainer.find('div[data-name*="' + searchTerm.toUpperCase() + '"]').removeClass("hideNavElement");
$navigationelementsContainer.children().not('div[data-name*="' + searchTerm.toUpperCase() + '"]').addClass("hideNavElement");
} else {
//make sure all are showing
$navigationelementsContainer.children().removeClass("hideNavElement");
@sgentile
sgentile / jsmodule.js
Created August 11, 2011 11:37
Javascript Module Pattern
<script type="text/javascript">
//from book 'Javascript the Good parts' p.58
//The methods do not make use of this or that.
//As a result, there is no way to com- promise the seqer.
//It isn’t possible to get or change the prefix or seq
//except as per- mitted by the methods. The seqer object
//is mutable, so the methods could be replaced, but
//that still does not give access to its secrets.
//seqer is simply a collection of functions, and
@sgentile
sgentile / KnockoutJsHistory
Created May 13, 2011 14:32
KnockoutJS with History
<!doctype html>
<html lang="en">
<head>
<title>knockout binding test</title>
<style type="text/css">
#sidebar { float: left; width: 15em; }
#details { float: left; }
#sidebar li { list-style: none; }
#sidebar a { list-style: none; background-color: silver; width: 8em; margin-bottom: 0.5em; padding: 0.5em; display:block; }
#sidebar a.selected { background-color: Navy; color: white; }
@sgentile
sgentile / Basic Javascript Callback
Created May 13, 2011 14:28
Basic Javascript Callback
<!-- This demonstrates a simple javascript callback -->
<div id="now">0</div>
<input type="button" id="goBtn" value="Go" />
<br/>
<div id="result">Let's go!</div>
<script>
var result = document.getElementById('result');
function animate(element, callback){