These docs are old. Use these
/*
* message
*/
console.log();
var len = array.length;
for(var ii = 0; ii < len; ii++){
var cur = array[ii];
/* code ... */
}
for (var key in object){
if (object.hasOwnProperty(key)){
var value = object[key];
}
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '${1:UA-XXXXX-X}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
switch(var){
case :
/* code ... */
break;
case :
/* code ... */
break;
default:
/* code ... */
break;
}
condition ? true : false;
try {
/* code... */
}
catch (e) {
/* code... */
}
finally (e) {
/* code... */
}
var filtered = array.filter(
function(element){
return true|false;
}
);
items.sort(function (a, b) {
if (${1:a > b}){
return 1;
}
if (${2:a < b}){
return -1;
}
// a must be equal to b
return 0;
});
setTimeout(function(){},delay);
function method(arguments){
/* code ... */
}
(function(){
/* code */
})();
function ClassName (param) {
this.publicVar = 'foo';
var privateVar = 'bar';
var that = this;
function privateMethod(){
/*
* this method can be accessed by
* privileged methods but not by
* public methods.
*/
}
this.privilegedMethod = function(){
/*
* this method has access to both
* the public and private properties
* of the object
*/
}
}
ClassName.prototype.publicMethod = function() {};
var ClassName;
(function() {
var instance;
ClassName = function ClassName() {
if (instance) {
return instance;
}
instance = this;
/* code */
};
}());
var promise = new Promise(function(resolve, reject) {
var success;
/* code */
if (success) {
resolve();
}
else {
reject(Error());
}
});
promise.then(
function(result) {
console.log(result);
},
function(err) {
console.log(err);
}
);
promise.then(
function(result) {
console.log(result);
},
function(err) {
console.log(err);
}
);
$.ajax({
url: '',
data: {}
})
.done(function ( data ) {
/* code ... */
})
.fail(function(jqXHR,textStatus){
/* code ... */
})
.always(function(jqXHR,textStatus){
/* code ... */
});
```js
$(document).ready(function(e){
/* code ... */
});
```
```js
$(function() {
/* code ... */
});
```
```js
$('selector').on('event', function(e){
/* code ... */
});
```
(function($){
var ClassName = function (element, options){
this.$element = $(element);
// plugin options
this.options = $.extend({}, ClassName.DEFAULTS, options);
var that = this;
};
ClassName.DEFAULTS = {};
var old = $.fn.pluginName;
$.fn.pluginName = function (option) {
return this.each(function () {
var $this = $(this);
var data = $this.data('pluginName');
var options = typeof option === 'object' && option;
if (!data){
$this.data('pluginName', (data = new ClassName(this, options)));
}
});
};
$.fn.pluginName.Constructor = ClassName;
$.fn.pluginName.noConflict = function() {
$.fn.pluginName = old;
return this;
};
})(jQuery);
publish (tiny pub/sub)
```js
$.publish('whatever.event.name',payload);
```
subscribe (tiny pub/sub)
```js
function handlerFunction(){
return function(_,data){
console.log('subscribe ',data);
};
}
$.subscribe('whatever.event.name',handlerFunction());
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>page</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="">
</head>
<body>
<main>
</main>
<script type="text/javascript" src=""></script>
</body>
</html>
<video controls preload="auto" width="640" height="264" poster="PATH_TO_ASSETS.png">
<source src="PATH_TO_ASSETS.mp4" type='video/mp4' />
<source src="PATH_TO_ASSETS.webm" type='video/webm' />
<source src="PATH_TO_ASSETS.ogv" type='video/ogg' />
</video>
@media all and (min-width: 50em) {
}
@-webkit-keyframes ANIMATION_NAME {
0% { }
100% { }
}
@-moz-keyframes ANIMATION_NAME {
0% { }
100% { }
}
@-o-keyframes ANIMATION_NAME {
0% { }
100% { }
}
@keyframes ANIMATION_NAME {
0% { }
100% { }
}
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: 750ms;
transition-duration: 750ms;
-webkit-transition-timing-function: ease-in;
transition-timing-function: ease-in;
-webkit-transition-delay: 500ms;
transition-delay: 500ms;
/^[0-9a-zA-Z]+$/
/^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
# osx noise
.DS_Store
# svn & cvs
.svn
CVS
*.log
node_modules
bower_components
# project specific