Scope & Timeline. Troubleshooting takes time and it's painful when the problem is because of where something is written in respect to other things. "Return functions". I wish i learned to do this earlier. Instead of writing "document.get[thing]" over and over again sucks. So creating a return function in my global object is a great timesaver... something like UI.bySelect("#tag") and UI.byTag("body"). I believe this is also a good way to learn how to use parameters Parameters. Specifically about the scope of where a variable is named. I found that there are times where i'll use "x", "y" for a generic variable to pass as a parameter. This means the previous function will try to pass their variable in those spots. This is something to pay attention to when using more than two parameters Using setTimeout() to delay a className change. This is something that i spent a lot of time and code on to do things, only to find out that a simple timeout can delay a change momentarity. This is important when l
This file contains 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 timeString(userMilliseconds) { | |
var // the actual data ranges. now trivial to extend | |
ranges = [ | |
{ range: 86400, singular: 'day', plural: 'days' }, | |
{ range: 3600, singular: 'hour', plural: 'hours' }, | |
{ range: 60, singular: 'minute', plural: 'minutes' }, | |
{ range: 1, singular: 'second', plural: 'seconds' } | |
], |
This file contains 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
'use strict'; | |
/* global angular */ | |
var app = angular.module('playground', []); | |
app.directive('showBetweenHours', function () { | |
return { | |
restrict: 'AC', | |
link: function (scope, element, attrs) { |