Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
(function () { | |
// HTML items | |
// <button>Normal</button> | |
// <button>Changed</button> | |
// <a href="http://www.google.com">Google</a> | |
// <a href="http://www.google.com">Google</a> | |
var buttons = document.getElementByTagName('button'); |
(function () { | |
var speed = 500, | |
i = 0, | |
doSomething = function () { | |
console.log('doSomething() executed ' + (i + 1) + ' times'); | |
i++; | |
if (i > 4) { | |
// stop when condition is met |
/* functions */ | |
/* passing a function as a parameter */ | |
var calculate = function (number, paramTwo, fn) { | |
number = number + 3; | |
number = number + 1; | |
number = number * 8; | |
return fn(number, paramTwo); | |
}; |
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
// http://javascriptweblog.wordpress.com/2010/12/07/namespacing-in-javascript/ | |
/* Namespacing - The Module Pattern */ | |
var myApp = (function () { | |
var id = 0; | |
return { | |
next: function () { | |
return id++; | |
}, |
// Immediately invoked function | |
// Code treated as local variables and functions | |
// Anonymous function, wrapped by a set of parenthesis, allows execution of anonymous function | |
(function () { | |
var foo = 'hello, window'; | |
var bar = function () { | |
var foo = 'hello, function'; |
// user input | |
var input = '3 5 10\n2 7 15\n5 10 50'; | |
// split on newline | |
var inputSplitOnNewLine = input.split('\n'); | |
// get and set 'A', 'B', and 'N' values | |
// call fizzBuzz function | |
for (var i = 0; i < inputSplitOnNewLine.length; i++) { | |
var inputString = inputSplitOnNewLine[i]; // current 3 numbers |
<script> | |
(function($) { | |
$(function() { | |
// place scripts here... | |
}); | |
})(jQuery); | |
</script> | |
/* | |
(function($) { |
/* Print Styles - http://www.slideshare.net/aardrian/css-summit-2014-making-your-site-printable */ | |
/* | |
Resize type sizes to points, set text to black | |
- Points provide more consistent text size across browsers and devices | |
- Not all users have color printers. | |
Clear whitespace around content | |
- User's print settings will handle page margins |
/* Transformation Examples */ | |
// Ternary example | |
<%# !string.IsNullOrEmpty((string)Eval("ItemToTest")) ? "True" : "False" %> | |
<%# !String.IsNullOrEmpty(Eval("ItemToTest").ToString()) ? "True" : "False" %> | |
<%# !string.IsNullOrEmpty((string)Eval("CatalogLink")) ? "<p>For detailed curriculum and more, please visit the <a href=\"" + Eval("CatalogLink") + "\" target=\"_blank\">Course Catalog entry</a> for this program.</p>" : Eval("CatalogDescription") + "<br /><br /><strong>For detailed curriculum and more please visit the <a onclick=\"_gaq.push(['_trackEvent', 'Link', 'Click' 'Course Catalog Adult Education'])\" target=\"_blank\" href=\"" + Eval("CatalogLink") + "\">Course Catalog entry</a> for this program.</strong><br />" %> | |
<%# !String.IsNullOrEmpty(Eval("ScheduleOfBenefitsDownload").ToString()) || !String.IsNullOrEmpty(Eval("ProviderNetwork").ToString()) ? "<strong>Resources</strong><br>" : "" %> | |
/* ********** */ |