Jquery Daily Timer Failing -


I am using this jQuery code to display locally up to 10am on the left.

It removes some images between 10am and 14:00

Then after 14:00 it should spend time till 10:00. It adds the offset to the account for the weekend too

It works brilliantly at the most time, although after 14:00 it seems that this route goes along. .

Can anyone see why this is unsuccessful, I am looking for it for a long time ... now I am just confused! help please!

  $ (document) .ready (function () {// 24 hour based var targetTime = 1000; var targetHour = 10; var openingTime = 1400; var openingHour = 14; var CurrentTime = new Date (); // Sun 0 Mon 1 ... Venus 5 Saturn 6 var Current day = Current time .getDay (); var offset = 24; // if Friday (current del === 5) {offset = 60;} // Saturdays and if (current day === 6) {offset = 48;} var the_current_time = '' + current time.gethors () + '' + current time.get minute () + ''; if (the_current_time & Gt; Target Time & amp;; Amp; the_current_time & lt; opening time) {var time_hours = (opening + offset) - Works The time is in the time. Gatehors () - 1; var Time_min = 60 - the current time.GetMinets (); var time_second = 60 - the current time.gatessecond (); $ ('#', 'time', 'time', 'time' , 'Time', 'time', 'time', 'time', 'time', 'time' and '#watch_image') .attr ('src', 'http: //cdn.shopify.com/s/ Files ('width', '275px'); $ ('# time-left-banner'); $ (' Button to add ') CSS (' display ',' none '). . $ ('# Purchase') CSS ('display', 'any'); } And if (the_current_time & gt; target time & amp; amp; the_current_time & gt; opening time) {var time_hours = (target = offsets) - current time.gethors () - 1; Var Time_min = 60 - present timeGetWind (); Var time_second = 60 - present time.gatessecond (); $ ('# Hours_left'). Add (time_range, ':', time_mill and lieutenant; 10? "0": "", periodically, ':', time-seconds 10; "0": "", Time_second); } And {var time_hours = (targetHour + offset) - current time.gethors () - 1; Var Time_min = 60 - present timeGetWind (); Var time_second = 60 - present time.gatessecond (); $ ('# Hours_left'). Add (time_range, ':', time_mill and lieutenant; 10? "0": "", periodically, ':', time-seconds 10; "0": "", Time_second); }   

});

First of all, I code a little bit of three in three branches, var Is similar. Then there is an update to #hours_left you should be able to face them out of if , the number of branches will be reduced from 3 to 1 - if I do not remember anything .

For the problem, I'll look at the_current_time . You are not padding for minutes, so 10:05 will be 105 or 1:05. I can not see why this will be the reason for any play, because the calculation does not depend on this value, but if you change that branch you will take.


Ah, I have the difference in the first branch of of if it is the difference of target_hours Opening_hours . It explains why a bad the_current_time will make a difference to the reported value.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -