link: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
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 getCursorPosition (inp) { | |
| if ("selectionStart" in inp) { | |
| return inp.selectionStart | |
| } else if (document.selection) { | |
| inp.focus(); | |
| var sel = document.selection.createRange(); | |
| var selLen = document.selection.createRange().text.length; | |
| sel.moveStart("character", -inp.value.length); | |
| return sel.text.length - selLen; | |
| } |
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 setCursorPosition(e, pos) { | |
| $(e).each(function(index, elem) { | |
| if (elem.setSelectionRange) { | |
| elem.setSelectionRange(pos, pos); | |
| } else if (elem.createTextRange) { | |
| var range = elem.createTextRange(); | |
| range.collapse(true); | |
| range.moveEnd('character', pos); | |
| range.moveStart('character', pos); | |
| range.select(); |
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 = function(){ | |
| var current = null; | |
| var labels = { | |
| 'home':'home', | |
| 'articles':'articles', | |
| 'contact':'contact' | |
| }; | |
| var init = function(){ | |
| }; | |
| var show = function(){ |
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
| // Everything that is likely to change in your code should not be scattered throughout your code. | |
| // By putting these into a configuration object and making this one public we make maintenance easy and allow for customization. | |
| carousel = function(){ | |
| var config = { | |
| CSS:{ | |
| classes:{ | |
| current:'current', | |
| scrollContainer:'scroll' | |
| }, |
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 names = ['George', | |
| 'Ringo', | |
| 'Paul', | |
| 'John']; | |
| for(var i=0,j=names.length;i<j;i++){ | |
| doSomethingWith(names[i]); | |
| } |
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
| lsof | grep 35729 |
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 getScrollTop = function() { | |
| if(_isMobile) { | |
| return _mobileOffset; | |
| } else { | |
| return window.pageYOffset || documentElement.scrollTop || body.scrollTop || 0; | |
| } | |
| }; | |
| var setScrollTop = function(top, force) { | |
| _forceRender = (force === true); |
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 alertSize() { | |
| var myWidth = 0, myHeight = 0; | |
| if( typeof( window.innerWidth ) == 'number' ) { | |
| //Non-IE | |
| myWidth = window.innerWidth; | |
| myHeight = window.innerHeight; | |
| } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { | |
| //IE 6+ in 'standards compliant mode' | |
| myWidth = document.documentElement.clientWidth; | |
| myHeight = document.documentElement.clientHeight; |
OlderNewer