Skip to content

Instantly share code, notes, and snippets.

View TCotton's full-sized avatar
🏠
Working from home

Andrew Walpole TCotton

🏠
Working from home
View GitHub Profile
@TCotton
TCotton / form_processing.js
Created July 11, 2011 16:53
Form processing script
// JavaScript Document
/*global Modernizr*/
/*global Y */
/*global DOMAssistant */
/*global DOMReady */
/*global clearInterval: false, clearTimeout: false, document: false, event: false, frames: false, history: false, Image: false, location: false, name: false, navigator: false, Option: false, parent: false, screen: false, setInterval: false, setTimeout: false, window: false, XMLHttpRequest: false, alert: false*/
/* Three functions: prcess_contact_form for as the name suggests
process the contact form and search_placeholder for adding
placeholder to the search box to Internet Explorer
icon_rollover changes the image of the main icon on rollover
@TCotton
TCotton / ieplaceholder.js
Created July 12, 2011 13:51
IE Placeholder JavaScript replacement
if (!Modernizr.input.placeholder) {
// always declare javascript variables at the top of the script
var $elements, $i, $x, $len, $formInput, $inputField, $form;
$form = document.getElementById('contact-us').elements;
$i = 0;
//set placeholder values for internet explorer
@TCotton
TCotton / jcanvascriptexperiment.js
Created July 14, 2011 11:48
jcanvascript experiment
function html5_canvas() {
var $colours1, $colours2, $gradient1, $gradient2;
jc.start("canvas_1");
// first gradient
var $colours1 = [
[0, 'rgb(0,147,211)'],
[0.5, 'rgb(255,255,255)'],
@TCotton
TCotton / fabric.js
Created July 14, 2011 19:14
Creates pretty shapes with fabric.js
function html5_canvas() {
// declear variables
var $canvas, $rect, $circle, $triangle, $i, $limit, $width, $height;
//create canvas object with div id
$canvas = new fabric.Canvas('canvas_1');
// create Circle - note radius
@TCotton
TCotton / cake.js
Created July 16, 2011 11:49
CAKE HTML5 canvas experiment
function html5_canvas() {
// declare variables
var $canvas, $circle, $rectangle, $backG, $canvasImage, $imageMask;
/*
Create the HTML elements below
It is the child of the code tag and will be 750 x 600
*/
$canvas = new Canvas(document.getElementById("code"), 750, 600);
@TCotton
TCotton / doodle.js
Created July 16, 2011 18:17
Using doodle.js HTML Canvas framework
function html5_canvas() {
// declare variables
var $canvas, $element, $circle, $rect, $triangle, $x, $limit, $angle, $centerY, $range, $speed;
//dom block element wrapper
$element = doodle.createDisplay("canvas");
//creates new canvas element wrapper
$canvas = $element.createLayer();
// function to create a random number
@TCotton
TCotton / andy.css
Created August 6, 2011 07:25
320 and up
h1 {
margin-bottom : .75em;
font-size : 3em; /* 48 / 16 = 3 */
line-height : 1.2;
}
h2 {
margin-bottom : .75em;
font-size : 2em; /* 36 / 16 = 2 */
line-height : 1.2;
}
@TCotton
TCotton / class-controllerSettingsApi.php
Created February 29, 2012 10:43
A class to handle the Wordpress Settings API
class Form_Controller {
function __construct() {
} // end construct
public function ah_config_settings() {
// put together the output array
@TCotton
TCotton / a view.php
Created March 7, 2012 21:39
Wordpress Options API access class
<?php
namespace OptionView;
use OptionController;
/**
* Form_View
*
* @package Wordpess Options API access class
* @author Andy Walpole
@TCotton
TCotton / recursive.php
Created April 16, 2012 12:40
Rescursivly find file
<?php
function find_files($path, $file) {
$path = rtrim(str_replace("\\", "/", $path), '/').'/*';
foreach (glob($path) as $fullname) {
if (is_dir($fullname)) {
find_files($fullname, $file);
} else {