javascript - slow protoype.js performance using on penny auction website help me -


i ask developer make me penny auction script magento average speed of request 450-500 ms slow.. on cloud server , dedicated( low end) tested other script on internet fast 100 ms prototype.js slow? or code not optimised? here script please me please you

function auctiontimer(dt,no,id) {     //alert(no);  var end = new date(dt);  var now_date= new date(no);  // alert(now_date);  // alert(end);     var _second = 1000;     var _minute = _second * 60;     var _hour = _minute * 60;     var _day = _hour * 24;       flag_time = true;     timer = '';     setinterval(function(){showremaining();},1000);      function showremaining()      {         var date = no;                 var = new date(date);                 var de= now.gettime();                  if ( flag_time ) {                 timer = de;                 }                 var d = new date(timer);                 currentyear = d.getfullyear();                 month = d.getmonth()+1;                  var currentdate = d.getdate();                 currentdate = currentdate < 10 ? '0'+currentdate : currentdate;                  var hours = d.gethours();                 var minutes = d.getminutes();                 var seconds = d.getseconds();                  // var ampm = hours >= 12 ? 'pm' : 'am';                 // hours = hours % 12;                 // hours = hours ? hours : 12; // hour ’0′ should ’12′                 minutes = minutes < 10 ? '0'+minutes : minutes;                 seconds = seconds < 10 ? '0'+seconds : seconds;                 var strtime = hours + ':' + minutes+ ':' + seconds; // + ' ' + ampm;                 timer = timer + 1000;                var now_time = currentyear+'/' + month+'/' + currentdate + ' ' + strtime ;                  // document.getelementbyid("demo1").innerhtml= currentmonth1+' ' + currentdate+' , ' + currentyear + ' ' + strtime ;                  // document.getelementbyid("demo2").innerhtml= currentdate+':' +(month+1)+':' +currentyear + ' ' + strtime ;                  // document.getelementbyid("demo3").innerhtml= strtime ;                  // document.getelementbyid("demo4").innerhtml= current_day + ' , ' +currentmonth1+' ' + currentdate+' , ' + currentyear + ' ' + strtime ;                    // alert(now_time);          var = new date(now_time);          // alert(now);         var distance = end - now;          if (distance < 0) {              if (distance>-3)                  {                     location.reload(true);                      return;                 };              clearinterval(timer);             document.getelementbyid('countdown_'+id).innerhtml = 'sold';             document.getelementbyid('bid-box').hide();             document.getelementbyid('auction_watcher').hide();             toggledisabled(document.getelementbyid('bid-box'));             toggledisabled(document.getelementbyid('auction_watcher'));             document.getelementbyid('watcher_url').removeattribute('href');             return;         }         var days = math.floor(distance / _day);         var hours = math.floor((distance % _day) / _hour);         var minutes = math.floor((distance % _hour) / _minute);         var seconds = math.floor((distance % _minute) / _second);         if (days <10)             {days = '0' + days;}         if (hours <10)             {hours = '0' + hours;}         if (minutes < 10)            { minutes = '0' + minutes;}         if (seconds < 10)             {seconds = '0' + seconds; }         if(days==00)         {                         dytext = '';             }         else if(days==1)         {             dytext = '<span class="countdown-text">'+ days +' day  </span>';            }         else         {              dytext = '<span class="countdown-text">'+ days +' days  </span>';             }         if(hours==00) {             hrtext='';         }         else {             hrtext = '<span class="countdown-text">'+ hours + '</span>'+ ":";         }         if(minutes==00)         {             mintext='';         }else {                   mintext = '<span class="countdown-text">'+ minutes +'</span>'+ ":";          }         sectext = '<span class="countdown-text">'+ seconds +'</span>';         document.getelementbyid('countdown_'+id).innerhtml = dytext + hrtext +  mintext + sectext;        flag_time = false;     }      //timer = setinterval(showremaining, 1000); } function callme() {     document.getelementbyid('countdown').innerhtml = "time"; }   function price_condtion(min_price,max_price,id)     { return;      min_price ="(between" + '<span class="price">'+ "$" +min_price + '</span>' +" , ";     max_price = '<span class="price">'+ "$"+max_price + '</span>' + ")";     document.getelementbyid('price_condition_'+id).innerhtml = min_price + max_price;     } function placepennybid(url,id){     //var bid_type = $$('input:checked[type="radio"][name="bid_type"]').pluck('value');     //var is_valid_bidprice = checkbidprice();     // if(is_valid_bidprice == false)     // return;     //var bid_price = $('bid_price').value;      var product_id = id;      $('auction_bid_button'+product_id).hide();     $('auction_bid_waitting'+product_id).show();     $('msg_error'+product_id).innerhtml = '';     $('msg_success'+product_id).innerhtml ='';     $('msg_error'+product_id).hide();     $('msg_success'+product_id).hide();    // $('is_bidding').value = '1';     var auctionid = $('auction_id').value;      new ajax.request(url,                 {                 method: 'post',                 parameters: {auction_id:auctionid,product_id:product_id},                  onsuccess: function(data) {                     response = data.responsetext.evaljson(true);                      if(response.iserror)                    {                      $('msg_error'+product_id).update(response.errors);                         $('msg_error'+product_id).innerhtml;                         //$('msg_error'+product_id).show();                         jquery('#msg_error'+product_id).show().delay(3000).fadeout();                      }else {                      $('msg_success'+product_id).update(response.success);                         $('msg_success'+product_id).innerhtml;                         jquery('#msg_success'+product_id).show().delay(3000).fadeout();                          //jquery('#msg_success'+product_id).delay(5000).hide();                         $('auction_bid_waitting'+product_id).hide();                         $('auction_bid_button'+product_id).show();                         $('totalbids').update(response.totalbid);                     $('totalbids').innerhtml;                     }                     //autionbidcomplete();                         $('auction_bid_waitting'+product_id).hide();                         $('auction_bid_button'+product_id).show();                  },                 onfailure: function(response){                // alert("url not exixts");                  $('auction_bid_waitting'+product_id).hide();                  $('auction_bid_button'+product_id).show();                 }                 });      //new ajax.updater('results_bid_after_'+auctionid,url,{method: 'get', oncomplete:function(){autionbidcomplete();} ,onfailure: ""});  }  function placepennyautobid(url,id){       var product_id = id;      $('auction_bid_auto_button_start'+product_id).hide();     $('auction_bid_waitting'+product_id).show();     $('msg_error'+product_id).innerhtml = '';     $('msg_success'+product_id).innerhtml ='';     $('msg_error'+product_id).hide();     $('msg_success'+product_id).hide();     var auctionid = $('auction_id').value;     var auto_price = $('bid_auto_price').value;     var num_bid = $('bid_auto_number').value;      new ajax.request(url,                 {                 method: 'post',                 parameters: {auction_id:auctionid,product_id:product_id,                     auto_price:auto_price,num_bid:num_bid},                  onsuccess: function(data) {                     response = data.responsetext.evaljson(true);                      if(response.iserror)                    {                      $('msg_error'+product_id).update(response.errors);                         $('msg_error'+product_id).innerhtml;                         $('msg_error'+product_id).show();                    }else {                     $('msg_success'+product_id).update(response.success);                         $('msg_success'+product_id).innerhtml;                         $('msg_success'+product_id).show();                                               //$('totalbids').update(response.totalbid);                         //$('totalbids').innerhtml;                    }                      //autionbidcomplete();                         $('auction_bid_waitting'+product_id).hide();                         //$('auction_bid_auto_button_start'+product_id).show();                  },                 onfailure: function(response){                   $('auction_bid_waitting'+product_id).hide();                  $('auction_bid_auto_button_start'+product_id).show();                 }                 });   }  function stoppennyautobid(url,id){       var product_id = id;       var auctionid = $('auction_id').value;       new ajax.request(url,                 {                 method: 'post',                 parameters: {auction_id:auctionid,product_id:product_id},                  onsuccess: function(data) {                     response = data.responsetext.evaljson(true);                     var num_bid = $('bid_auto_number').setvalue(15);                     },                 onfailure: function(response){                  }                 });   }   function checkbidprice(){     var bid_price = document.getelementbyid('bid_price').value;     var bid_type = document.getelementbyid('auction_standard_bid').checked;     //alert(bid_type);     if(bid_type==true)     {     price = bid_price;     if(price==null)     {         alert("enter bid price");     }     if(price != 0){     var min_next_price = document.getelementbyid('min_next_price').value;     var max_next_price = document.getelementbyid('max_next_price').value;     max_next_price = parsefloat(max_next_price);     min_next_price = parsefloat(min_next_price);     if(price < min_next_price)     {     alert("your bid price must equal or greater "+min_next_price);     return false;     }     if(max_next_price != 0)     if(price > max_next_price)     {         alert("your bid price must less "+max_next_price);         return false;     }     }     return true;     }     }    function placebid(url){     var bid_type = $$('input:checked[type="radio"][name="bid_type"]').pluck('value');     var is_valid_bidprice = checkbidprice();     if(is_valid_bidprice == false)     return;     var bid_price = $('bid_price').value;      var product_id = $('auction_product_id').value;     if(bid_price <= 0){     return;     }     if (url.indexof('?') == -1)     url += '?bid_price=' + bid_price;     else     url += '&bid_price=' + bid_price;     url += '&product_id=' + product_id;     url += '&bid_type=' + bid_type;     $('auction_bid_button').hide();     $('auction_bid_waitting').show();     $('msg_error').innerhtml = '';     $('msg_success').innerhtml ='';     $('msg_error').hide();     $('msg_success').hide();     $('is_bidding').value = '1';     var auctionid = $('auction_id').value;     new ajax.updater('results_bid_after_'+auctionid,url,{method: 'get', oncomplete:function(){autionbidcomplete();} ,onfailure: ""});  }  function updateauctioncomplete(){     var auctionid;     if ($('result_auction_reset')!= null){     location.reload(true);     }     if($('result_auction_id') != null)     auctionid = $('result_auction_id').innerhtml;     if($('result_price_condition_'+auctionid)!=null)     $('price_condition_'+auctionid).innerhtml = $('result_price_condition_'+auctionid).innerhtml;     if($('notice_error')!=null){     $('msg_error').innerhtml = $('notice_error').value;     if($('notice_error').value != '')     $('msg_error').show();     else     $('msg_error').hide();     } else {     $('msg_error').innerhtml='';     $('msg_error').hide();     }     if($('notice_success')!=null){     $('msg_success').innerhtml = $('notice_success').value;     if($('notice_success').value != '')     $('msg_success').show();     else     $('msg_success').hide();     } else {     $('msg_success').innerhtml = '';     $('msg_success').hide();     }     if($('result_current_bid_id_'+auctionid)!=null)     $('current_bid_id_'+auctionid).value = $('result_current_bid_id_'+auctionid).innerhtml;     if($('result_auction_end_time_'+auctionid) != null)     $('auction_end_time_'+auctionid).value = $('result_auction_end_time_'+auctionid).innerhtml;     if($('result_auction_now_time_'+auctionid) != null)     $('auction_now_time_'+auctionid).value = $('result_auction_now_time_'+auctionid).innerhtml;     if($('result_auction_info_'+auctionid)!=null){     $('auction_info_'+auctionid).innerhtml = $('result_auction_info_'+auctionid).innerhtml;     $('result_auction_info_'+auctionid).innerhtml = '';     }     }       function autionbidcomplete(){     $('auction_bid_button').show();     $('auction_bid_waitting').hide();     updateauctioncomplete();     updateauctioninfo();     $('is_bidding').value = '0';     }        function validnumeric(inputtext){     var text = inputtext.value;     if (isnan(text)) {                 alert('bid in wrong format');             }     }       function updateauctioninfo()     {        var url = document.getelementbyid('updateurl').value;        var value = document.getelementbyid('auction_id').value;          new ajax.request(url,                 {                 method: 'post',                 parameters: {auction_id:value },                  onsuccess: function(data) {                     response = data.responsetext.evaljson(true);                      //var info = document.getelementbyid('auction_info');                      $('auction_info').update(response.updated);                      $('auction_info').innerhtml;                    // info.innerhtml = update_auction_info;                  },                 onfailure: function(response){                 alert("url not exixts");                 }                 });      }      function checkupdateauctioninfo(url)     {           if($('current_bidder_id')!=null)         {         var current_bidder_id = document.getelementbyid('current_bidder_id').value;         var value = document.getelementbyid('auction_id').value;         new ajax.request(url,                 {                 method: 'post',                 parameters: {auction_id:value , bidder_id:current_bidder_id  },                  onsuccess: function(data) {                   responses = data.responsetext.evaljson(true);                  (i = 0; < responses.length; i++) {                  response = responses[i];                  document.getelementbyid('countdown_'+response.id).innerhtml = response.timer;                      if(response.winner && !response.currentwinner)                     {                        $('auction_bid_button'+response.product).hide();                       $('buy'+response.product).update(response.remplacementbutton);                      $('buy'+response.product).innerhtml;                      }                     if(response.currentwinner)                     {                         $('auction_bid_button'+response.product).hide();                      $('buy'+response.product).update(response.currentwinnerbuy);                      $('buy'+response.product).innerhtml;                     }                     if(response.currenthigh && !response.currentwinner && !response.winner)                     { //alert(response.product);                      $('auction_bid_button'+response.product).hide();                       $('buy'+response.product).update(response.currenthightext);                      $('buy'+response.product).innerhtml;                      $('buy'+response.product).show();                      }else if(!response.currenthigh && !response.currentwinner && !response.winner)                     {                      $('auction_bid_button'+response.product).show();                      $('buy'+response.product).hide();                      }                     if(response.updated )                      {                      $('current_price').update(response.bid_price);                      $('bidder').update(response.name);                     $('current_price').innerhtml;                      $('bidder').innerhtml;                       }                     // if(response.autobiddelete)                     // {                     //     $('auction_bid_auto_button_stop'+response.product).hide();                     //     $('auction_bid_auto_button_start'+response.product).show();                     //     $('bid_auto_number').setvalue(15);                     // }                     //  if(response.autobid && response.currenthigh)                    // {                      //   var num_bid = $('bid_auto_number').setvalue(response.numbid);                     // }                    if(response.totalbid!=$('totalbids').innerhtml)                    {                     $('totalbids').update(response.totalbid);                     $('totalbids').innerhtml;                    }                    if(response.totalautobid)                    {    var num_bid = $('bid_auto_number').setvalue(response.totalautobid);                          $('auto-bid-notification').setvalue(1);                     }else {                       if($('auto-bid-notification').value==1 &&  $('auction_bid_auto_button_stop'+response.product).visible()) {                           $('auction_bid_auto_button_stop'+response.product).hide();                          $('auction_bid_auto_button_start'+response.product).show();                          $('bid_auto_number').setvalue(15);                          $('auto-bid-notification').setvalue(0);                          }                    }                      if(response.bidder)                    {                     $('current_bidder_id').setvalue(response.bidder);                     $('bidder').style.backgroundcolor = "red";                      htm='<tr class="row"><td>'+response.name+'</td><td>'+response.bid_price+'</td></tr>';                      htmcheck='<td>'+response.name+'</td><td>'+response.bid_price+'</td>';                var count = document.getelementbyid("hisotry_item_list").getelementsbytagname("tr").length;                         olderhtml=$('hisotry_item_list').innerhtml;                      var table=document.getelementbyid("hisotry_item_list");                 var updt=true;                 var r=0;                 var i=1;                 while(row=table.rows[r++])                 {                           if(row.innerhtml==htmcheck){                          var updt=false;                       }                   var i=i+1;                   }                         if(updt){                      $('hisotry_item_list').update(htm+olderhtml);                      $('hisotry_item_list').innerhtml;                       if(i==9) {                     $$('#hisotry_item_list tr').last('tr').remove();                     }                          }                     // if(count==8) {                     // $$('#hisotry_item_list tr').last('tr').remove();                     // }                      //   olderhtml=$('hisotry_item_list').innerhtml;                     //  $('hisotry_item_list').update(htm+olderhtml);                                        }else {                     $('bidder').style.backgroundcolor='#fff';                    }                    //console.clear();                  }                   },                 onfailure: function(response){                 //alert("url not exixts");                 //console.clear();                 }                 });         // var request = jquery.ajax({         //       url: url,         //       method: "post",         //       data: { auction_id:value , bidder_id:current_bidder_id },         //       datatype: "json"         //     });         // request.done(function( msg ) {           // });         }     }     function checkupdateauctioninfolist(url)     {            var value = document.getelementbyid('auction_id').value;         //console.clear();         new ajax.request(url,                 {                 method: 'post',                 parameters: {auction_id:value   },                 oncreate: function() {                      //console.clear();                 },                  onsuccess: function(data) {                  allresponses = data.responsetext.evaljson(true);                   (i = 0; < allresponses.length; i++) {                   response = allresponses[i];                  document.getelementbyid('countdown_'+response.id).innerhtml = response.timer;                      if(response.winner && !response.currentwinner)                     {                        $('auction_bid_button'+response.product).hide();                       $('buy'+response.product).update(response.remplacementbutton);                      $('buy'+response.product).innerhtml;                      }                     if(response.currentwinner)                     {                         $('auction_bid_button'+response.product).hide();                      $('buy'+response.product).update(response.currentwinnerbuy);                      $('buy'+response.product).innerhtml;                     }                     if(response.currenthigh && !response.currentwinner && !response.winner)                     { //alert(response.product);                      $('auction_bid_button'+response.product).hide();                       $('buy'+response.product).update(response.currenthightext);                      $('buy'+response.product).innerhtml;                      $('buy'+response.product).show();                      }else if(!response.currenthigh && !response.currentwinner && !response.winner)                     {                      $('auction_bid_button'+response.product).show();                      $('buy'+response.product).hide();                      }                     if(response.updated)                      {                         if(response.bid_price!=""){                     $('current_price_'+response.id).update(response.bid_price);                     $('current_price_'+response.id).innerhtml;                          }                      $('bidder_'+response.id).update(response.name);                      $('bidder_'+response.id).innerhtml;                       }                    //console.clear();                  } },                 onfailure: function(response){                  console.clear();                 }                 });       }     function toggledisabled(el) {         try {             el.disabled = el.disabled ? false : true;         }         catch(e){         }         if (el.childnodes && el.childnodes.length > 0) {         (var x = 0; x < el.childnodes.length; x++) {         toggledisabled(el.childnodes[x]);         }         }     }      function auctioncompleteshow(id)     {              document.getelementbyid('countdown_'+id).innerhtml = 'sold';             document.getelementbyid('bid-box').hide();             document.getelementbyid('auction_watcher').hide();             toggledisabled(document.getelementbyid('bid-box'));             toggledisabled(document.getelementbyid('auction_watcher'));             document.getelementbyid('watcher_url').removeattribute('href');       }     function callthetimers(distance,id)     {          var _second = 1000;         var _minute = _second * 60;         var _hour = _minute * 60;         var _day = _hour * 24;         if (distance < 0) {              if (distance>-3)                  {                     location.reload(true);                      return;                 };               document.getelementbyid('countdown_'+id).innerhtml = 'sold';             document.getelementbyid('bid-box').hide();              return;         }         var days = math.floor(distance / _day);         var hours = math.floor((distance % _day) / _hour);         var minutes = math.floor((distance % _hour) / _minute);         var seconds = math.floor((distance % _minute) / _second);          if (days <10)             {days = '0' + days;}         if (hours <10)             {hours = '0' + hours;}         if (minutes < 10)            { minutes = '0' + minutes;}         if (seconds < 10)             {seconds = '0' + seconds; }         if(days==00)         {                         dytext = '';             }         else if(days==1)         {             dytext = '<span class="countdown-text">'+ days +' day  </span>';            }         else         {              dytext = '<span class="countdown-text">'+ days +' days  </span>';             }         if(hours==00) {             hrtext='';         }         else {             hrtext = '<span class="countdown-text">'+ hours + '</span>'+ ":";         }         if(minutes==00)         {             mintext=''; 


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -