Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. var i =0;
  4. var y =0;
  5. var ascending = function(){ // KLIK W filtr
  6. $(this).html('Price Ascending <i class="demo-icon icon-up-dir" style="margin-left: 0px;"></i>')
  7. $("#itemy").html("");
  8. for ( n=prices.length; n>=0; n--){
  9. for (i=0; i<name_length; i++){
  10.  
  11.  
  12. if (name[i][2] == prices[n]) {
  13. $("#itemy").append('<div class="items"><div class="item_name">'+ name[i][0] +'</div><div class="item_img"><img src="'+ name[i][1] +'" height="100px" width="100px"></div><div class="price '+ name[i][3] +'" >'+ name[i][2] +'</div></div>')
  14.  
  15. }
  16. }
  17. $(".items").each(function(index){
  18. var value = $(this).find(".price").html();
  19. if (value<1) {
  20.  
  21. $(this).css("color", "red").css("cursor", "not-allowed").css("opacity", "0.6");
  22. return 0;
  23.  
  24. }
  25.  
  26. $(this).click(function(){
  27. y += parseFloat(value);
  28. i++;
  29. var item = $(this).get();
  30. $("#your_items").prepend(item);
  31. $("#count").html(i);
  32. $("#total_price").html(y.toFixed(2));
  33. $(this).off();
  34. if (i>4) $("#your_items").css("overflow-y", "scroll");
  35. if (i>0) $("#deposit").fadeIn();
  36. });
  37.  
  38. });
  39. }
  40.  
  41. };
  42.  
  43.  
  44.  
  45.  
  46. var name = [["Karambit | Tiger Tooth (FACTORY-NEW)]", "tiger.png", 673.82, "knife"], ["AWP | ASIIMOV (FIELD-TESTED)", "asiimov.png", 25.97, "red" ], ["AWP | ASIIMOV (FIELD-TESTED)", "asiimov.png", 25.97, "red" ], ["FAMAS | DJINN (MINIMAL-WEAR)", "jin.png", 3.07, "pink"], ["MAC-10 | MALACHITE (FACTORY-NEW)", "malachite.png", 1.21, "purple"], ["SCAR-20 | GROTTO (FIELD-TESTED)", "grotto.png", 0.73, "blue"], ];
  47. var prices = [];
  48. var name_length = name.length;
  49. for (i=0; i<name_length; i++){
  50. prices[prices.length] = name[i][2];
  51. prices.sort(function(a, b){return b-a});
  52. }
  53.  
  54.  
  55.  
  56.  
  57. $("#itemy, #mess_box").html("");
  58. for ( n=0; n<prices.length; n++){
  59. for (i=0; i<name_length; i++){
  60.  
  61.  
  62. if (name[i][2] == prices[n]) {
  63. $("#itemy").append('<div class="items"><div class="item_name">'+ name[i][0] +'</div><div class="item_img"><img src="'+ name[i][1] +'" height="100px" width="100px"></div><div class="price '+ name[i][3] +'" >'+ name[i][2] +'</div></div>')
  64. }
  65. }
  66. }
  67.  
  68. $(".items").each(function(index){
  69. var value = $(this).find(".price").html();
  70. if (value<1) {
  71.  
  72. $(this).css("color", "red").css("cursor", "not-allowed").css("opacity", "0.6");
  73. return 0;
  74.  
  75. }
  76.  
  77. $(this).click(function(){
  78. y += parseFloat(value);
  79. i++;
  80. var item = $(this).get();
  81. $("#your_items").prepend(item);
  82. $("#count").html(i);
  83. $("#total_price").html(y.toFixed(2));
  84. $(this).off();
  85. if (i>4) $("#your_items").css("overflow-y", "scroll");
  86. if (i>0) $("#deposit").fadeIn();
  87. });
  88.  
  89. }); //Koniec funkcjie each
  90.  
  91. $("#filtr").click(ascending());
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98. }); //Koniec funkcji ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement