What are the best...
VCS
| // All modules must have a init function. | |
| /** | |
| * ready Function | |
| * @param fn | |
| */ | |
| function ready(fn) { | |
| if (document.readyState != 'loading'){ | |
| fn(); | |
| } else { | |
| document.addEventListener('DOMContentLoaded', fn); |
| /** | |
| * @param lng {Number} | |
| * @returns {string} | |
| * @constructor | |
| */ | |
| function MakeId(lng) { | |
| var text = ""; | |
| var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
| for (var i = 0; i < lng; i++) |
| r=require,f='<form><input name=m>';r('http').createServer((q,s)=>s.end(f=('<p>'+(r('querystring').parse(q.url)['/?m']||'')+f))).listen(3000) |
| $.validator.addMethod("passwordCheck", function (value, element) { | |
| return this.optional(element) || /((?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%-_=+<>]).{8,30})/g.test(value); | |
| }, "Field must contain only letters, numbers, or dashes."); |
| $.validator.addMethod("passwordCheck", function (value, element) { | |
| return this.optional(element) || /((?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%-_=+<>]).{8,30})/g.test(value); | |
| }, "Field must contain only letters, numbers, or dashes."); |
| var http = require("http"); | |
| http.get(weatherApi, function(res) { | |
| var body = ''; | |
| // get chunks of data and add it to body | |
| res.on('data', function(chunk){ | |
| body += chunk; | |
| }); |
| /** | |
| * project.exampleModule | |
| * @namespace project.exampleModule | |
| */ | |
| (function (window, project, undefined) { | |
| /** | |
| * @constructor | |
| * @public | |
| * @memberof project.exampleModule |
| /** | |
| * Using apply and built-in functions | |
| * | |
| * Clever usage of apply allows you to use built-ins functions for some tasks that otherwise probably would have been written by looping over the array values. As an example here we are going to use Math.max/Math.min to find out the maximum/minimum value in an array. | |
| */ | |
| // min/max number in an array | |
| var numbers = [5, 6, 2, 3, 7]; | |
| // using Math.min/Math.max apply |
| /** | |
| * Pass an Array of image urls and it will run `callback` once they are cached. | |
| * | |
| * @example | |
| cacheImagesThenCallback([image.jpg, picture.png], function() { | |
| ... | |
| }); | |
| * @alias CORE.cacheImagesThenCallback | |
| * @constructor | |
| * @param imageSrcArray {array} Array of image urls. |