source : TeamSpeakTalking.js

  1. 'use strict';
  2. /**
  3. * This widget displays a who is talking and whispering in TeamSpeak.
  4. * For this to work, TeamSpeak has to be running and the ClientQuery plug-in has to be enabled in the settings.
  5. * <p>
  6. * Example:
  7. * <p><b>
  8. * <sra-team-speak-talking></sra-team-speak-talking><br />
  9. * </b>
  10. * <img src="../widgets/TeamSpeakTalking/icon.png" />
  11. * @ngdoc directive
  12. * @name sra-team-speak-talking
  13. * @param {integer} data-sra-args-interval The interval, in milliseconds, that this widget will update from the server. Default is 50.
  14. * @author Jeffrey Gilliam
  15. * @since 1.0
  16. * @copyright Copyright (C) 2015 - 2024 Jeffrey Gilliam
  17. * @license Apache License 2.0
  18. */
  19. define(['SIMRacingApps','css!widgets/TeamSpeakTalking/TeamSpeakTalking','widgets/DataTable/DataTable'],
  20. function(SIMRacingApps) {
  21. var self = {
  22. name: "sraTeamSpeakTalking",
  23. url: 'TeamSpeakTalking',
  24. template: 'TeamSpeakTalking.html',
  25. defaultWidth: 800,
  26. defaultHeight: 480,
  27. defaultInterval: 50 //initialize with the default interval
  28. };
  29. self.module = angular.module('SIMRacingApps'); //get the main module
  30. self.module.directive(self.name,
  31. ['sraDispatcher', '$filter', '$rootScope',
  32. function(sraDispatcher, $filter, $rootScope) {
  33. return {
  34. restrict: 'EA',
  35. scope: true,
  36. templateUrl: sraDispatcher.getWidgetUrl(self.url) + '/' + self.template,
  37. controller: [ '$scope', function($scope) {
  38. $scope.directiveName = self.name;
  39. $scope.defaultWidth = self.defaultWidth;
  40. $scope.defaultHeight = self.defaultHeight;
  41. $scope.defaultInterval = self.defaultInterval;
  42. //load translations, if you have any un-comment this
  43. sraDispatcher.loadTranslations(sraDispatcher.getWidgetUrl(self.url),'text',function(path) {
  44. $scope.translations = sraDispatcher.getTranslation(path);
  45. });
  46. /** your code goes here **/
  47. }]
  48. , link: function($scope,$element,$attrs) {
  49. //copy arguments to our scope. First if using attribute, second tag, else default to something.
  50. $attrs.sraArgsData = $attrs.sraArgsData || "";
  51. $scope.value =
  52. $scope[self.name] = sraDispatcher.getTruthy($scope.sraArgsVALUE, $attrs[self.name], $attrs.sraArgsValue, "DefaultValue");
  53. /** your code goes here **/
  54. /**standard code that should be in every directive **/
  55. $rootScope.$on('sraResize', sraDispatcher.resize($scope,$element,self.defaultWidth,self.defaultHeight));
  56. //register with the dispatcher
  57. $scope.names = sraDispatcher.subscribe($scope,$attrs,self.defaultInterval); //register subscriptions and options to the dispatcher
  58. }
  59. };
  60. }]);
  61. return self;
  62. });