Skip to content

Instantly share code, notes, and snippets.

View devdays's full-sized avatar

Bruce D Kyle devdays

View GitHub Profile
@devdays
devdays / geolocation-sample2.html
Created December 2, 2014 01:12
Geolocation sample with watchPosition, clearWatch, error handling
<!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 () {
@devdays
devdays / html5-websocket.html
Created November 30, 2014 19:15
Web Socket client
<!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 December 22, 2014 17:32
jQuery Filter Example
var games = $(myData.products).filter(function (index) {
return myData.products[index].category == "Game";
});
@devdays
devdays / jqeury-FilterResults.json
Created December 22, 2014 17:33
jQuery Filter Results
{
"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},
@devdays
devdays / jquery-grepExample.js
Created December 22, 2014 17:28
jQuery Grep Example
// 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 December 22, 2014 17:23
jQuery Snippet - Sample Data
// 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 February 22, 2015 23:30
Sample for moving footnotes using jQuery plugin
(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%");
@devdays
devdays / svg-animation.svg
Created November 30, 2014 23:38
SVG Animation
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 August 29, 2015 14:16
Sample jQuery UI Widget
<!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 / client.js
Last active August 29, 2015 14:16
Client code for displaying widget
$("#cheeses").filterable({
className: "cheese",
create: function() { $("#register").addClass("ui-widget-header cheese").show(); },
filtered: function(e, ui) {
var t = 0;
ui.visible.each(function() { t = t + parseFloat($(this).data("price")); });
console.log( t );
total.text(t.toFixed(2));
},
setOption: function(e, ui) {