summaryrefslogtreecommitdiff
path: root/public/bundle.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-21 11:43:41 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-21 11:43:41 +0200
commit9b66e84a72eb1cf0a8caf19450f348f194c21d4f (patch)
treef777160c357e8cdee9c6b770b10505b1fa748fe7 /public/bundle.js
parentbbf3c187c4967509a8097b168533786daacc2ec6 (diff)
update all these faders
Diffstat (limited to 'public/bundle.js')
-rw-r--r--public/bundle.js173
1 files changed, 135 insertions, 38 deletions
diff --git a/public/bundle.js b/public/bundle.js
index 337c8fa..4fb7698 100644
--- a/public/bundle.js
+++ b/public/bundle.js
@@ -123,34 +123,70 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js");
var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
-function ParamGroup(props) {
- return (0, _preact.h)(
- 'div',
- { 'class': 'paramGroup' },
- (0, _preact.h)(
- 'label',
- null,
- (0, _preact.h)(
- 'h3',
- null,
- props.title
- ),
- (0, _preact.h)('input', { type: 'checkbox' })
- ),
- props.children
- );
-}
+var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js");
+
+var _actions = __webpack_require__(/*! ../live/actions */ "./app/client/live/actions.js");
+
+var liveActions = _interopRequireWildcard(_actions);
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var ParamGroup = function (_Component) {
+ _inherits(ParamGroup, _Component);
+
+ function ParamGroup() {
+ _classCallCheck(this, ParamGroup);
+
+ return _possibleConstructorReturn(this, (ParamGroup.__proto__ || Object.getPrototypeOf(ParamGroup)).apply(this, arguments));
+ }
+
+ _createClass(ParamGroup, [{
+ key: 'render',
+ value: function render() {
+ var props = this.props;
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'paramGroup' },
+ (0, _preact.h)(
+ 'label',
+ null,
+ (0, _preact.h)(
+ 'h3',
+ null,
+ props.title
+ ),
+ (0, _preact.h)('input', { type: 'checkbox' })
+ ),
+ props.children
+ );
+ }
+ }]);
+
+ return ParamGroup;
+}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
- return {};
+ return {
+ opt: state.live.opt
+ };
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
- return {};
+ return {
+ actions: (0, _redux.bindActionCreators)(liveActions, dispatch)
+ };
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(ParamGroup);
@@ -171,40 +207,96 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
-var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js");
var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
+var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js");
+
+var _actions = __webpack_require__(/*! ../live/actions */ "./app/client/live/actions.js");
+
+var liveActions = _interopRequireWildcard(_actions);
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+var SLIDER_THROTTLE_TIME = 100;
+
var Slider = function (_Component) {
_inherits(Slider, _Component);
- function Slider() {
+ function Slider(props) {
_classCallCheck(this, Slider);
- return _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).apply(this, arguments));
+ var _this = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, props));
+
+ _this.timeout = 0;
+ _this.state = {
+ value: props.opt[props.name]
+ };
+ _this.handleInput = _this.handleInput.bind(_this);
+ _this.handleRange = _this.handleRange.bind(_this);
+ return _this;
}
_createClass(Slider, [{
+ key: 'handleInput',
+ value: function handleInput(e) {
+ var _props = this.props,
+ name = _props.name,
+ opt = _props.opt;
+
+ var old_value = opt[name];
+ var new_value = e.target.value;
+ if (this.props.type === 'int') {
+ new_value = parseInt(new_value);
+ }
+ if (old_value !== new_value) {
+ this.setState({ value: new_value });
+ this.props.actions.set_param(this.props.name, new_value);
+ }
+ clearTimeout(this.timeout);
+ }
+ }, {
+ key: 'handleRange',
+ value: function handleRange(e) {
+ var _this2 = this;
+
+ clearTimeout(this.timeout);
+ var new_value = e.target.value;
+ if (this.props.type === 'int') {
+ new_value = parseInt(new_value);
+ }
+ this.setState({ value: new_value });
+ this.timeout = setTimeout(function () {
+ _this2.props.actions.set_param(_this2.props.name, new_value);
+ }, SLIDER_THROTTLE_TIME);
+ }
+ }, {
key: 'render',
value: function render() {
- var props = this.props;
- var name = props.name;
- var title = props.title || name.replace(/_/g, ' ');
+ var _props2 = this.props,
+ name = _props2.name,
+ title = _props2.title;
+
+ var value = this.state.value;
+ if (typeof value === 'undefined') {
+ value = this.props.min;
+ }
+ var text_value = value;
var step = void 0;
- if (props.type === 'int') {
+ if (this.props.type === 'int') {
step = 1;
} else {
- step = (props.max - props.min) / 100;
+ step = (this.props.max - this.props.min) / 100;
+ text_value = parseFloat(value).toFixed(2);
}
return (0, _preact.h)(
'div',
@@ -215,16 +307,17 @@ var Slider = function (_Component) {
(0, _preact.h)(
'span',
null,
- title
+ title || name.replace(/_/g, ' ')
),
- (0, _preact.h)('input', { type: 'text'
- })
+ (0, _preact.h)('input', { type: 'text', value: text_value, onBlur: this.handleInput })
),
(0, _preact.h)('input', {
type: 'range',
- min: props.min,
- max: props.max,
- step: step
+ min: this.props.min,
+ max: this.props.max,
+ step: step,
+ value: value,
+ onInput: this.handleRange
})
);
}
@@ -234,11 +327,15 @@ var Slider = function (_Component) {
}(_preact.Component);
var mapStateToProps = function mapStateToProps(state) {
- return {};
+ return {
+ opt: state.live.opt
+ };
};
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
- return _extends({}, ownProps);
+ return {
+ actions: (0, _redux.bindActionCreators)(liveActions, dispatch)
+ };
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Slider);
@@ -604,7 +701,7 @@ var liveReducer = function liveReducer() {
var action = arguments[1];
var results = void 0;
- console.log(action.type);
+
switch (action.type) {
case 'LOAD_PARAMS':
return _extends({}, state, {
@@ -662,7 +759,7 @@ socket.on('res', function (data) {
case 'get_params':
_store.store.dispatch({
type: 'LOAD_PARAMS',
- opt: data.payload
+ opt: data.res
});
break;
default: