Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruce D Kyle devdays

View GitHub Profile
@devdays
devdays / geolocation-sample2.html
Created Dec 2, 2014
Geolocation sample with watchPosition, clearWatch, error handling
View geolocation-sample2.html
<!DOCTYPE html>
<html>
<head>
<title>Location Test with Buttons</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script type="text/javascript">
window.addEventListener("load", function () {
var nav = null;
var watchID;
startWatching.addEventListener("click", function () {
View html5-websocket.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script type="text/javascript">
var wsUri = 'ws://' + window.location.hostname +
window.location.pathname.replace('index.html', 'ws.ashx');
var output;
var socket;
@devdays
devdays / jQuery-FilterExample.js
Created Dec 22, 2014
jQuery Filter Example
View jQuery-FilterExample.js
var games = $(myData.products).filter(function (index) {
return myData.products[index].category == "Game";
});
View jqeury-FilterResults.json
{
"0":{"name":"Board Game 1","category":"Game","price":35},
"1":{"name":"Card Game 1","category":"Game","price":8.5},
"2":{"name":"Poker","category":"Game","price":75.5},"length":3,
"prevObject": {
"0":{"name":"Slinky","category":"Toy","price":9.56},
"1":{"name":"Hamburger","category":"Grocery","price":2.49},
"2":{"name":"Squirt Gun","category":"Toy","price":8.5},
"3":{"name":"Board Game 1","category":"Game","price":35},
"4":{"name":"Card Game 1","category":"Game","price":8.5},
View jquery-grepExample.js
// Get just the toys by grep on products
var toys = $.grep(myData.products, function (element, index) {
// return whether myData.products.category == 'Toy'
return element.category == "Toy";
});
// toys is a new array of the matching products
$.each(toys, function (i) {
$('#toys').append("<li class='toy'>" + toys[i].name + "</li>");
});
@devdays
devdays / jquery-data.js
Created Dec 22, 2014
jQuery Snippet - Sample Data
View jquery-data.js
// start with JSON (perhaps received using $.getJSON() )
var myJSONString = '{' +
'"products":' +
' ['+
' { "name": "Slinky", "category": "Toy", "price": 9.56 }, ' +
' { "name": "Hamburger", "category": "Grocery", "price": 2.49 }, ' +
' { "name": "Squirt Gun", "category": "Toy", "price": 8.50 }, ' +
' { "name": "Board Game 1", "category": "Game", "price": 35 }, ' +
' { "name": "Card Game 1", "category": "Game", "price": 8.50 }, ' +
' { "name": "Poker", "category": "Game", "price": 75.50 }, ' +
@devdays
devdays / footnotes-0.0.2.js
Created Feb 22, 2015
Sample for moving footnotes using jQuery plugin
View footnotes-0.0.2.js
(function ($) {
$.fn.footnote = function () {
// console.log("footnote");
var footnotes = this.find("span.footnote");
footnotes.each(function (key, value) {
//console.log("footnote" + key + " : " + $(value).contents().text());
var footnoteContentsNode = $(value).clone();
var footnoteNumberTextNode = document.createTextNode("[" + key + "] ");
$("#references").append(footnoteNumberTextNode).append(footnoteContentsNode).css("color", "blue").append("<br />");
$(value).text("[" + key + "] ").css("color", "blue").css("vertical-align", "super").css("font-size", "60%");
View svg-animation.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@devdays
devdays / Filterable-0.0.3.html
Last active Aug 29, 2015
Sample jQuery UI Widget
View Filterable-0.0.3.html
<!DOCTYPE html>
<html>
<head>
<!--
From http://ajpiano.com/widgetfactory/
Copyright 2014 Bruce D Kyle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@devdays
devdays / setWidgetOption.js
Last active Aug 29, 2015
Your widget responds to changes of an option
View setWidgetOption.js
_setOption: function (key, value) {
var oldValue = this.options[key];
// Check for a particular option being set
if (key === "className") {
// Gather all the elements we applied the className to
this.filterInput.parent().add(this.filterElems)
// Switch the new className in for the old