Advertisement
plirof2

breaktimes-dialeimmata

Sep 13th, 2022 (edited)
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <header>
  3. <!--
  4. 220914 - fixed weeknmber
  5.  
  6. ToDo :
  7. - Use a For Loop for showing break times
  8. - Make a table according to day number that displays class/room
  9. -->
  10. <meta charset="utf-8" />
  11. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  12. <META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">
  13. </header>
  14.  
  15. <body>
  16.  
  17. <div id="result" name="result" ></div>
  18.  
  19. <script type="text/javascript">
  20.    
  21. var normal_program=true; // Toggle this if we have secondary program   
  22.  
  23. var weeknumber=37;
  24.  
  25. function getWeekNumber(){
  26.     currentdate = new Date();
  27.     var oneJan = new Date(currentdate.getFullYear(),0,1);
  28.     var numberOfDays = Math.floor((currentdate - oneJan) / (24 * 60 * 60 * 1000));
  29.     //var result = Math.ceil(( currentdate.getDay() + 1 + numberOfDays) / 7);//orig
  30.     var result = Math.ceil(( currentdate.getDay()  + numberOfDays) / 7);
  31.     console.log(`The week number of the current date (${currentdate}) is ${result}.`);
  32.     return result;
  33. }
  34.  
  35. weeknumber=getWeekNumber();
  36.  
  37. //check if the number is even
  38. if(weeknumber % 2 == 0) {
  39.     console.log("The number is zygos.");
  40.     normal_program=true;
  41. }
  42. // if the number is odd
  43. else {
  44.     console.log("The number is monos.");
  45.     normal_program=false;
  46. }
  47. console.log("Current program flag (odd-even check) : "+normal_program+" weeknumber ="+weeknumber);
  48.    
  49. const class_times=[
  50.  
  51. "<B>8:15-9</B> no break",
  52. "<B>9-9:40</B>",
  53. "<B>10-10:45</B> no break",
  54. "<B>10:45-11:30</B>",
  55. "<B>11:55-12:35</B> no break",
  56. "<B>12:35-13:15</B>"
  57. ];
  58.  
  59. const class_times_int=[
  60. "<B>8:15-9</B>",
  61. "<B>9:15-10</B> no break",
  62. "<B>10-10:45</B>",
  63. "<B>11-11:45</B> no break",
  64. "<B>11:45-12:25</B>",
  65. "<B>12:35-13:15</B>",
  66. ];
  67.  
  68.  
  69. const break_times=[
  70. "(2h/3h) 9:40-10:00",
  71. "(4h/5h) 11:30-11:55"
  72. ];
  73.  
  74.  
  75. const break_times_int=[
  76. "(1h/2h) 9:00-9:15",
  77. "(3h/4h) 10:45-11:00",
  78. "(5h/6h) 12:25-12:35",
  79. ];
  80.  
  81. const classroom= [
  82.   ["-","-","-","-","Δ2","Δ1","-"],  //monday [1][5]
  83.   ["-","-","-","-","Δ2","Δ1","-"],  //thusday  21dim
  84.   ["-","-","Γ2 -13","Α1","ΣΤ1 -16","ΣΤ2 -20","-"],  //Tetarti
  85.   ["-","-","Α2","Β2 -25","Γ1 -15","Ε2 -","ΟΛΟΗΜΕΡΟ"],  //
  86.   ["-","-","-","Β1 -","-","Ε1 -","-"]  //ΠΑΡΑΣΚ
  87. ];
  88. console.log(classroom[0][0]); //
  89.  
  90.  
  91. //each thuessday is toggled program
  92. var now = new Date();
  93. //             0         1       2          3         4          5          6
  94. var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  95.  
  96. var day = days[ now.getDay() ];
  97.  
  98. var div = document.getElementById('result');
  99.  
  100. console.log(day);
  101.  
  102.  
  103. function createProgramString(current_program){
  104.     var result="";
  105.     var line_seperator="\n<TR><TD>";
  106.     console.log("\n_______ DAY : "+day);
  107.     for(var hour = 1; hour < current_program.length+1; hour++) {
  108.         //var current_day_program = current_program[i];
  109.         //for(var j = 0; j < current_program.length; j++) {
  110.         //result+=(line_seperator+"current_program[" + hour + "] = " + current_program[hour-1] + classroom[now.getDay()-1 ][hour-1]);
  111.         result+=(line_seperator+hour+") "+ "</TD><TD><h1>"+ current_program[hour-1] + "</TD><TD><h1>"+classroom[now.getDay()-1 ][hour-1] +"</TD></TR>");
  112.         //}
  113.     }
  114.    
  115.     console.log(current_program.join("<BR>"+current_program.length+"||"));
  116.    
  117.     console.log("\n_______ createProgramString : "+result);
  118.     return result;
  119.    
  120. }
  121.  
  122.  
  123. function checkTime(){
  124.     console.log("Current program flag : "+normal_program +" , getDay()="+now.getDay());
  125.     if(now.getDay()==2) {
  126.         normal_program = !normal_program; //toogle program variable (if its triti)
  127.         div.innerHTML += 'Day =2 '+normal_program;
  128.        
  129.     }
  130.    
  131.     /*
  132.     for(var i = 0; i < cubes.length; i++) {
  133.     var cube = cubes[i];
  134.     for(var j = 0; j < cube.length; j++) {
  135.         display("cube[" + i + "][" + j + "] = " + cube[j]);
  136.     }
  137.     }
  138.    
  139.     */
  140.    
  141.     console.log("Current program flag (after : "+normal_program);
  142.     if(normal_program){
  143.         //div.innerHTML +="<BR>"
  144.         //div.innerHTML ="<BR><h1><B>LESSONS</B><BR>"+class_times.join("<BR>");
  145.        
  146.         console.log("============Normal_program : "+normal_program);
  147.         div.innerHTML ="<BR><h1><B>LESSONS</B><BR><TABLE border=1>"+createProgramString(class_times);
  148.         div.innerHTML +="</TABLE><BR><B>BREAKS</B><BR>"+break_times.join("<BR>");
  149.        
  150.     }else {
  151.         //div.innerHTML ="<BR><h1><B>LESSONS</B><BR>"+class_times_int.join("<BR>");
  152.        
  153.         console.log("============NOT Normal_program : "+normal_program);
  154.         div.innerHTML ="<BR><h1><B>LESSONS</B><BR><TABLE border=1>"+createProgramString(class_times_int);
  155.         div.innerHTML +="</TABLE><BR><B>BREAKS</B><BR>"+break_times_int.join("<BR>");
  156.     }
  157.        
  158.    
  159.    
  160.    
  161.    
  162. }
  163.  
  164.  
  165. checkTime();
  166. //var t=setInterval(checkTime,1000);
  167. //clearInterval(t);
  168.  
  169.  
  170.  
  171.  
  172. //div.innerHTML += 'Extra stuff';
  173.  
  174. </script>
  175.  
  176.  
  177. <!--
  178. //ORIGINAL
  179. const class_times=[
  180.  
  181. "1. 8:15-9 no break",
  182. "2. 9-9:40",
  183. "3. 10-10:45 no break",
  184. "4. 10:45-11:30",
  185. "5. 11:55-12:35 no break",
  186. "6. 12:35-13:15"
  187. ];
  188.  
  189. const class_times_int=[
  190. "1. 8:15-9",
  191. "2. 9:15-10 no break",
  192. "3. 10-10:45",
  193. "4. 11-11:45 no break",
  194. "5. 11:45-12:25",
  195. "6. 12:35-13:15",
  196. ];
  197.  
  198.  
  199. const break_times=[
  200. "(2h/3h) 9:40-10:00",
  201. "(4h/5h) 11:30-11:55"
  202. ];
  203.  
  204.  
  205. const break_times_int=[
  206. "(1h/2h) 9:00-9:15",
  207. "(3h/4h) 10:45-11:00",
  208. "(5h/6h) 12:25-12:35",
  209. ];
  210. -->
  211.  
  212.  
  213. </body>
  214.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement