Skip to content

Instantly share code, notes, and snippets.

View hughbris's full-sized avatar

Hugh Barnes hughbris

  • Reidston, New Zealand
  • 02:39 (UTC +13:00)
View GitHub Profile
@hughbris
hughbris / bbsSubmit.js
Last active August 29, 2015 14:18
bbsSubmit
/*
Imagine a world where Javascript is relied upon to submit a form, the only means of validation. That is currently my sad reality.
Needs are basic for this instance. It's a temporary state of affairs and This Will Do Now (TM).
*/
function bbsSubmit(action) {
$("[class~='error'][class~='field']").each( function () {
$(this).removeClass('error');
} );
@hughbris
hughbris / README.md
Last active August 29, 2015 14:21
Pattern for testing development Javascript in production environments

This is nothing but a simple conditional pattern for situations where you find yourself needing to test Javascript development code in a live operational server environment. Yes, this indicates less than ideal configuration management, but it has happened to me more than once. Reasons I can think of are:

  • stoopid (quite often)
  • need to authenticate against APIs, some of which can be difficult or impossible to set up in non-production environments

To make it work, you just have to set a custom User Agent prefix in your testing browser and change the string at the top of the file to match it. Customising User Agent strings varies between browsers but there are usually plugins available if it is not in the configuration options (for example, User Agent Switcher for Firefox).

Of course, syntax errors are going to kill the whole deal … :(

@hughbris
hughbris / call-to-action.html
Last active August 29, 2015 14:21
Design pattern: call to action button/link (plus sized)
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- brah! -->
<head>
<title>Call to do it!</title>
<style type="text/css">
@hughbris
hughbris / img.cut-in.html
Last active August 29, 2015 14:21
Design pattern: very basic cut-in image (right-aligned by default)
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- brah! -->
<head>
<title>Right aligned cut-in</title>
<style type="text/css">
@hughbris
hughbris / dl.quotes.html
Created May 13, 2015 06:35
Design pattern: list of attributed third-party blockquotes rendered with speech bubbles
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- brah! -->
<head>
<title>Third-party attributed blockquote list</title>
<style type="text/css">
@hughbris
hughbris / ul.logos.credits.html
Last active August 29, 2015 14:21
Design pattern: roll the credits, this is a list of logos
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- brah! -->
<head>
<title>Drum please</title>
<style type="text/css">
@hughbris
hughbris / breakouts.html
Created June 3, 2015 04:19
Design pattern: breakout boxes
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- bru -->
<head>
<title>Step away from the flow</title>
<style type="text/css">
@hughbris
hughbris / formhints.html
Created June 3, 2015 05:17
Design pattern: hints for forms
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- bru -->
<head>
<title>You need help</title>
<style type="text/css">
@hughbris
hughbris / form-personfields.html
Created June 3, 2015 05:44
Design pattern: personal details fieldset boilerplate for a form
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- bru -->
<head>
<title>Gotta sign up</title>
<style type="text/css">
@hughbris
hughbris / form-elaboratedradios.html
Created June 3, 2015 06:28
Design pattern: radio buttons across with aligned pictorial headings and blurb text
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-NZ" lang="en-NZ"> <!-- bru -->
<head>
<title>What will it be? You must choose</title>
<style type="text/css">