source : FuelLevel.js

  1. 'use strict';
  2. /**
  3. * This widget displays the fuel level.
  4. * <p>
  5. * States:
  6. * <p>
  7. * <ul>
  8. * <li>WARNING - time to start looking for pit road.</li>
  9. * <li>CRITICAL - time to pit.</li>
  10. * </ul>
  11. * Example:
  12. * <p><b>
  13. * <sra-analog-gauge-spek-fuel-level data-sra-args-show-digital-value="false"></sra-analog-gauge-spek-fuel-level>
  14. * </b>
  15. * <img src="../widgets/AnalogGauge/Spek/FuelLevel/icon.png" />
  16. * @ngdoc directive
  17. * @name sra-analog-gauge-spek-fuel-level
  18. * @param {boolean} data-sra-args-show-digital-value Set to true or false for displaying the digital value. Defaults to true. Can be overridden from the URL with "SHOWDIGITALVALUE=false".
  19. * @param {integer} data-sra-args-interval The interval, in milliseconds, that this widget will update from the server. Default is 500.
  20. * @author Jeffrey Gilliam
  21. * @since 1.0
  22. * @copyright Copyright (C) 2015 - 2024 Jeffrey Gilliam
  23. * @license Apache License 2.0
  24. */
  25. define(['SIMRacingApps','widgets/AnalogGauge/AnalogGauge','css!widgets/AnalogGauge/Spek/FuelLevel/FuelLevel'],
  26. function(SIMRacingApps,AnalogGauge) {
  27. var self = {
  28. name: "sraAnalogGaugeSpekFuelLevel",
  29. url: 'AnalogGauge/Spek/FuelLevel',
  30. template: 'FuelLevel.html',
  31. defaultWidth: 480,
  32. defaultHeight: 480,
  33. defaultInterval: 500 //initialize with the default interval
  34. };
  35. self.module = angular.module('SIMRacingApps'); //get the main module
  36. self.module.directive(self.name,
  37. ['sraDispatcher', '$filter',
  38. function(sraDispatcher, $filter) {
  39. return {
  40. restrict: 'EA',
  41. scope: true,
  42. templateUrl: sraDispatcher.getWidgetUrl(self.url) + '/' + self.template,
  43. controller: [ '$scope', function($scope) {
  44. $scope.directiveName = self.name;
  45. $scope.defaultWidth = self.defaultWidth;
  46. $scope.defaultHeight = self.defaultHeight;
  47. $scope.defaultInterval = self.defaultInterval;
  48. }]
  49. , link: function($scope,$element,$attrs) {
  50. //copy arguments to our scope
  51. $scope.value =
  52. $scope[self.name] = sraDispatcher.getTruthy($scope.sraArgsVALUE, $attrs[self.name], $attrs.sraArgsValue, "DefaultValue");
  53. $scope.sraShowValue = sraDispatcher.getBoolean($scope.sraArgsSHOWDIGITALVALUE, $attrs.sraArgsShowDigitalValue, $attrs.sraArgsShowValue, true);
  54. //register with the dispatcher
  55. $scope.names = sraDispatcher.subscribe($scope,$attrs,self.defaultInterval); //register subscriptions and options to the dispatcher
  56. }
  57. };
  58. }]);
  59. return self;
  60. });