vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

10 years ago
  1. /**
  2. * Created by Alex on 9/25/2014.
  3. */
  4. function DurationData() {
  5. this.fields = ['duration','durationWithPause','durationWithStartup','durationWithBoth'];
  6. for (var i = 0; i < this.fields.length; i++) {
  7. this[this.fields[i]] = 0;
  8. }
  9. }
  10. DurationData.prototype.setData = function(otherData) {
  11. for (var i = 0; i < this.fields.length; i++) {
  12. this[this.fields[i]] = otherData[this.fields[i]];
  13. }
  14. };
  15. DurationData.prototype.getData = function() {
  16. var dataObj = {};
  17. for (var i = 0; i < this.fields.length; i++) {
  18. dataObj[this.fields[i]] = this[this.fields[i]];
  19. }
  20. return dataObj;
  21. };
  22. DurationData.prototype.useHighest = function(otherData) {
  23. for (var i = 0; i < this.fields.length; i++) {
  24. var field = this.fields[i];
  25. if (this[field] < otherData[field]) {
  26. this[field] = otherData[field];
  27. }
  28. }
  29. };
  30. DurationData.prototype.calculateDuration = function(time, timeStart, elapsedTime, elapsedTimeWithPause, startupTime) {
  31. this.duration = elapsedTime;
  32. this.durationWithPause = elapsedTimeWithPause;
  33. this.durationWithStartup = elapsedTime + startupTime.durationWithStartup;
  34. this.durationWithBoth = elapsedTimeWithPause + startupTime.durationWithBoth;
  35. };