Skip to content

Instantly share code, notes, and snippets.

@ethyde
ethyde / file-size-next-download-links.js
Last active August 29, 2015 14:07
Display file sizes next to download links - From http://tutorialzine.com book "Trickshots"
@ethyde
ethyde / jquery-plugin-demo.html.js
Last active August 29, 2015 14:07
Simple jQuery base plugin
$(document).ready(function() {
// put all your jQuery goodness in here.
$('#sandbox').pluginName({
fontSize : '2em',
onComplete : function() {
$( this ).fadeOut( 5000 );
},
onSetup : function() {
$( this ).css( 'color', 'blue' );
}
$(function() {
    $.ajaxSetup({
        error: function(jqXHR, exception) {
            if (jqXHR.status === 0) {
                alert('Not connect.\n Verify Network.');
            } else if (jqXHR.status == 404) {
                alert('Requested page not found. [404]');
            } else if (jqXHR.status == 500) {
                alert('Internal Server Error [500].');
            } else if (exception === 'parsererror') {
<!-- To sort or not to sort, that is the question. -->
<h3>By price asc</h3>
<ul id="u1" style="margin-bottom: 20px;"></ul>
<h3>By city desc</h3>
<ul id="u2"></ul>
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
$("input").datepicker({
beforeShowDay: nonWorkingDates,
numberOfMonths: 1,
minDate: '05/01/14',
firstDay: 1
});
function nonWorkingDates(date){
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDates = [[7,25, 2014], [8, 14, 2014]];
@ethyde
ethyde / is-in-iframe.js
Last active August 29, 2015 14:07
Parse url param : http://stackoverflow.com/a/3855394 Use window.location with jQuery : http://stackoverflow.com/a/14613849
// in iframe
var isInIframe = (window.location != window.parent.location) ? true : false;
// or
var isIniFrame = function(){
return (window.location != window.parent.location) ? true : false;
};
// set
var newCodes = function(){
var dCodes = fg.codecsCodes.rs; // Linked ICDs
var dCodes2 = fg.codecsCodes2.rs; //Linked CPTs
return [dCodes, dCodes2];
};
// get
var codes = newCodes();
var dCodes = codes[0];
var dCodes2 = codes[1];
@ethyde
ethyde / stop-scroll-event-propagation-gmap.js
Last active August 29, 2015 14:07
Stop scroll event propagation outside a Google map
var dom = document.getElementById("conteneur-map");
dom.addEventListener('DOMMouseScroll',function(event){
event.stopPropagation();
},false);
@ethyde
ethyde / countdown.html
Created September 30, 2014 12:00
Simple Javascript count down timer.
<div id="countdown"></div>
<div id="newcountdown"></div>