source : OilLevel.js

  1. 'use strict';
  2. /**
  3. * This widget displays the oil level.
  4. * <p>
  5. * States:
  6. * <p>
  7. * <ul>
  8. * <li>WARNING - maybe some thing is wrong with the engine.</li>
  9. * <li>CRITICAL - pit and repair your engine.</li>
  10. * </ul>
  11. * Example:
  12. * <p><b>
  13. * <sra-text-gauge-oil-level></sra-text-spek-oil-level>
  14. * </b>
  15. * <img src="../widgets/TextGauge/OilLevel/icon.png" />
  16. * @ngdoc directive
  17. * @name sra-text-gauge-oil-level
  18. * @param {boolean} data-sra-args-show-label Set to true or false for displaying the label. Defaults to true. Can be overridden from the URL with "SHOWLABEL=false".
  19. * @param {double} data-sra-args-round-to The value to round the digital display to. Defaults to 1. Can be overridden from the URL with "ROUNDTO=10".
  20. * @param {integer} data-sra-args-interval The interval, in milliseconds, that this widget will update from the server. Default is 16.
  21. * @author Jeffrey Gilliam
  22. * @since 1.10
  23. * @copyright Copyright (C) 2015 - 2024 Jeffrey Gilliam
  24. * @license Apache License 2.0
  25. */
  26. define(['SIMRacingApps','widgets/TextGauge/TextGauge','css!widgets/TextGauge/OilLevel/OilLevel'],
  27. function(SIMRacingApps,TextGauge) {
  28. var self = {
  29. name: "sraTextGaugeOilLevel",
  30. url: 'TextGauge/OilLevel',
  31. template: 'OilLevel.html',
  32. defaultWidth: 380,
  33. defaultHeight: 120,
  34. defaultInterval: 300 //initialize with the default interval
  35. };
  36. self.module = angular.module('SIMRacingApps'); //get the main module
  37. self.module.directive(self.name,
  38. ['sraDispatcher', '$filter',
  39. function(sraDispatcher, $filter) {
  40. return {
  41. restrict: 'EA',
  42. scope: true,
  43. templateUrl: sraDispatcher.getWidgetUrl(self.url) + '/' + self.template,
  44. controller: [ '$scope', function($scope) {
  45. $scope.directiveName = self.name;
  46. $scope.defaultWidth = self.defaultWidth;
  47. $scope.defaultHeight = self.defaultHeight;
  48. $scope.defaultInterval = self.defaultInterval;
  49. }]
  50. , link: function($scope,$element,$attrs) {
  51. //copy arguments to our $scope
  52. $scope.value =
  53. $scope[self.name] = sraDispatcher.getTruthy($scope.sraArgsVALUE, $attrs[self.name], $attrs.sraArgsValue, "DefaultValue");
  54. $scope.sraShowLabel = sraDispatcher.getBoolean($scope.sraArgsSHOWLABEL, $attrs.sraArgsShowLabel, $attrs.sraArgsShowLabel, true);
  55. $scope.sraShowUOM = sraDispatcher.getBoolean($scope.sraArgsSHOWUOM, $attrs.sraArgsShowUOM, $attrs.sraArgsShowUOM, true);
  56. $scope.sraRoundTo = sraDispatcher.getTruthy($scope.sraArgsTACHROUNDTO,$attrs.sraArgsRoundTo,1)*1;
  57. $scope.sraDecimals = sraDispatcher.getTruthy($scope.sraArgsDECIMALS,$attrs.sraArgsDecimals,1)*1;
  58. //register with the dispatcher
  59. $scope.names = sraDispatcher.subscribe($scope,$attrs,self.defaultInterval); //register subscriptions and options to the dispatcher
  60. }
  61. };
  62. }]);
  63. return self;
  64. });