bemspeakhistory-view-model.js 831 B

12345678910111213141516171819202122232425262728
  1. (function() {
  2. BemsWebApplication.BemsPeakHistoryViewModel = function(data) {
  3. this.SiteId = ko.observable();
  4. this.CreatedDateTime = ko.observable();
  5. this.CurrentValue = ko.observable();
  6. if(data)
  7. this.fromJS(data);
  8. };
  9. $.extend(BemsWebApplication.BemsPeakHistoryViewModel.prototype, {
  10. toJS: function() {
  11. return {
  12. SiteId: this.SiteId(),
  13. CreatedDateTime: this.CreatedDateTime(),
  14. CurrentValue: this.CurrentValue(),
  15. };
  16. },
  17. fromJS: function(data) {
  18. if(data) {
  19. this.SiteId(data.SiteId);
  20. this.CreatedDateTime(data.CreatedDateTime);
  21. this.CurrentValue(data.CurrentValue);
  22. }
  23. }
  24. });
  25. })();