Guest User

Untitled

a guest
Nov 28th, 2016
218
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.   $('.shop-zipcode').each(function(){
  3.     var getShopZipcode = $(this).text();
  4.     $(this).closest('li').attr('data-zipcode', getShopZipcode.substring(0, 2));
  5.   });  
  6.  
  7.   $('ul.shop-all li').each(function(){
  8.     var dataZipcode = $(this).attr('data-zipcode');
  9.     var idfCodeList = ["77","78","91","92","93","94"];
  10.  
  11.     if((dataZipcode == 75)){
  12.       $(this).addClass('is-paris');
  13.     }
  14.  
  15.     else if($.inArray(dataZipcode, idfCodeList) >= 0){
  16.       $(this).addClass('is-idf');
  17.     }
  18.  
  19.     else{
  20.       $(this).addClass('is-province');
  21.     }
  22.   });
  23.  
  24.   var isZones = ["paris","idf","province"];
  25.   $.each(isZones, function(index,value){
  26.     $('li.is-'+ value).each(function(){
  27.       $(this).appendTo('ul#shop-' + value);
  28.     });
  29.   });
  30.  
  31.   $('ul.shop-all').remove();      
  32. });
RAW Paste Data