mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-13 05:55:26 +00:00
update
This commit is contained in:
43
node_modules/browser-sync-ui/lib/plugins/remote-debug/latency/latency.client.js
generated
vendored
Normal file
43
node_modules/browser-sync-ui/lib/plugins/remote-debug/latency/latency.client.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
(function (angular) {
|
||||
|
||||
const SECTION_NAME = "remote-debug";
|
||||
/**
|
||||
* Display the snippet when in snippet mode
|
||||
*/
|
||||
angular
|
||||
.module("BrowserSync")
|
||||
.directive("latency", function () {
|
||||
return {
|
||||
restrict: "E",
|
||||
replace: true,
|
||||
scope: {
|
||||
"options": "="
|
||||
},
|
||||
templateUrl: "latency.html",
|
||||
controller: ["$scope", "Socket", latencyDirectiveControlller],
|
||||
controllerAs: "ctrl"
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @param $scope
|
||||
* @param Socket
|
||||
*/
|
||||
function latencyDirectiveControlller($scope, Socket) {
|
||||
|
||||
var ctrl = this;
|
||||
var ns = SECTION_NAME + ":latency";
|
||||
|
||||
ctrl.latency = $scope.options[SECTION_NAME]["latency"];
|
||||
|
||||
ctrl.alterLatency = function () {
|
||||
Socket.emit("ui", {
|
||||
namespace: ns,
|
||||
event: "adjust",
|
||||
data: {
|
||||
rate: ctrl.latency.rate
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
})(angular);
|
12
node_modules/browser-sync-ui/lib/plugins/remote-debug/latency/latency.html
generated
vendored
Normal file
12
node_modules/browser-sync-ui/lib/plugins/remote-debug/latency/latency.html
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<div ng-show="ctrl.latency.active" bs-panel-content>
|
||||
<input type="range"
|
||||
max="5"
|
||||
min="0"
|
||||
step=".50"
|
||||
id="latency-rate"
|
||||
ng-change="ctrl.alterLatency()"
|
||||
ng-model="ctrl.latency.rate"/>
|
||||
|
||||
<label for="latency-rate">{{ctrl.latency.rate | number:1}}s</label>
|
||||
</div>
|
||||
|
44
node_modules/browser-sync-ui/lib/plugins/remote-debug/latency/latency.js
generated
vendored
Normal file
44
node_modules/browser-sync-ui/lib/plugins/remote-debug/latency/latency.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
var Immutable = require("immutable");
|
||||
|
||||
module.exports.init = function (ui, bs) {
|
||||
|
||||
var timeout = 0;
|
||||
var optPath = ["remote-debug", "latency"];
|
||||
|
||||
ui.setOptionIn(optPath, Immutable.Map({
|
||||
name: "latency",
|
||||
title: "Latency",
|
||||
active: false,
|
||||
tagline: "Simulate slower connections by throttling the response time of each request.",
|
||||
rate: 0
|
||||
}));
|
||||
|
||||
var methods = {
|
||||
toggle: function (value) {
|
||||
if (value !== true) {
|
||||
value = false;
|
||||
}
|
||||
if (value) {
|
||||
ui.setOptionIn(optPath.concat("active"), true);
|
||||
bs.addMiddleware("*", function (req, res, next) {
|
||||
setTimeout(next, timeout);
|
||||
}, {id: "cp-latency", override: true});
|
||||
} else {
|
||||
ui.setOptionIn(optPath.concat("active"), false);
|
||||
bs.removeMiddleware("cp-latency");
|
||||
}
|
||||
},
|
||||
adjust: function (data) {
|
||||
timeout = parseFloat(data.rate) * 1000;
|
||||
var saved = ui.options.getIn(optPath.concat("rate"));
|
||||
if (saved !== data.rate) {
|
||||
ui.setOptionIn(optPath.concat("rate"), timeout/1000);
|
||||
}
|
||||
},
|
||||
event: function (event) {
|
||||
methods[event.event](event.data);
|
||||
}
|
||||
};
|
||||
|
||||
return methods;
|
||||
};
|
Reference in New Issue
Block a user