Skip to content

Instantly share code, notes, and snippets.

@NicholasMurray
NicholasMurray / NicholasHTMLExample
Created June 28, 2012 23:04
JQuery Tutorial Html Example
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is a Sample Page</title>
<link href="allstateni-1.0.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Truncate Example</h1>
(function ($) {
$.fn.truncate = function (options) {
var defaults = {
length: 300,
minTrail: 20,
moreText: "more",
lessText: "less",
ellipsisText: "..."
};
p {
width:600px;
background-color:#ccc;
padding:10px;
}
.allstateni_normal_text {
font-size: .85em;
font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is a Sample Page</title>
</head>
<body>
<h1>Truncate Example</h1>
<p class="truncate">
@NicholasMurray
NicholasMurray / gist:5188763
Created March 18, 2013 16:56
RockPaperScissorsHTMLRequired
<!DOCTYPE html>
<html>
<head>
<title>Rock Paper Scissors basic version</title>
</head>
<body>
</body>
</html>
@NicholasMurray
NicholasMurray / gist:5188775
Last active December 15, 2015 02:39
RockPaperScissorsHTMLInputAndOutput
<p>
<span>The human has chosen:</span><br /><br />
<input type="radio" name="human-choice" value="rock">Rock<br />
<input type="radio" name="human-choice" value="paper">Paper<br />
<input type="radio" name="human-choice" value="scissors">Scissors<br /><br />
<input type="button" id="play-game" value="Play" /><br /><br />
</p>
<p>
The computer has chosen: <i><span id="computer-choice"></span></i>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
</script>
var choiceArray = ['rock', 'paper', 'scissors'];
var humanChoice = '';
var computerChoice = '';
var winner = '';
$('#play-game').click(function() {
computerChoice = choiceArray[Math.floor(Math.random() * choiceArray.length)];
humanChoice = $('input:radio[name=human-choice]:checked').val();
function theWinnerIs(humanChoice, computerChoice) {
if (humanChoice === computerChoice ) {
return 'no winner it is a draw';
}
if ((humanChoice === 'rock') && (computerChoice === 'scissors')) {
return 'human';
}
if ((humanChoice === 'rock') && (computerChoice === 'paper')) {
@NicholasMurray
NicholasMurray / QUnit equal
Created February 25, 2014 00:01
QUnit equal
equal: function( actual, expected, message ) {
/*jshint eqeqeq:false */
QUnit.push( expected == actual, actual, expected, message );
},
push: function( result, actual, expected, message ) {
if ( !config.current ) {
throw new Error( "assertion outside test context, was " + sourceFromStacktrace() );
}