473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to highlight the second time reference in my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. var img = new Image();
  3.  
  4. var now = new Date();
  5. var weekday = new Array(7);
  6. weekday[0] = "Sunday";      //9:00 am - 11:00 pm  
  7. weekday[1] = "Monday";      //11:00 am - 11:00 pm
  8. weekday[2] = "Tuesday";     //11:00 am - 11:00 pm
  9. weekday[3] = "Wednesday";   //11:00 am - 11:00 pm
  10. weekday[4] = "Thursday";    //11:00 am - 11:00 pm
  11. weekday[5] = "Friday";      //9:00 am - 12:00 am 
  12. weekday[6] = "Saturday";    //9:00 am - 12:00 am    
  13.  
  14. var checkTime6 = function() {
  15.   var today = weekday[now.getDay()];
  16.   var timeDiv6 = document.getElementById('timeDiv6');
  17.   var dayOfWeek = now.getDay();
  18.   var hour = now.getHours();
  19.   var minutes = now.getMinutes();
  20.  
  21.   //add AM or PM
  22.   var suffix = hour >= 12 ? "PM" : "AM";
  23.  
  24.   // add 0 to one digit minutes
  25.   if (minutes < 10) {
  26.     minutes = "0" + minutes
  27.   };
  28.  
  29.   if ((dayOfWeek == 0 || dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4) && hour >= 9 && hour <= 22) {
  30.     hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15
  31.     timeDiv6.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br/><center><img style="width:150px;top:0px;border-radius:10px;" src="'+img.src+'" />';
  32.     timeDiv6.className = 'open';
  33.     img.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOn.gif';
  34.   } 
  35.  
  36.   else if ((dayOfWeek == 5 || dayOfWeek == 6) && hour >= 9 && hour <= 23) {
  37.     hour = ((hour + 11) % 12 + 1);
  38.     timeDiv6.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br/><center><img style="width:150px;top:0px;border-radius:10px;" src="'+img.src+'" /></center>';
  39.     timeDiv6.className = 'open';
  40.     img.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOn.gif';
  41.   } 
  42.  
  43.   else {
  44.     if (hour == 0 || hour > 9) {
  45.       hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15
  46.     }
  47.     timeDiv6.innerHTML = 'It\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br/><center><img style="width:150px;top:0px;border-radius:10px;" src="'+img.src+'" /></center>' ;
  48.     timeDiv6.className = 'closed';
  49.     img.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOff.png';
  50.   }
  51. };
  52.  
  53. setInterval(checkTime6, 1000);
  54. checkTime6();
  55.  
  56.  
  57. var checkTime31 = function() {
  58.   var today = weekday[now.getDay()];
  59.   var timeDiv = document.getElementById('timeDiv31');
  60.   var dayOfWeek = now.getDay();
  61.   var hour = now.getHours();
  62.   var minutes = now.getMinutes();
  63.  
  64.   //add AM or PM
  65.   var suffix = hour >= 12 ? "PM" : "AM";
  66.  
  67.   // add 0 to one digit minutes
  68.   if (minutes < 10) {
  69.     minutes = "0" + minutes
  70.   };
  71.  
  72.   if ((dayOfWeek == 1 ||  dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 5) && hour >= 9 && hour <= 23) {
  73.     hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15
  74.     timeDiv31.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br/><center><img style="width:150px;top:0px;border-radius:10px;" src="'+img.src+'" />';
  75.     timeDiv31.className = 'open';
  76.     img.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOn.gif';
  77.   } 
  78.  
  79.   else if ((dayOfWeek == 0 || dayOfWeek == 6) && hour >= 9 && hour <= 1) {
  80.     hour = ((hour + 11) % 12 + 1);
  81.     timeDiv31.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br/><center><img style="width:150px;top:0px;border-radius:10px;" src="'+img.src+'" /></center>';
  82.     timeDiv31.className = 'open';
  83.     img.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOn.gif';
  84.   } 
  85.  
  86.   else {
  87.     if (hour == 0 || hour > 9) {
  88.       hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15
  89.     }
  90.     timeDiv31.innerHTML = 'It\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br/><center><img style="width:150px;top:0px;border-radius:10px;" src="'+img.src+'" /></center>' ;
  91.     timeDiv31.className = 'closed';
  92.     img.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOff.png';
  93.   }
  94. };
  95.  
  96.  
  97.  
  98. setInterval(checkTime31, 1000);
  99. checkTime31();
  100.  
  101.  
  102. var currentDay = weekday[now.getDay()];
  103. var currentDayID = "#" + currentDay; //gets todays weekday and turns it into id
  104. $(currentDayID).toggleClass("today"); //hightlights today in the view hours modal popup
  105.  
  106.  
Expand|Select|Wrap|Line Numbers
  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
  2. <div class="timebox1"  >
  3.   <div id="timeDiv6"></div>
  4.   <label class="viewOpen6" for="modal-state6">View Hours&nbsp;&nbsp;<i class="fa fa-clock-o"></i></label>
  5.   <input type="checkbox" name="modal-state6" id="modal-state6">
  6.   <div class="modal-overlay6">
  7.     <label for="modal-state6" class="modal-overlay-close6"></label>
  8.  
  9.    <div class="modaltime6">
  10.       <label class="button-close6" for="modal-state6"><i class="fa fa-times"></i></label>
  11.       <h2>We're Open At These Times</h2>
  12.       <div id="Monday" class="dateTime">
  13.         <div class="day">Monday</div>
  14.         <div class="time">11am - 11pm</div>
  15.       </div>
  16.       <br>
  17.       <div id="Tuesday" class="dateTime">
  18.         <div class="day">Tuesday</div>
  19.         <div class="time">11am - 11pm</div>
  20.       </div>
  21.       <br>
  22.       <div id="Wednesday" class="dateTime">
  23.         <div class="day">Wednesday</div>
  24.         <div class="time">11am - 11pm</div>
  25.       </div>
  26.       <br>
  27.       <div id="Thursday" class="dateTime">
  28.         <div class="day">Thursday</div>
  29.         <div class="time">11am - 11pm</div>
  30.       </div>
  31.       <br>
  32.       <div id="Friday" class="dateTime">
  33.         <div class="day">Friday</div>
  34.         <div class="time">9am - 12am</div>
  35.       </div>
  36.       <br>
  37.       <div id="Saturday" class="dateTime">
  38.         <div class="day">Saturday</div>
  39.         <div class="time">9am - 12am</div>
  40.       </div>
  41.       <br>
  42.       <div id="Sunday" class="dateTime">
  43.         <div class="day">Sunday</div>
  44.         <div class="time">9am - 11pm</div>
  45.       </div>
  46.  
  47.  
  48.     </div>
  49.   </div>
  50. </div>
  51.  
  52. <div class="timebox2"  >
  53.   <div id="timeDiv31"></div>
  54.   <label class="viewOpen31" for="modal-state31">View Hours&nbsp;&nbsp;<i class="fa fa-clock-o"></i></label>
  55.   <input type="checkbox" name="modal-state31" id="modal-state31">
  56.   <div class="modal-overlay31">
  57.     <label for="modal-state31" class="modal-overlay-close31"></label>
  58.  
  59.    <div class="modaltime31">
  60.       <label class="button-close31" for="modal-state31"><i class="fa fa-times"></i></label>
  61.       <h2>We're Open At These Times</h2>
  62.       <div id="Monday" class="dateTime">
  63.         <div class="day">Monday</div>
  64.         <div class="time">9am - 12am</div>
  65.       </div>
  66.       <br>
  67.       <div id="Tuesday" class="dateTime">
  68.         <div class="day">Tuesday</div>
  69.         <div class="time">9am - 12am</div>
  70.       </div>
  71.       <br>
  72.       <div id="Wednesday" class="dateTime">
  73.         <div class="day">Wednesday</div>
  74.         <div class="time">9am - 12am</div>
  75.       </div>
  76.       <br>
  77.       <div id="Thursday" class="dateTime">
  78.         <div class="day">Thursday</div>
  79.         <div class="time">9am - 12am</div>
  80.       </div>
  81.       <br>
  82.       <div id="Friday" class="dateTime">
  83.         <div class="day">Friday</div>
  84.         <div class="time">9am - 12am</div>
  85.       </div>
  86.       <br>
  87.       <div id="Saturday" class="dateTime">
  88.         <div class="day">Saturday</div>
  89.         <div class="time">9am - 1am</div>
  90.       </div>
  91.       <br>
  92.       <div id="Sunday" class="dateTime">
  93.         <div class="day">Sunday</div>
  94.         <div class="time">9am - 1am</div>
  95.       </div>
  96.  
  97.  
  98.     </div>
  99.   </div>
  100. </div>
  101.  
Expand|Select|Wrap|Line Numbers
  1. /*timee*/
  2.  
  3. .timebox1{
  4.     position:fixed;
  5.     display:block;
  6.     padding:0px;
  7.     top:10px;
  8.     left:10px;
  9. }
  10.  
  11. .timebox2{
  12.     position:fixed;
  13.     display:block;
  14.     padding:0px;
  15.     top:10px;
  16.     right:10px;
  17. }
  18.  
  19. .open {
  20.   color: #27ae60;
  21.   /*border: 2px solid #27ae60;*/
  22. }
  23.  
  24.  
  25.  
  26. .closed {
  27.  
  28.   color: rgba(231, 76, 60, 0.85);
  29.  /*border: 2px solid rgba(231, 76, 60, 0.8);*/
  30. }
  31.  
  32. * {
  33.   margin: 0;
  34.   padding: 0;
  35.   font-family: 'Lato', sans-serif;
  36. }
  37.  
  38.  
  39. #timeDiv6, #timeDiv31{
  40.   font-size: 15px;
  41.   text-transform: uppercase;
  42.   text-align: center;
  43.   position:static;
  44.   width: 100%;
  45.   background: transparent;
  46.   margin: 0 auto;
  47.   top: 10px;
  48.   border-radius: 3px;
  49.  /* -webkit-box-shadow: 0 8px 16px -8px #adadad;
  50.   -moz-box-shadow: 0 8px 16px -8px #adadad;
  51.   box-shadow: 0 8px 16px -8px #adadad;*/
  52.   display:block;
  53.   vertical-align: top;
  54.   font-weight: 600;
  55.   background-color: rgb(0,0,0); /* Fallback color */
  56.     background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63. .viewOpen6, .viewOpen31 {
  64.   font-size: 15px;
  65.   text-transform: uppercase;
  66.   display:block;
  67.   border: 2px solid rgba(70, 70, 70, 0.7);
  68.   max-width: 100%;
  69.   background: #fff;
  70.   color: rgba(70, 70, 70, 0.8);
  71.   margin: 0 auto;
  72.   top:160px;
  73.   padding: 10px;
  74.   border-radius: 3px;
  75.   -webkit-box-shadow: 0 8px 16px -8px #adadad;
  76.   -moz-box-shadow: 0 8px 16px -8px #adadad;
  77.   box-shadow: 0 8px 16px -8px #adadad;
  78.   cursor: pointer;
  79.     border:blue solid 1px;
  80.     position:static;
  81.  
  82. }
  83.  
  84. .viewOpen6 i, .viewOpen31 i {
  85.   color: rgba(70, 70, 70, 0.8);
  86. }
  87.  
  88. @media all and (max-width: 600px) {
  89.   #timeDiv6, #timeDiv31{
  90.     margin-bottom: 20px;
  91.   }
  92. }
  93.  
  94. @media all and (min-width: 601px) {
  95.   #timeDiv6, #timeDiv31 {
  96.     margin-right: 15px;
  97.   }
  98.  
  99.  
  100. }
  101.  
  102. .dateTime  {
  103.   max-width: 320px;
  104.   margin: 0 auto;
  105. }
  106.  
  107. .day {
  108.   display: inline-block;
  109.   float: left;
  110. }
  111.  
  112. .time {
  113.   display: inline-block;
  114.   float: right
  115. }
  116.  
  117. .today {
  118.   color: rgb(200, 85, 39);
  119.   font-weight: 600;
  120. }
  121.  
  122. @media all and (max-height: 420px) {
  123.   #timeDiv6, .viewOpen6,
  124.   #timeDiv31, .viewOpen31
  125.   {
  126.     top: 60%;
  127.   }
  128. }
  129. /* view hours modal */
  130.  
  131. @keyframes fade-in {
  132.   0% {
  133.     opacity: 0;
  134.   }
  135.   100% {
  136.     opacity: 1;
  137.   }
  138. }
  139.  
  140. .modal-overlay6, .modal-overlay31{
  141.   position: fixed;
  142.   top: 0;
  143.   left: 0;
  144.   right: 0;
  145.   bottom: 0;
  146.   background-color: rgba(173, 173, 173, 0.5);
  147.   display: none;
  148.   z-index:999;
  149. }
  150.  
  151. #modal-state6, #modal-state31 {
  152.   display: none;
  153. }
  154.  
  155. #modal-state6:checked + .modal-overlay6, 
  156. #modal-state31:checked + .modal-overlay31
  157.  {
  158.   opacity: 1;
  159.   animation: fade-in .4s;
  160.   display: block;
  161. }
  162.  
  163. .modaltime6, .modaltime31{
  164.   position: absolute;
  165.   margin: 0 auto;
  166.   padding: 30px 25px;
  167.   background: #fff;
  168.   right: 0;
  169.   left: 0;
  170.   text-align: center;
  171.   box-shadow: 0px 12px 24px rgba(0, 0, 0, 0.2);
  172.   max-width: 400px;
  173.   line-height: 1.8;
  174.     border:red solid 1px;
  175. }
  176.  
  177.  
  178.  
  179. .modaltime6 h2, .modaltime31 h2 {
  180.   margin-top: 0;
  181.   line-height: 25px;
  182.   font-size: 22px;
  183.   border-bottom: 1px solid #dce0d8;
  184.   margin-bottom: 10px;
  185.   padding-bottom: 10px;
  186.   font-weight: 400;
  187. }
  188.  
  189. @media all and (max-width: 470px) {
  190.   .modaltime6 {
  191.     width: 75%;
  192.   }
  193.   .modaltime6 h2{
  194.     font-size: 20px;
  195.   }
  196.  
  197.  
  198.   .modaltime31 {
  199.     width: 75%;
  200.   }
  201.   .modaltime31 h2{
  202.     font-size: 20px;
  203.   }
  204.  
  205.  
  206.  
  207. }
  208.  
  209. #modal-state6:checked + .modal-overlay6 .modaltime6, 
  210. #modal-state31:checked + .modal-overlay31 .modaltime31
  211. {
  212.   top: 20%;
  213. }
  214.  
  215. .modal-overlay-close6, .modal-overlay-close31 {
  216.   height: 100%;
  217.   width: 100%;
  218.   position: absolute;
  219.   left: 0;
  220.   top: 0;
  221. }
  222.  
  223. .button-close6, .button-close31 {
  224.   text-decoration: none;
  225.   position: absolute;
  226.   color: #fff;
  227.   background: #464646;
  228.   padding: 0px 7px;
  229.   font-weight: bold;
  230.   top: 0px;
  231.   right: 0;
  232.   cursor: pointer
  233. }
  234. /*time end*/
its only highlighting my first code not second in "var currentDay" also it goes from modeltime 1-40 so the could should get passed the other models and plus
Jan 6 '17 #1
1 1110
chaarmann
785 Expert 512MB
Your code is Javascript. But you are in the Java forum. Please move your question.
Jan 9 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Huahe | last post by:
I try to delete a file in a for each loop. My code checks if the file exists and if it does, it will delete the file and create a new file with the same name. The first time it works perfect, but...
2
by: info | last post by:
I am pasting in a recordset from access to an excel sheet via VBA successfully. Then my routine copies a range of cells and pastes them into another range, this works fine every other time it...
2
by: FrzzMan | last post by:
The first time I called this function, everything went well, but the second time I called it. An Exception thrown, do you know why? An unhandled exception of type 'System.IO.IOException' occurred...
0
by: Frank Schumacher | last post by:
.... i do a server roundtrip, my dynamical control set is broken. Here is the plot: I have a dynamical control with some dynamical buttons within. How many of these buttons are shown depends...
8
by: Rick Lederman | last post by:
I am using a PrintDocument and PrintDialog to print. The first time that I print it works, but when I try to print a second time without exiting the entire program I get an...
1
by: thulaseeram | last post by:
hi, i am using the following code for uploading <div id="iframe" name="iframe" style="width:850px; height:120px;"> <iframe name="attach_frame" id="attach_frame"...
7
by: Peter Laan | last post by:
Is there a simple way to encapsulate the functionality to redo a method call a second time in case a specific exception is thrown? We are sending commands to an external system and if the sessionId...
0
by: Med | last post by:
Hi, I have two dropDown lists ddlCars and ddlModels. ddlCars AutoPostBack="true" to populate the ddlModels when a car is selected. If the page is not valid (i.e. user left a mandatory textbox...
6
by: gobblegob | last post by:
Hi guys, I am playing a sound using MMC on a form that pops up. Ok here is the problem it plays fine the first time but when the form loads the second time it plays no sound. Private Sub...
2
by: david l smith | last post by:
Hi, The following code snippet works on page load (it displays an anchor link using document.write), works when the anchor is clicked on the first time, but does not work when the anchor link is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.