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
// Pure JavaScript hasClass, addClass, and removeClass. | |
// Source: http://www.avoid.org/?p=78 | |
function hasClass(el, name) { | |
return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className); | |
} | |
function addClass(el, name) { | |
if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; } | |
} | |
function removeClass(el, name) { | |
if (hasClass(el, name)) { |
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
// jQuery scroll page smoothly depends on the link target ID and | |
// prevent #ID on the URL. Windows Phone has a built-in smooth-scroll | |
$('a[href^="#"]').click(function () { | |
$('html, body').animate({ scrollTop:$(this.hash).offset().top },500); | |
return false; | |
}); |
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
// Prevent or stop page from redirecting to the next page | |
window.onbeforeunload = function() { | |
return 'Are you sure you want to leave?'; | |
}; |
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
// Countdown timer script, after 25secs it will add class on the body class="stop-animations" | |
// and clear the intervar. Timer value (60 * 1 = 1 minute) | |
function startTimer(duration, display, isRunning) { | |
if (!!isRunning) { | |
var timer = duration, minutes, seconds; | |
var interval = setInterval(function () { | |
minutes = parseInt(timer / 60, 10); | |
seconds = parseInt(timer % 60, 10); | |
minutes = minutes < 10 ? "0" + minutes : minutes; | |
seconds = seconds < 10 ? "0" + seconds : 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
// Remove all comments in HTML | |
$('body').contents().filter(function() { | |
return this.nodeType == 8; | |
}).remove(); |
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
// required | |
code --install-extension emmanuelbeziat.vscode-great-icons | |
code --install-extension oderwat.indent-rainbow | |
code --install-extension dbaeumer.vscode-eslint | |
code --install-extension stylelint.vscode-stylelint | |
code --install-extension esbenp.prettier-vscode | |
code --install-extension visualstudioexptteam.vscodeintellicode | |
code --install-extension VisualStudioExptTeam.intellicode-api-usage-examples | |
code --install-extension eamodio.gitlens | |
code --install-extension waderyan.gitblame |
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
{ | |
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
"draw_white_space": "all", | |
"font_size": 12, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"translate_tabs_to_spaces": true, | |
"word_wrap": "false" |
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
// A simple counter and the numbers will be | |
// formatted to xxx,xxx,xxx | |
function formatNum(num) { | |
var parts = String( num ).replace(/[^\d.]-/g,'').split('.'); | |
var str = parts[0].split('').reverse().join(''); | |
var retVal = ''; | |
while( retVal != (str = str.replace(/(\d{3})(\d{1,3})/,'$1,$2')) ) { | |
retVal = str; | |
} | |
if( parts[1] ) { |
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 timeControl(n){ | |
if (n < 10) return "0" + n else return "" + n; | |
} | |
t = Math.floor(effect("Slider Control")("Slider")); | |
hr = Math.floor(t/3600); | |
min = Math.floor((t%3600)/60); | |
sec = Math.floor(t%60); | |
/* hours */ |
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
// Add multiple event listener to element | |
// Usage: addMutiEventListener(element, 'click touchstart', function() {}); | |
function addMutiEventListener(el, s, fn) { | |
s.split(' ').forEach(function (e) { | |
return el.addEventListener(e, fn, false); | |
}); | |
} |
OlderNewer