Skip to content

Instantly share code, notes, and snippets.

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// 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) {}
@emayk
emayk / remote-typeahead.js
Created July 19, 2012 08:04 — forked from geuis/remote-typeahead.js
Remote data querying for Twitter Bootstrap 2.0 Typeahead without modifications
<script>
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
@emayk
emayk / README.markdown
Created July 19, 2012 08:05 — forked from jrust/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)

This is a fork of a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

  • Ability to disable autoselect of first matched element.
  • Ability to automatically set the width of the dropdown to that of the text input.
  • Ability to fetch source element via AJAX
  • Ability to have a comma separated list of tags.

For the proper source, and other examples, please see the original gist.

Example showing off all the above features

@emayk
emayk / pagination.php
Created July 19, 2012 08:05 — forked from yaranaio/pagination.php
Twitter bootstrap was applied to the CodeIgniter Pagination
<?php
$config['first_link'] = false;
$config['next_link'] = '次へ >>';
$config['prev_link'] = '<< 前へ';
$config['last_link'] = false;
$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>;';
@emayk
emayk / snippet.js
Created July 19, 2012 08:07 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
<html>
<head>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<head>
<body>
<script>
$(document).ready(function () {
// Cross domain ajax (uses YQL)
@emayk
emayk / date.js
Created July 19, 2012 10:30 — forked from litzinger/date.js
Cross Domain XML to JSON
/*
* JavaScript Pretty Date
* Copyright (c) 2011 John Resig (ejohn.org)
* Licensed under the MIT and GPL licenses.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time){
var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
@emayk
emayk / cors.js
Created July 19, 2012 11:35 — forked from eriwen/cors.js
Simple cross-domain Javascript function
/**
* Make a X-Domain request to url and callback.
*
* @param url {String}
* @param method {String} HTTP verb ('GET', 'POST', 'DELETE', etc.)
* @param data {String} request body
* @param callback {Function} to callback on completion
* @param errback {Function} to callback on error
*/
function xdr(url, method, data, callback, errback) {
@emayk
emayk / cross_domain.js
Created July 19, 2012 11:36 — forked from jonleung/cross_domain.js
Cross Domain Access in Javascript
function filterData(data){
// data = data.replace(/<?\/body[^>]*>/g,'');
// data = data.replace(/[\r|\n]+/g,'');
// data = data.replace(/<--[\S\s]*?-->/g,'');
// data = data.replace(/<noscript[^>]*>[\S\s]*?<\/noscript>/g,'');
// data = data.replace(/<script[^>]*>[\S\s]*?<\/script>/g,'');
// data = data.replace(/<script.*\/>/,'');
// data = data.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
data = data.replace(/<style[^>]+?\/>|<style(.|\s)*?\/style>/gi, '')
@emayk
emayk / jQuerycrossdomainajaxexample.html
Created July 20, 2012 03:10 — forked from andylind/jQuerycrossdomainajaxexample.html
jQuery cross domain ajax example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery cross domain ajax example</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {