Skip to content

Instantly share code, notes, and snippets.

@TerryMooreII
TerryMooreII / textarea-tab.js
Last active December 31, 2015 04:39
Add Tab support within a text area. In particular Metlifes Synapse site
//Added tab support to Metlife Synapse json resume builder site
$('#json_textarea').on('keydown', function(event){
$this = $(this);
var TAB_SPACES = 2;
var getSpaces = function(){
var space='';
for(var i=0; i<TAB_SPACES; i++){
space += ' ';
@TerryMooreII
TerryMooreII / barcodesanner.js
Last active December 27, 2015 09:49
barcode scanner - doesnt work....yet :)
<!DOCTYPE html>
<html><head>
<title>Barcode recognition with JavaScript</title>
<script type="text/javascript" src="get_barcode_from_image.js"></script>
<style type="text/css"></style></head>
<video id="video" width="320" height="240" autoplay></video>
<button id="snap">Snap Photo</button>
<canvas id="canvas" width="320" height="240"></canvas>
<button onclick="alert(getBarcodeFromImage('canvas'))">Scan</button>
@TerryMooreII
TerryMooreII / war.js
Last active December 27, 2015 04:39
war
var suites = ['\u2660', '\u2665', '\u2666', '\u2663'];
var numbers = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'];
var buildDeck = function(){
var deck = [];
for (var suite in suites)
for (var number in numbers)
deck.push(numbers[number] + suites[suite]);
return deck;
};
@TerryMooreII
TerryMooreII / deckOfCards.js
Created November 1, 2013 13:03
Deck of Cards
var suites = ['\u2660', '\u2665', '\u2666', '\u2663'];
var numbers = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'];
var buildDeck = function(){
var deck = [];
for (suite in suites)
for (number in numbers)
deck.push(numbers[number] + suites[suite]);
return deck;
}
@TerryMooreII
TerryMooreII / jquery-i18n.html
Last active December 26, 2015 14:19
Sample code for blog
<html>
<body>
<div id="myId">
<span data-i18n="welcome"></span> <!-- Updates the span text with the welcome value from the translation file-->
<input data-i18n="enter_name"> <!-- Updates the placeholder value with enter_name value fro from the translation file-->
</div>
<script src="path/to/jquery"></script>
<script src="path/to/jquery.i18n.js"></script>
<script>
$('body').i18n();
@TerryMooreII
TerryMooreII / hs-football-player-of-the-week.js
Last active December 23, 2015 07:39
Um, my mom requested this. A script to vote for my cousin so that he can player of the week. I really don't feel so bad, it looks like two other contestants are doing the same.
(function(){
var count = 0;
var totalVotes = 10;
var interval = 1000; //in milliseconds 1000 = 1 sec
var vote = setInterval(function(){
$('input[value="3997"]').prop('checked', true);
$('form.poll').submit();
console.log("Vote " + count + " Cast")
@TerryMooreII
TerryMooreII / jquery-mobile.getHashtagParameters.js
Last active December 20, 2015 07:09
Jquery mobile. Pass data from hashtag page links with in jquery mobile Ex #newPage?key=value&key2=asdf. This is by no means a final product but it gets the job done.
var params;
// Listen for any attempts to call changePage().
$(document).bind( "pagebeforechange", function( e, data ) {
if ( typeof data.toPage === "string" ) {
var u = $.mobile.path.parseUrl( data.toPage );
var re = /^#/;
var question = u.hash.indexOf('?');
if ( u.hash.search(re) !== -1 && question !== -1 )
@TerryMooreII
TerryMooreII / jquery.moble.panelOpenSwipe.js
Last active December 20, 2015 03:29
Jquery Mobile open panel by sliding by starting slide from left edge
(function(){
var swiperight = null;
$('body').on('touchstart vmousedown', function(e){
if (e.pageX < 20)
swiperight = e.pageX;
else
swiperight = null;
});
@TerryMooreII
TerryMooreII / gist:5585240
Last active December 17, 2015 09:09
Baseball filed in CSS3 - work in progress
<!-- http://cssdeck.com/labs/baseball-field -->
<html>
<head>
<title>CSS3 Baseball field</title>
<style type="text/css">
#field{
position:absolute;
/**
* Replace $.ajax on your subdomain with a copy taken
* from your base domain. All jQuery AJAX actions go
* through $.ajax (i.e. $.get, $.post), so it's all good.
*/
(function() {
var iframe,
onload,
queue = [],