Skip to content

Instantly share code, notes, and snippets.

View johnantoni's full-sized avatar

John Griffiths johnantoni

View GitHub Profile
@johnantoni
johnantoni / sinatra-cache-demo.rb
Created March 16, 2010 08:12
sinatra cache demo
require 'rubygems'
require 'sinatra'
configure do
Cache = {} # Create a new cache
end
helpers do
def menu_helper
sleep 3 # delay to demonstrate cache speedup...
var data = "Core Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
$(".autocomplete").autocomplete(data, {minChars: 0});
function append_message(text) {
if ($(".ac_results").find("span").length == 0) {
$(".ac_results").append("<span>"+text+"</span>");
};
};
$(".autocomplete").keyup(function(){
@johnantoni
johnantoni / jquery.tamperframe.js
Created August 19, 2010 12:17
determine if element changed inside iframe and create alert on clicking exit element
/*
* jquery.tamperframe.js
* v 0.1
*
* Initial Author
* John Griffiths
*
* Description
* Simpy watches an element for changes, if any encountered flips the flag.
* If the exit button is clicked and the flag is true a dialog appears warning user will lose changes.
// detect Internet Explorer and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//
// author: Scott Jehl
//
// http://gist.github.com/scottjehl
//
// version arg is for IE version (optional)
// comparison arg supports 'lte', 'gte', etc (optional)
//
// is it IE?
@johnantoni
johnantoni / dean edwards ie conditionals
Created August 23, 2010 14:52
dean edward ie conditional detect
// http://jsperf.com/ie
// Conditional Comment
ie = (function() {
var v = 3,
div = document.createElement('div');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', div.getElementsByTagName('i')[0]);
window.status = v;
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// And to detect the version:
// ie === 6 // IE6
// ie> 7 // IE8, IE9 ...
@johnantoni
johnantoni / Google Doodle - Bouncy Balls
Created September 7, 2010 10:14
google doodle - bouncy balls
(function() {
try {
if (!google.doodle) google.doodle = {};
var a = 200,
g = -200,
j = -200,
k,
l,
m,
n = 0,
@johnantoni
johnantoni / font-family declaration - with apple in mind
Created October 15, 2010 12:31
font-family declaration - with apple in mind
font:100%/1.5 "Helvetica Neue",Helvetica,Arial,sans-serif;
@johnantoni
johnantoni / html5 mark element
Created October 15, 2010 12:36
html5 mark element
http://html5doctor.com/draw-attention-with-mark/
mark {
background-color : #ff9;
color : rgb(0,0,0);
font-style : italic;
font-weight : bold; }
---------------------
@johnantoni
johnantoni / tinyMCE fix for jquery validation
Created December 20, 2010 17:54
tinyMCE fix for use with jQuery.validation plugin and IE
// when using the jquery.validation plugin with a tinymce textarea you will need to write the contents of the tinymce area back into the original textarea for jquery.validation to pick up it's new value
// force tinymce content to be written back into original textarea element
var content = tinyMCE.activeEditor.getContent();
$("textarea.tinymce").val(content);
// if all else fails
tinyMCE.triggerSave();
after this you can safely apply jquery validation ala...