Skip to content

Instantly share code, notes, and snippets.

@ederduran
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save ederduran/8949e5978f05fca08d59 to your computer and use it in GitHub Desktop.

Select an option

Save ederduran/8949e5978f05fca08d59 to your computer and use it in GitHub Desktop.

Revisions

  1. Eder Durán revised this gist Sep 26, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jquery.backgroundrdm.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    (function(a){$.fn.extend({backgroundRdm : function (arrayLista){this.each(function(){backgroundsTotal = arrayLista.length;random = Math.floor((Math.random() * backgroundsTotal) + 0);finalBack = arrayLista[random];$(this).css('background-image','url(' + finalBack + ')');});}});})(jQuery)
    (function(e){$.fn.extend({backgroundRdm:function(e){this.each(function(){backgroundsTotal=e.length;random=Math.floor(Math.random()*backgroundsTotal+0);finalBack=e[random];$(this).css("background-image","url("+finalBack+")")})}})})(jQuery)
  2. Eder Durán revised this gist Sep 26, 2014. 1 changed file with 1 addition and 12 deletions.
    13 changes: 1 addition & 12 deletions jquery.backgroundrdm.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1 @@
    (function(a){
    $.fn.extend({
    backgroundRdm : function (arrayLista){
    this.each(function(){
    backgroundsTotal = arrayLista.length;
    random = Math.floor((Math.random() * backgroundsTotal) + 0);
    finalBack = arrayLista[random];
    $(this).css('background-image','url(' + finalBack + ')');
    });
    }
    });
    })(jQuery)
    (function(a){$.fn.extend({backgroundRdm : function (arrayLista){this.each(function(){backgroundsTotal = arrayLista.length;random = Math.floor((Math.random() * backgroundsTotal) + 0);finalBack = arrayLista[random];$(this).css('background-image','url(' + finalBack + ')');});}});})(jQuery)
  3. Eder Durán created this gist Sep 26, 2014.
    12 changes: 12 additions & 0 deletions jquery.backgroundrdm.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    (function(a){
    $.fn.extend({
    backgroundRdm : function (arrayLista){
    this.each(function(){
    backgroundsTotal = arrayLista.length;
    random = Math.floor((Math.random() * backgroundsTotal) + 0);
    finalBack = arrayLista[random];
    $(this).css('background-image','url(' + finalBack + ')');
    });
    }
    });
    })(jQuery)
    15 changes: 15 additions & 0 deletions scripts.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    $(document).ready(function(){
    //Asignamos a body un background aleatorio tomando en cuenta la lista de backgrounds que le pasamos a traves de un array
    $("body").backgroundRdm([
    'http://ederduran.com/wp-content/uploads/2014/09/square_bg.png',
    'http://ederduran.com/wp-content/uploads/2014/09/pat-17.png',
    'http://ederduran.com/wp-content/uploads/2014/09/gplaypattern.png',
    'http://ederduran.com/wp-content/uploads/2014/09/light_wool.png',
    'http://ederduran.com/wp-content/uploads/2014/09/grey.png',
    'http://ederduran.com/wp-content/uploads/2014/09/ecailles.png',
    'http://ederduran.com/wp-content/uploads/2014/09/cream_pixels.png',
    'http://ederduran.com/wp-content/uploads/2014/09/crossword.png',
    'http://ederduran.com/wp-content/uploads/2014/09/transp_bg.png',
    ]);

    });