Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- var g =0;
- var y =0;
- var descending = function(){
- $("#filtr").html('Price Descending <i class="demo-icon icon-up-dir" style="margin-left: 0px;"></i>').click(ascending);
- $("#itemy, #your_items").html("").removeClass('olwerflol');
- g = 0;
- y=0;
- $("#count").html(g);
- $("#total_price").html(y.toFixed(2));
- for ( n=0; n<prices.length; n++){ //5 // n = 0;
- for (i=0; i<name_length; i++){ //6
- if (name[i][2] == prices[n]) { //if name[0][2](673.82)=
- $("#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>');
- break;
- }
- }
- }
- $(".items").each(function(index){
- var value = $(this).find(".price").html();
- if (value<1) {
- $(this).css("color", "red").css("cursor", "not-allowed").css("opacity", "0.6");
- return 0;}
- var addi = function(){
- y += parseFloat(value);
- g++;
- var item = $(this);
- $("#your_items").prepend(item);
- item.addClass("elko");
- $("#count").html(g);
- $("#total_price").html(y.toFixed(2));
- $(this).off();
- if (g==20) $("#count").css("color","red");
- if (g>4) $("#your_items").addClass("olwerflol");
- if (g>0) $("#deposit").fadeIn();
- item.click(removei);
- };
- var removei= function(){
- y -= parseFloat(value);
- g --;
- var item = $(this);
- $("#itemy").prepend(item);
- item.addClass("elko");
- $("#count").html(g);
- $("#total_price").html(y.toFixed(2));
- $(this).off();
- if (g==20) $("#count").css("color","red");
- if (g<4) $("#your_items").removeClass("olwerflol");
- if (g==0) $("#deposit").fadeOut();
- item.click(addi);
- };
- $(this).click(addi);
- });
- return 0;
- };
- var ascending = function(){ // KLIK W filtr
- $("#filtr").html('Price Ascending <i class="demo-icon icon-down-dir" style="margin-left: 0px;"></i>').click(descending);
- $("#itemy, #your_items").html("").removeClass('olwerflol');
- g = 0;
- y=0;
- $("#count").html(g);
- $("#total_price").html(y.toFixed(2));
- for ( n=prices.length; n>=0; n--){
- for (i=0; i<name_length; i++){
- if (name[i][2] == prices[n]) {
- $("#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>');
- break;
- }
- }
- }
- $(".items").each(function(index){
- var value = $(this).find(".price").html();
- if (value<1) {
- $(this).css("color", "red").css("cursor", "not-allowed").css("opacity", "0.6");
- return 0; }
- var addi = function(){
- y += parseFloat(value);
- g++;
- var item = $(this);
- $("#your_items").prepend(item);
- item.addClass("elko");
- $("#count").html(g);
- $("#total_price").html(y.toFixed(2));
- $(this).off();
- if (g==20) $("#count").css("color","red");
- if (g>4) $("#your_items").addClass("olwerflol");
- if (g>0) $("#deposit").fadeIn();
- item.click(removei);
- };
- var removei= function(){
- y -= parseFloat(value);
- g --;
- var item = $(this);
- $("#itemy").prepend(item);
- item.addClass("elko");
- $("#count").html(g);
- $("#total_price").html(y.toFixed(2));
- $(this).off();
- if (g==20) $("#count").css("color","red");
- if (g<4) $("#your_items").removeClass("olwerflol");
- if (g==0) $("#deposit").fadeOut();
- item.click(addi);
- };
- $(this).click(addi);
- });
- return 0;
- };
- 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"], ["Karambit | Tiger Tooth (FACTORY-NEW)]", "tiger.png", 673.82, "knife"], ["AWP | ASIIMOV (FIELD-TESTED)", "asiimov.png", 25.97, "red" ], ];
- var prices = [];
- var name_length = name.length; //6
- for (i=0; i<name_length; i++){
- prices[prices.length] = name[i][2];
- prices.sort(function(a, b){return b-a});
- }
- descending();
- $("#filtr").click(ascending);
- if (name.length>21){
- $("#itemy").addClass("olwerflol");
- }
- }); //Koniec funkcji ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement