From: Gael Le Mignot Date: Tue, 5 Dec 2017 16:47:21 +0000 (+0100) Subject: First version of JS chrono X-Git-Tag: 2.8.1-pro~216^2~2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f9106860ca3bc91fb02e32c2ea6a5c2f0477acc2;p=teleforma.git First version of JS chrono --- diff --git a/teleforma/static/teleforma/js/application.js b/teleforma/static/teleforma/js/application.js index a43febbd..7127d3ff 100644 --- a/teleforma/static/teleforma/js/application.js +++ b/teleforma/static/teleforma/js/application.js @@ -35,13 +35,18 @@ $(window).ready(function() { var navHeight = pageHeight - 125; $('#desk_center').css({"max-height": navHeight + 'px'}); + // chronometer $('.autotimer').each(function(){ var timer = new Timer(); - $timer = $(this); - timer.start({precision: 'seconds', startValues: {seconds: 90}, target: {seconds: 120}}); - $(this).html(timer.getTimeValues().toString()); + $timerSpan = $(this); + var value = $timerSpan.text() + // convert text value of timer to seconds + var timeArray = value.split(':'); + var seconds = parseInt(timeArray[0], 10) * 3600 + parseInt(timeArray[1], 10) * 60 + parseInt(timeArray[2], 10); + timer.start({precision: 'seconds', startValues: {seconds: seconds}}); + $timerSpan.html(timer.getTimeValues().toString()); timer.addEventListener('secondsUpdated', function (e) { - $(this).html(timer.getTimeValues().toString()); + $timerSpan.html(timer.getTimeValues().toString()); }); }); }); diff --git a/teleforma/static/teleforma/js/easytimer.js b/teleforma/static/teleforma/js/easytimer.js new file mode 100644 index 00000000..3b412646 --- /dev/null +++ b/teleforma/static/teleforma/js/easytimer.js @@ -0,0 +1 @@ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Timer=t()}(this,function(){"use strict";function n(n,t,e){var o=void 0,i="";for(o=0;o0?n-cn:cn-n,e={};e[m]=L(t),e[y]=M(t),e[b]=C(t),e[w]=j(t),e[g]=r(t),I(e),en(an.detail.timer),O(n)&&(K("targetAchieved",an),J())}function q(n){return Math.floor(n/E[nn])*E[nn]}function I(n){n[m]&&K("secondTenthsUpdated",an),n[y]&&K("secondsUpdated",an),n[b]&&K("minutesUpdated",an),n[w]&&K("hoursUpdated",an),n[g]&&K("daysUpdated",an)}function O(n){return sn instanceof Array&&n>=fn}function z(){for(var n in W)W.hasOwnProperty(n)&&"number"==typeof W[n]&&(W[n]=0);for(var t in X)X.hasOwnProperty(t)&&"number"==typeof X[t]&&(X[t]=0)}function R(n){nn="string"==typeof(n=n||{}).precision?n.precision:y,en="function"==typeof n.callback?n.callback:function(){},dn=!0===n.countdown,tn=!0===dn?-1:1,"object"===s(n.startValues)&&G(n.startValues),cn=D(),"object"===s(n.target)?sn=F(n.target):dn&&(n.target={seconds:0},sn=F(n.target)),on={precision:nn,callback:en,countdown:"object"===(void 0===n?"undefined":s(n))&&!0===n.countdown,target:sn,startValues:un},rn=n}function B(n){var t=void 0,e=void 0,o=void 0,i=void 0,r=void 0,m=void 0;if("object"===(void 0===n?"undefined":s(n)))if(n instanceof Array){if(5!==n.length)throw new Error("Array size not valid");m=n}else m=[n.secondTenths||0,n.seconds||0,n.minutes||0,n.hours||0,n.days||0];for(var y=0;y{% trans "Quiz" %} : {{ progress|quiz_progress }}%
- + {% if timer %} +
  • + Votre temps de connexion : {{ timer }} sur {{ seminar.duration }} +
  • + {% endif %} diff --git a/teleforma/templates/teleforma/answer_form.html b/teleforma/templates/teleforma/answer_form.html index c23f72cc..c1b8e1a4 100644 --- a/teleforma/templates/teleforma/answer_form.html +++ b/teleforma/templates/teleforma/answer_form.html @@ -115,7 +115,7 @@ $(document).ready(function(){ {% if timer %}
  • - {% trans "chronometer" %} : {{ timer }} sur {{ seminar.duration }} + Votre temps de connexion : {{ timer }} sur {{ seminar.duration }}
  • {% endif %} diff --git a/teleforma/templates/teleforma/inc/seminar_description.html b/teleforma/templates/teleforma/inc/seminar_description.html index bc92c28c..3ace5a4e 100644 --- a/teleforma/templates/teleforma/inc/seminar_description.html +++ b/teleforma/templates/teleforma/inc/seminar_description.html @@ -10,9 +10,6 @@ {% endif %}
    {% trans "level" %}
    {{ seminar.level }}
    {% trans "duration" %}
    {{ seminar.duration|hours }} {% trans "hours" %}
    -{% if timer %} -
    {% trans "chronometer" %}
    {{ timer }}
    -{% endif %}
    {% trans "expiry date" %}
    {{ seminar.expiry_date }}
    {% trans "last modification date" %}
    {% if seminar.date_forced %}{{ seminar.date_forced }}{% else %}{{ seminar.date_modified }}{% endif %}
    {% if user.is_superuser %} diff --git a/teleforma/templates/teleforma/seminar_detail.html b/teleforma/templates/teleforma/seminar_detail.html index be059fad..b35cb683 100644 --- a/teleforma/templates/teleforma/seminar_detail.html +++ b/teleforma/templates/teleforma/seminar_detail.html @@ -239,7 +239,7 @@ $(window).ready(function( ){ {% if timer %}
  • - {% trans "chronometer" %} : {{ timer }} sur {{ seminar.duration }} + Votre temps de connexion : {{ timer }} sur {{ seminar.duration }}
  • {% endif %} diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index 29a28d2e..cb444c64 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -48,7 +48,7 @@ - + diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 7757736e..f5eaef87 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -119,7 +119,7 @@ class SeminarAccessMixin(object): context = super(SeminarAccessMixin, self).get_context_data(**kwargs) seminar = context.get('seminar') if not seminar: - seminar = Seminar.objects.get(pk=self.kwargs.get('id', 'pk')) + seminar = Seminar.objects.get(pk=self.kwargs.get('id', self.kwargs.get('pk'))) context['seminar'] = seminar user = self.request.user