diff --git a/package.json b/package.json
index cfb1fc9..f7c581f 100644
--- a/package.json
+++ b/package.json
@@ -49,6 +49,7 @@
"@babel/polyfill": "^7.0.0",
"bootstrap": "3.3.7",
"bootstrap-datetime-picker": "2.4.4",
+ "bootstrap-slider": "^10.2.1",
"comment-json": "^1.1.3",
"fs.extra": "^1.3.2",
"fs.realpath": "^1.0.0",
diff --git a/src/player.jsx b/src/player.jsx
index 6cd9bcf..86d1ba7 100644
--- a/src/player.jsx
+++ b/src/player.jsx
@@ -24,6 +24,7 @@ let Term = require("term.js-cockpit");
let Journal = require("journal");
let $ = require("jquery");
require("console.css");
+require("bootstrap-slider");
/*
* Get an object field, verifying its presence and type.
@@ -460,32 +461,57 @@ let PacketBuffer = class {
}
};
-let ProgressBar = class extends React.Component {
+class Slider extends React.Component {
constructor(props) {
super(props);
- this.jumpTo = this.jumpTo.bind(this);
+ this.slideStart = this.slideStart.bind(this);
+ this.slideStop = this.slideStop.bind(this);
+ this.slider = null;
+ this.state = {
+ paused: false,
+ };
}
- jumpTo(e) {
+ slideStart(e) {
+ this.setState({paused: this.props.paused});
+ this.props.pause();
+ }
+
+ slideStop(e) {
if (this.props.fastForwardFunc) {
- let percent = parseInt((e.nativeEvent.offsetX * 100) / e.currentTarget.clientWidth);
- let ts = parseInt((this.props.length * percent) / 100);
- this.props.fastForwardFunc(ts);
+ this.props.fastForwardFunc(e);
+ if (this.state.paused === false) {
+ this.props.play();
+ }
}
}
- render() {
- let progress = {
- "width": parseInt((this.props.mark * 100) / this.props.length) + "%"
- };
+ componentDidMount() {
+ this.slider = $("#slider").slider({
+ value: 0,
+ tooltip: "hide",
+ enabled: false,
+ });
+ this.slider.slider('on', 'slideStart', this.slideStart);
+ this.slider.slider('on', 'slideStop', this.slideStop);
+ }
+ componentDidUpdate() {
+ if (this.props.length) {
+ this.slider.slider('enable');
+ this.slider.slider('setAttribute', 'max', this.props.length);
+ }
+ if (this.props.mark) {
+ this.slider.slider('setValue', this.props.mark);
+ }
+ }
+
+ render () {
return (
-
+
);
}
-};
+}
class InputPlayer extends React.Component {
render() {
@@ -506,6 +532,8 @@ export class Player extends React.Component {
this.handleTitleChange = this.handleTitleChange.bind(this);
this.rewindToStart = this.rewindToStart.bind(this);
this.playPauseToggle = this.playPauseToggle.bind(this);
+ this.play = this.play.bind(this);
+ this.pause = this.pause.bind(this);
this.speedUp = this.speedUp.bind(this);
this.speedDown = this.speedDown.bind(this);
this.speedReset = this.speedReset.bind(this);
@@ -769,6 +797,14 @@ export class Player extends React.Component {
this.setState({paused: !this.state.paused});
}
+ play() {
+ this.setState({paused: false});
+ }
+
+ pause() {
+ this.setState({paused: true});
+ }
+
speedUp() {
let speedExp = this.state.speedExp;
if (speedExp < 4) {
@@ -1010,17 +1046,6 @@ export class Player extends React.Component {
"float": "right",
};
- const progressbar_style = {
- 'marginTop': '10px',
- };
-
- const currentTsPost = function(currentTS, bufLength) {
- if (currentTS > bufLength) {
- return bufLength;
- }
- return currentTS;
- };
-
let error = "";
if (this.state.error) {
error = (
@@ -1047,6 +1072,7 @@ export class Player extends React.Component {
+
-
diff --git a/src/recordings.css b/src/recordings.css
index a163f44..641159c 100644
--- a/src/recordings.css
+++ b/src/recordings.css
@@ -394,6 +394,10 @@ table.listing-ct > thead th:last-child, tr.listing-ct-item td:last-child {
resize: none;
}
-#progress_bar {
- margin-bottom: 10px;
+#input-player-wrap {
+ margin-top: 5px;
+}
+
+.panel-footer {
+ padding: 5px 15px;
}
diff --git a/src/recordings.jsx b/src/recordings.jsx
index 8b2d1bc..72bc82d 100644
--- a/src/recordings.jsx
+++ b/src/recordings.jsx
@@ -424,7 +424,8 @@ class Recording extends React.Component {
-
+ {player}
+
{_("Recording")}
@@ -473,7 +474,6 @@ class Recording extends React.Component {
- {player}
);
diff --git a/src/slider.html b/src/slider.html
new file mode 100644
index 0000000..0a8498c
--- /dev/null
+++ b/src/slider.html
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+
+
+Example of a slider in a form
+
+
+
+
+
+
+ 0
+
+ 100
+
+ GB
+
+
+
+
+
+
+ 0
+
+ 100
+
+
+
+
+
+
+
+
+
+
+componentDidMount() {
+this.slider = new Slider("input.slider", {
+value: 0,
+min: 0,
+max: 100
+});
+console.log(this.slider);
+}
+
+componentDidUpdate() {
+console.log('slider updated');
+console.log(this.slider);
+// this.slider.setAttribute('max', this.props.length);
+// this.slider.setValue(this.props.mark);
+}