Commit 6ea8fbd6b181d98229ddd4571dfc7d4cf7e1c697

Authored by Miguel Barão
1 parent 77962168
Exists in master and in 1 other branch dev

- progress bar under the menu shows the remaining time.

perguntations/__init__.py
@@ -32,7 +32,7 @@ proof of submission and for review. @@ -32,7 +32,7 @@ proof of submission and for review.
32 ''' 32 '''
33 33
34 APP_NAME = 'perguntations' 34 APP_NAME = 'perguntations'
35 -APP_VERSION = '2020.04.dev4' 35 +APP_VERSION = '2020.04.dev5'
36 APP_DESCRIPTION = __doc__ 36 APP_DESCRIPTION = __doc__
37 37
38 __author__ = 'Miguel Barão' 38 __author__ = 'Miguel Barão'
perguntations/templates/test.html
@@ -44,8 +44,12 @@ @@ -44,8 +44,12 @@
44 <!-- ===================================================================== --> 44 <!-- ===================================================================== -->
45 <body> 45 <body>
46 <!-- ===================================================================== --> 46 <!-- ===================================================================== -->
  47 +<div class="progress fixed-top" style="height: 60px; border-radius: 0px;">
  48 + <div class="progress-bar bg-secondary" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
  49 +</div>
47 50
48 <nav id="navbar" class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark"> 51 <nav id="navbar" class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark">
  52 +
49 <a class="navbar-brand" href="#"> 53 <a class="navbar-brand" href="#">
50 <img src="/static/logo_horizontal.png" height="30" alt=""> 54 <img src="/static/logo_horizontal.png" height="30" alt="">
51 </a> 55 </a>
@@ -62,6 +66,7 @@ @@ -62,6 +66,7 @@
62 <li class="nav-item"><h5> 66 <li class="nav-item"><h5>
63 <span class="navbar-text" id="clock"> --:-- </span> 67 <span class="navbar-text" id="clock"> --:-- </span>
64 </h5> 68 </h5>
  69 +
65 </li> 70 </li>
66 </ul> 71 </ul>
67 72
@@ -76,6 +81,7 @@ @@ -76,6 +81,7 @@
76 </li> 81 </li>
77 </ul> 82 </ul>
78 </div> 83 </div>
  84 +
79 </nav> 85 </nav>
80 86
81 <!-- ===================================================================== --> 87 <!-- ===================================================================== -->
@@ -152,7 +158,8 @@ @@ -152,7 +158,8 @@
152 </script> 158 </script>
153 159
154 <script> 160 <script>
155 - var finishtime = new Date().getTime() + {{ t['duration']*60*1000 }}; 161 + var duration = {{ t['duration']*60*1000 }}; // ms
  162 + var finishtime = new Date().getTime() + duration;
156 163
157 {% if t['duration'] == 0 %} 164 {% if t['duration'] == 0 %}
158 $("#clock").html("+\u221e"); 165 $("#clock").html("+\u221e");
@@ -161,7 +168,7 @@ @@ -161,7 +168,7 @@
161 // Update the count down every 1 second 168 // Update the count down every 1 second
162 var x = setInterval(function() { 169 var x = setInterval(function() {
163 var now = new Date().getTime(); 170 var now = new Date().getTime();
164 - var distance = finishtime - now; 171 + var distance = finishtime - now; // ms
165 172
166 // Time calculations for days, hours, minutes and seconds 173 // Time calculations for days, hours, minutes and seconds
167 var minutes = Math.floor((distance / (1000 * 60))); 174 var minutes = Math.floor((distance / (1000 * 60)));
@@ -180,6 +187,9 @@ @@ -180,6 +187,9 @@
180 $("#test").submit(); 187 $("#test").submit();
181 {% end %} 188 {% end %}
182 } 189 }
  190 +
  191 + var progress = distance/duration*100 + '%'
  192 + $('.progress-bar').css('width', progress).attr('aria-valuenow', progress);
183 }, 1000); 193 }, 1000);
184 194
185 {% end %} 195 {% end %}