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
/** | |
* FUNCTIONS | |
**/ | |
/** | |
* Functions create closures; variables defined | |
* inside of them are accessible inside the | |
* function, and to any functions that were | |
* defined within the same scope. | |
**/ |
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 tooltip_button = { | |
show : function () { | |
this.panel.show(); | |
}, | |
hide : function () { | |
this.panel.hide(); | |
}, | |
bind_events : function () { | |
var that = this; | |
this.button.bind("mouseover.Tooltip_Button", function () { that.show.call(that); }); |
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
document.ontouchstart = function(e) { | |
//This will alert coordinates where you touch the screen | |
alert(e.touches[0].pageX+', '+e.touches[0].pageY); | |
//This will alert coordinates if you touch with a second finger at the same time | |
if(e.touches[1]) { | |
alert(e.touches[1].pageX+', '+e.touches[1].pageY); | |
} | |
} |
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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
bar[foo?'doSomething':'doSomethingElse'](el); | |
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
// ---------------------------------------------------------- | |
// 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) {} |
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
/* Javascript utility funcs */ | |
function valueInArray (val,arr) { | |
for (var i = 0; i < arr.length; i++) { | |
if (val==arr[i]) { | |
return true; | |
} | |
} | |
return false; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>jQuery Templating Demo</title> | |
<style type="text/css"> | |
html { | |
background:#f3f3f3; | |
font: 13px/1.5 helvetica, arial, san-serif; | |
} | |
ul { |
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 array = ["one", "two", "three", "four", "five"]; | |
document.writeln(array + "<br />"); | |
var newArray = shuffle(array); | |
document.writeln(newArray); | |
function shuffle (arr) { | |
var copy = arr.concat(), |
NewerOlder