Re: [Proto-Scripty] help me with prototype ajax .. request are slow

2016-06-11 Thread Mahdi Farhat
i have sent you an email on 

wal**@wdstudio.com please reply


On Saturday, June 11, 2016 at 9:28:59 PM UTC+3, Walter Lee Davis wrote:
>
> I'm watching it in the Network pane of Safari Web Inspector. It's running 
> at a total duration of 1.464 ms, but a latency of 159.4 ms. So your server 
> is replying nearly instantly when it gets the request, but there's a lag 
> while the message travels to and fro. Overall, this is astoundingly fast. 
>
> What I have seen pages like this do, however, is only update to the server 
> every few minutes or more, and have the browser's JavaScript update the 
> tick tock countdown timer independently. Let the local time drift out of 
> synch with the server, then catch up each time the "heartbeat" connects 
> back to the server. I can't imagine that this will be as fast when there 
> are hundreds of visitors connecting at once, constantly pinging every 
> second. 
>
> Walter 
>
> > On Jun 11, 2016, at 1:07 PM, Mahdi Farhat  > wrote: 
> > 
> > please check li1510-169.members.linode.com 
> > 
> > On Saturday, June 11, 2016 at 5:52:02 PM UTC+3, Walter Lee Davis wrote: 
> > 
> > > On Jun 10, 2016, at 10:40 AM, Mahdi Farhat  
> wrote: 
> > > 
> > > i asked a developer to develop me a a penny auction script but the 
> request are slow , 300 ms on local machine and 600ms on server 
> > > can i know why?  can you help me? is the code not optimized? 
> > 
> > Where are you measuring these times? Is this how long the JavaScript 
> takes to execute, or how long the total 
> (request/response/calculating/updating page) cycle takes per request? There 
> are a lot of factors that can cause Ajax to take time, not many of them 
> come down to the programming within the page. 
> > 
> > Another question, how many requests are sent by the page? I have only 
> glanced over the code, but it may be sending a separate request per item on 
> the page, which could get very "chatty" and cause the server to bog down in 
> replying to the requests. Have you watched the page in the Developer Tools 
> part of your browser? Can you post a link to a sample page showing the 
> script in action? 
> > 
> > Walter 
> > 
> > > 
> > > 
> > >   
> > > 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 now = 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; // the hour ’0′ should 
> be ’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 now = new Date(now_time); 
> > >   
> > > // alert(now); 
> > > var distance = end - now; 
> > > 
> > > if (distance < 0) { 
> 

Re: [Proto-Scripty] help me with prototype ajax .. request are slow

2016-06-11 Thread Walter Lee Davis
I'm watching it in the Network pane of Safari Web Inspector. It's running at a 
total duration of 1.464 ms, but a latency of 159.4 ms. So your server is 
replying nearly instantly when it gets the request, but there's a lag while the 
message travels to and fro. Overall, this is astoundingly fast.

What I have seen pages like this do, however, is only update to the server 
every few minutes or more, and have the browser's JavaScript update the tick 
tock countdown timer independently. Let the local time drift out of synch with 
the server, then catch up each time the "heartbeat" connects back to the 
server. I can't imagine that this will be as fast when there are hundreds of 
visitors connecting at once, constantly pinging every second.

Walter

> On Jun 11, 2016, at 1:07 PM, Mahdi Farhat  wrote:
> 
> please check li1510-169.members.linode.com
> 
> On Saturday, June 11, 2016 at 5:52:02 PM UTC+3, Walter Lee Davis wrote:
> 
> > On Jun 10, 2016, at 10:40 AM, Mahdi Farhat  wrote: 
> > 
> > i asked a developer to develop me a a penny auction script but the request 
> > are slow , 300 ms on local machine and 600ms on server 
> > can i know why?  can you help me? is the code not optimized? 
> 
> Where are you measuring these times? Is this how long the JavaScript takes to 
> execute, or how long the total (request/response/calculating/updating page) 
> cycle takes per request? There are a lot of factors that can cause Ajax to 
> take time, not many of them come down to the programming within the page. 
> 
> Another question, how many requests are sent by the page? I have only glanced 
> over the code, but it may be sending a separate request per item on the page, 
> which could get very "chatty" and cause the server to bog down in replying to 
> the requests. Have you watched the page in the Developer Tools part of your 
> browser? Can you post a link to a sample page showing the script in action? 
> 
> Walter 
> 
> > 
> > 
> >   
> > 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 now = 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; // the hour ’0′ should be 
> > ’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 now = 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(); 
> >

Re: [Proto-Scripty] help me with prototype ajax .. request are slow

2016-06-11 Thread Mahdi Farhat
please check li1510-169.members.linode.com

On Saturday, June 11, 2016 at 5:52:02 PM UTC+3, Walter Lee Davis wrote:
>
>
> > On Jun 10, 2016, at 10:40 AM, Mahdi Farhat  > wrote: 
> > 
> > i asked a developer to develop me a a penny auction script but the 
> request are slow , 300 ms on local machine and 600ms on server 
> > can i know why?  can you help me? is the code not optimized? 
>
> Where are you measuring these times? Is this how long the JavaScript takes 
> to execute, or how long the total (request/response/calculating/updating 
> page) cycle takes per request? There are a lot of factors that can cause 
> Ajax to take time, not many of them come down to the programming within the 
> page. 
>
> Another question, how many requests are sent by the page? I have only 
> glanced over the code, but it may be sending a separate request per item on 
> the page, which could get very "chatty" and cause the server to bog down in 
> replying to the requests. Have you watched the page in the Developer Tools 
> part of your browser? Can you post a link to a sample page showing the 
> script in action? 
>
> Walter 
>
> > 
> > 
> >   
> > 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 now = 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; // the hour ’0′ should be 
> ’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 now = 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) 

Re: [Proto-Scripty] help me with prototype ajax .. request are slow

2016-06-11 Thread Walter Lee Davis

> On Jun 10, 2016, at 10:40 AM, Mahdi Farhat  wrote:
> 
> i asked a developer to develop me a a penny auction script but the request 
> are slow , 300 ms on local machine and 600ms on server
> can i know why?  can you help me? is the code not optimized? 

Where are you measuring these times? Is this how long the JavaScript takes to 
execute, or how long the total (request/response/calculating/updating page) 
cycle takes per request? There are a lot of factors that can cause Ajax to take 
time, not many of them come down to the programming within the page.

Another question, how many requests are sent by the page? I have only glanced 
over the code, but it may be sending a separate request per item on the page, 
which could get very "chatty" and cause the server to bog down in replying to 
the requests. Have you watched the page in the Developer Tools part of your 
browser? Can you post a link to a sample page showing the script in action?

Walter

> 
> 
>   
> 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 now = 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; // the hour ’0′ should be ’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 now = 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 = ''+ days +' Day  ';  
>  
> }
> else
> {
>  dytext = ''+ days +' Days  
> ';
> }
> if(hours==00) {
> hrtext='';
> }
> else {
> hrtext = ''+ hours + ''