This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function when_condition_met(fn_condition, fn_callback, interval, opt_max_attempt) { | |
var poll_id; | |
var run_count = 0; | |
poll_id = setInterval(function () { | |
if (typeof opt_max_attempt == "number" && run_count == opt_max_attempt) { | |
clearInterval(poll_id); | |
return; // possible run onfail callback.. If so refactor to be onject based params. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function patchDelegate(delegate){ | |
console.log("Patching: ", delegate.type, delegate.selector); | |
var type = delegate.type; | |
var handler = delegate.handler; | |
var selector = delegate.selector; | |
var newHandler = function(e){ | |
e.preventDefault(); | |
console.group(); | |
console.log("Event triggered for: " + selector); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DetectOS() { | |
var osName = "Unknown OS"; | |
var platform = navigator.platform.toUpperCase(); | |
if (platform.indexOf("WIN") != -1) osName = "Windows"; | |
if (platform.indexOf('MAC') != -1) osName = "MacOS"; | |
if (platform.indexOf("X11") != -1) osName = "UNIX"; | |
if (platform.indexOf("LINUX") != -1) osName = "Linux"; | |
return osName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$.fn.serializeObject = function () { | |
var o = {}; | |
var a = this.serializeArray(); | |
$.each(a, function () { | |
if (o[this.name] !== undefined) { | |
if (!o[this.name].push) { | |
o[this.name] = [o[this.name]]; | |
} | |
o[this.name].push(this.value || ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* MD5 (Message-Digest Algorithm) | |
* http://www.webtoolkit.info/ | |
* | |
**/ | |
var MD5 = function (string) { | |
function RotateLeft(lValue, iShiftBits) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyApp = MyApp || {}; | |
(function(app) { | |
var count = 0; | |
app.add = add; | |
app.getCount = getCount; | |
function add() { | |
count++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WorkerBar = (function(){ | |
var promises = []; | |
var workingbar = $('.working'); | |
var done; | |
var add = function(promise) { | |
if ( promises.length == 0 ){ | |
showWorking(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.wait = function(time) { | |
return $.Deferred(function(dfd) { | |
setTimeout(dfd.resolve, time); | |
}).promise(); | |
}; | |
/* | |
---------------------------- | |
Use Case | |
---------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, unused:true, browser:true, devel:true, jquery:true, indent:4, maxerr:50, node:true */ | |
/* global _ */ | |
(function ($, _) { | |
"use strict"; | |
//Actual app logic | |
var PromiseCue = function (options) { | |
var fn = function () {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Countdown = function ($, undefined) { | |
'use strict'; | |
var interval, | |
initialMinutes = 5, | |
initialSeconds = 0, | |
dfd = $.Deferred(); | |
var vars = { | |
isInitialized: false, |