processedCtrl.js 1006 B

12345678910111213141516171819202122232425262728293031
  1. app.controller('processedCtrl', ['$scope', '$http', function ($scope, $http) {
  2. $scope.update = function() {
  3. $http.get('back/list/processed').success(function(data) {
  4. $scope.videolist = data.list.map(function(el) {
  5. if (el.end_time==0) return el;
  6. if (el.start_time==0) return el;
  7. if (el.end_time.indexOf(":") == -1 ) { //1800 => 0:30:00
  8. el.end_time=toHHMMSS(el.end_time);
  9. }
  10. if (el.start_time.indexOf(":") == -1 ) { //1800 => 0:30:00
  11. el.start_time=toHHMMSS(el.start_time);
  12. }
  13. return el;
  14. });
  15. });
  16. };
  17. $scope.update();
  18. function toHHMMSS (t) {
  19. var sec_num = parseInt(t, 10); // don't forget the second param
  20. var hours = Math.floor(sec_num / 3600);
  21. var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
  22. var seconds = sec_num - (hours * 3600) - (minutes * 60);
  23. if (hours < 10) {hours = "0"+hours;}
  24. if (minutes < 10) {minutes = "0"+minutes;}
  25. if (seconds < 10) {seconds = "0"+seconds;}
  26. return hours+':'+minutes+':'+seconds;
  27. }
  28. }]);