latency.client.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (function (angular) {
  2. const SECTION_NAME = "remote-debug";
  3. /**
  4. * Display the snippet when in snippet mode
  5. */
  6. angular
  7. .module("BrowserSync")
  8. .directive("latency", function () {
  9. return {
  10. restrict: "E",
  11. replace: true,
  12. scope: {
  13. "options": "="
  14. },
  15. templateUrl: "latency.html",
  16. controller: ["$scope", "Socket", latencyDirectiveControlller],
  17. controllerAs: "ctrl"
  18. };
  19. });
  20. /**
  21. * @param $scope
  22. * @param Socket
  23. */
  24. function latencyDirectiveControlller($scope, Socket) {
  25. var ctrl = this;
  26. var ns = SECTION_NAME + ":latency";
  27. ctrl.latency = $scope.options[SECTION_NAME]["latency"];
  28. ctrl.alterLatency = function () {
  29. Socket.emit("ui", {
  30. namespace: ns,
  31. event: "adjust",
  32. data: {
  33. rate: ctrl.latency.rate
  34. }
  35. });
  36. };
  37. }
  38. })(angular);