diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index fa8dceba9..ed16be669 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -391,25 +391,24 @@ angular.module('OpenSlidesApp.core', [ } ]) -/* Converts number of seconds into string "hh:mm:ss" or "mm:ss" */ +/* Converts number of seconds into string "h:mm:ss" or "mm:ss" */ .filter('osSecondsToTime', [ function () { return function (totalseconds) { var time; // floor returns the largest integer of the absolut value of totalseconds var total = Math.floor(Math.abs(totalseconds)); - var hh = Math.floor(total / 3600); + var h = Math.floor(total / 3600); var mm = Math.floor(total % 3600 / 60); var ss = Math.floor(total % 60); var zero = "0"; // Add leading "0" for double digit values - hh = (zero+hh).slice(-2); mm = (zero+mm).slice(-2); ss = (zero+ss).slice(-2); - if (hh == "00") + if (h == "0") time = mm + ':' + ss; else - time = hh + ":" + mm + ":" + ss; + time = h + ":" + mm + ":" + ss; if (totalseconds < 0) time = "-"+time; return time; diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index 0752d56d3..574e23f3f 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -1055,6 +1055,48 @@ angular.module('OpenSlidesApp.core.site', [ } ]) +// format time string for model ("s") and view format ("h:mm:ss" or "mm:ss") +.directive('minSecFormat', [ + function () { + return { + require: 'ngModel', + link: function(scope, element, attrs, ngModelController) { + ngModelController.$parsers.push(function(data) { + //convert data from view format (mm:ss) to model format (s) + var time = data.split(':'); + if (time.length > 1) { + data = (+time[0]) * 60 + (+time[1]); + if (data < 0) { + data = "-"+data; + } + } + return data; + }); + + ngModelController.$formatters.push(function(data) { + //convert data from model format (s) to view format (mm:ss) + var time; + // floor returns the largest integer of the absolut value of totalseconds + var total = Math.floor(Math.abs(data)); + var mm = Math.floor(total / 60); + var ss = Math.floor(total % 60); + var zero = "0"; + // Add leading "0" for double digit values + if (mm.length < 2) { + mm = (zero+mm).slice(-2); + } + ss = (zero+ss).slice(-2); + time = mm + ':' + ss; + if (data < 0) { + time = "-"+time; + } + return time; + }); + } + }; + } +]) + .directive('osFocusMe', [ '$timeout', function ($timeout) { diff --git a/openslides/core/static/templates/core/projector-controls.html b/openslides/core/static/templates/core/projector-controls.html index 665789fb7..569902478 100644 --- a/openslides/core/static/templates/core/projector-controls.html +++ b/openslides/core/static/templates/core/projector-controls.html @@ -136,7 +136,8 @@
- +