Skip to content

Instantly share code, notes, and snippets.

View tbranyen's full-sized avatar

Tim Branyen tbranyen

View GitHub Profile
// Collection iterator
self.each = function(_collection, _callback) {
var method, index, item, collection, keys, wrapper,
index_r = "i",
item_r = "_collection[i]",
collection_r = "_collection";
// Normal collection
if(_collection.length > 0 || _collection instanceof Array) {
method = true;
@tbranyen
tbranyen / models.js
Last active September 5, 2015 12:14
var user = {
username: { type: String, required: true },
password: { type: String, required: true },
valueOf: "username"
};
var tweet = {
source: { type: String, default: "Web" },
created_at: { type: Date, default: new Date() },
if(typeof _selector == "string") {
if(cache[_selector])
return cache[_selector];
window.setTimeout(function() { delete cache[_selector]; }, 0);
cache[_selector] = dom.query(_selector);
return cache[_selector];
}
@tbranyen
tbranyen / jquery.dom.js
Created August 23, 2010 23:59
potential new load filter
// The idea is to create a DOM based off an xml string passed to it. Very very rough draft of what this would look like.
// Working example @ http://tabdeveloper.com/jquery/load/
// Current problems are that <html>,<head>, and <body> tags are currently stripped from load's filter and that external resource
// are requested because the original load uses a 'dummy div'. This code attempts to solve both issues.
jQuery.dom = function(xmlstr) {
var doc;
// Start with standards compliant browsers first since they own
if("DOMParser" in window) {
@tbranyen
tbranyen / handler.js
Created December 1, 2010 19:56
handler shell
(function(window) {
window.renderTemplate = function() {
var template, context;
// AJAX implementation block
// Container node to render template into and paths to template and context
return function(node, paths) {
@tbranyen
tbranyen / handler-jquery.js
Created December 1, 2010 20:37
jquery plugin example
(function(window, $) {
$.fn.renderTemplate = function(paths) {
var template, context;
// Fetch template and context block
// Render block
@tbranyen
tbranyen / handler-dijit.js
Created December 1, 2010 20:48
dojo widget implementation
dojo.provide("dojox.widget.RenderTemplate");
dojo.require("dijit._Widget");
dojo.declare("dojox.widget.RenderTemplate",
dijit._Widget,
{
postCreate: function() {
this.inherited(arguments);
},
@tbranyen
tbranyen / handler.js
Created December 1, 2010 21:21
handler file with ajax functionality added in
(function(window) {
window.renderTemplate = function() {
var template, context;
// Handle ajax requests
var ajax = function() {
// Create normalized xhr object
function xhr() {
// To stifile any exceptions
@tbranyen
tbranyen / handler.js
Created December 1, 2010 21:37
handler code with render functionality added
(function(window) {
// Required dojo template references
dojo.require("dojox.dtl");
dojo.require("dojox.dtl.Context");
window.renderTemplate = function() {
var template, context;
// Handle ajax requests
var ajax = function() {
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Detect Credit Card Type</title>
</head>
<body>