Guest User

Untitled

a guest
Oct 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function swap(x,y){
  2. var temp = $('img:eq('+x+')').attr('src');
  3. var temp2 = $('img:eq('+y+')').attr('src');
  4.  
  5. $('img:eq('+y+')').attr('src',temp);
  6. $('img:eq('+y+1+')').attr('src',temp);
  7. $('img:eq('+x+')').attr('src',temp2);
  8. $('img:eq('+x+1+')').attr('src',temp2);
  9. }
  10.  
  11. function hw(x){
  12. return $('img:eq('+x+')').height()/$('img:eq('+x+')').width();
  13. }
  14.  
  15. function getNew(){
  16. var images = document.getElementsByClassName('img-responsive');
  17. var size = images.length;
  18. for (var x=0; x<size; x=x+2){
  19. for (var y=0; y<size-2; y=y+2){
  20. if(hw(y)>hw(y+2)){
  21. swap(y,y+2);
  22. console.log(y);
  23. console.log(y+2);
  24.  
  25. }
  26. }
  27.  
  28. }
  29. }
Add Comment
Please, Sign In to add comment