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.prototype.delayed = function (delay) { | |
| var timer = 0; | |
| var callback = this; | |
| return function() { | |
| clearTimeout(timer); | |
| timer = setTimeout(callback, ms); | |
| }; | |
| }; | |
| document.getElementById('search').addEventListener('keyup',search.delayed(200)); |
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 fn1 = function () { | |
| console.log('f1'); | |
| var c = 1 + b; | |
| }; | |
| var fn2 = function () { | |
| console.log('f2'); | |
| setTimeout(fn1, 100); | |
| //fn1(); | |
| }; |
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
| webApp.directive('icheck', function($timeout, $parse) { | |
| return { | |
| require: 'ngModel', | |
| link: function($scope, element, $attrs, ngModel) { | |
| return $timeout(function() { | |
| var value; | |
| value = $attrs['value']; | |
| $scope.$watch($attrs['ngModel'], function(newValue){ | |
| $(element).iCheck('update'); |
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
| // base class | |
| function SuperHuman (name, superPower) { | |
| this.name = name; | |
| this.superPower = superPower; | |
| } | |
| SuperHuman.prototype.usePower = function () { | |
| console.log(this.superPower + "!"); | |
| }; |
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
| module PATTERN { | |
| export class SingletonClass { | |
| private message: string; | |
| private static _instance:SingletonClass = null; | |
| constructor() { | |
| if(SingletonClass._instance) { | |
| throw console.log('Error: Instantiation failed'); | |
| } |
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
| class Iterator<T> { | |
| private count: number = 0; | |
| constructor(private lists: Array<T> = null) {} | |
| hasNext(): boolean { | |
| if(this.count < this.lists.length) { | |
| 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
| module PATTERN { | |
| export interface Precure { | |
| getTitle(): string; | |
| } | |
| export class SweetPrecure implements Precure { | |
| getTitle(): string { | |
| return 'title1'; | |
| } |
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
| module PATTERN { | |
| export class AbstractCreator { | |
| constructor(private name: string) {} | |
| create(): WindInstrumentProduct { | |
| var product: WindInstrumentProduct = this.createInstrument(); | |
| this.mark(product); |
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
| appServices.factory('TokenInterceptor', function ($q, $window, $location, AuthenticationService) { | |
| return { | |
| request: function (config) { | |
| config.headers = config.headers || {}; | |
| if ($window.sessionStorage.token) { | |
| config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token; | |
| } | |
| return config; | |
| }, | |
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 negate (predicateFunc) { | |
| return function () { | |
| return !predicateFunc.apply(this, arguments); | |
| }; | |
| } | |
| function isSuperStrong (character) { | |
| return character.strength === "Super"; | |
| } |