Skip to content
Snippets Groups Projects
Commit 519a8f63 authored by Sebastien's avatar Sebastien
Browse files

Fix edit popup TC for notes

parent a80ed85a
No related branches found
No related tags found
1 merge request!98refresh the mosaic on annotation modification
...@@ -178,6 +178,10 @@ function TCPanelInputEditor(data) { ...@@ -178,6 +178,10 @@ function TCPanelInputEditor(data) {
} }
TCPanelInputEditor.prototype = Object.create(PanelInputEditor.prototype); TCPanelInputEditor.prototype = Object.create(PanelInputEditor.prototype);
TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
function onlyNumber(event) {
$(this).val($(this).val().replace(/[^0-9]/g, ''));
}
let that = this; let that = this;
this.readonlyDiv = $('<div>'); this.readonlyDiv = $('<div>');
...@@ -194,7 +198,7 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { ...@@ -194,7 +198,7 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
this.popupTcInDiv this.popupTcInDiv
.attr('id', 'popupTCin') .attr('id', 'popupTCin')
.addClass('popupTCdisplay') .addClass('popupTCdisplay')
.html(convertToTime(that.tag.getTimeEnd())) .html(convertToTime(that.tag.getTimeStart()))
this.readonlyDiv.append(this.popupTcInDiv); this.readonlyDiv.append(this.popupTcInDiv);
this.popupTcOutDiv = $('<div>'); this.popupTcOutDiv = $('<div>');
...@@ -215,15 +219,21 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { ...@@ -215,15 +219,21 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
}) })
this.editDiv.append($('<span>').addClass('popupTClabel').html('start')); this.editDiv.append($('<span>').addClass('popupTClabel').html('start'));
this.popupTCeditDivMinStart = $('<input class="popupTCeditfield" id="popupTCinMin" maxLength="2" type="text" value="">'); this.popupTCeditDivMinStart = $('<input class="popupTCeditfield" id="popupTCinMin" maxLength="2" type="text" value="">');
this.popupTCeditDivMinStart.click(function (event) { this.popupTCeditDivMinStart
.val(Math.floor(that.tag.getTimeStart()/60).toString(10).padStart(2, '0'))
.click(function (event) {
event.stopPropagation(); event.stopPropagation();
}); })
.on('input', onlyNumber);
this.editDiv.append(this.popupTCeditDivMinStart); this.editDiv.append(this.popupTCeditDivMinStart);
this.editDiv.append(':'); this.editDiv.append(':');
this.popupTCeditDivSecStart = $('<input class="popupTCeditfield" id="popupTCinSec" maxLength="2" type="text" value="">'); this.popupTCeditDivSecStart = $('<input class="popupTCeditfield" id="popupTCinSec" maxLength="2" type="text" value="">');
this.popupTCeditDivSecStart.click(function (event) { this.popupTCeditDivSecStart
.val((that.tag.getTimeStart()%60).toString(10).padStart(2, '0'))
.click(function (event) {
event.stopPropagation(); event.stopPropagation();
}); })
.on('input', onlyNumber);
this.editDiv.append(this.popupTCeditDivSecStart); this.editDiv.append(this.popupTCeditDivSecStart);
let popupTCeditStartDivNow = $('<div class="nowTCbtn" id="nowTCin">now</div>'); let popupTCeditStartDivNow = $('<div class="nowTCbtn" id="nowTCin">now</div>');
popupTCeditStartDivNow.click(function (event) { popupTCeditStartDivNow.click(function (event) {
...@@ -232,7 +242,7 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { ...@@ -232,7 +242,7 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
that.popupTCeditDivMinStart.val(timeCurrent.split(":")[0]); that.popupTCeditDivMinStart.val(timeCurrent.split(":")[0]);
that.popupTCeditDivSecStart.val(timeCurrent.split(":")[1]); that.popupTCeditDivSecStart.val(timeCurrent.split(":")[1]);
}); });
this.editDiv.append(popupTCeditStartDivNow); this.editDiv.append(popupTCeditStartDivNow)
this.editDiv.append($('<br>')); this.editDiv.append($('<br>'));
this.editDiv.append($('<span>').addClass('popupTClabel').html('end')); this.editDiv.append($('<span>').addClass('popupTClabel').html('end'));
...@@ -242,7 +252,9 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { ...@@ -242,7 +252,9 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
.attr('maxlength', '2') .attr('maxlength', '2')
.attr('type', 'text') .attr('type', 'text')
.addClass('popupTCeditfield') .addClass('popupTCeditfield')
.val(''); .val(Math.floor(that.tag.getTimeEnd()/60).toString(10).padStart(2, '0'))
.on('input', onlyNumber);
this.popupTCeditDivMinEnd.click(function (event) { this.popupTCeditDivMinEnd.click(function (event) {
event.stopPropagation(); event.stopPropagation();
}); });
...@@ -254,10 +266,11 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { ...@@ -254,10 +266,11 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
.attr('maxlength', '2') .attr('maxlength', '2')
.attr('type', 'text') .attr('type', 'text')
.addClass('popupTCeditfield') .addClass('popupTCeditfield')
.val('') .val(Math.floor(that.tag.getTimeEnd()%60).toString(10).padStart(2, '0'))
.click(function (event) { .click(function (event) {
event.stopPropagation(); event.stopPropagation();
}); })
.on('input', onlyNumber);
this.editDiv.append(this.popupTCeditDivSecEnd); this.editDiv.append(this.popupTCeditDivSecEnd);
let popupTCeditEndDivNow = $('<div class="nowTCbtn" id="nowTCin">now</div>'); let popupTCeditEndDivNow = $('<div class="nowTCbtn" id="nowTCin">now</div>');
popupTCeditEndDivNow.click(function (event) { popupTCeditEndDivNow.click(function (event) {
...@@ -282,10 +295,18 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) { ...@@ -282,10 +295,18 @@ TCPanelInputEditor.prototype.appendInputEditorDiv = function (parentDiv) {
} }
TCPanelInputEditor.prototype.closeEdition = function () { TCPanelInputEditor.prototype.closeEdition = function () {
if (this.canEdit) { if (this.canEdit) {
let tcInMin = this.popupTCeditDivMinStart.val(); let isNaN = (maybeNaN) => maybeNaN!=maybeNaN;
let tcInSec = this.popupTCeditDivSecStart.val(); let ensureNotNaN = (text, defaultValue = 0) => {
let tcOutMin = this.popupTCeditDivMinEnd.val(); let tempVal = parseInt(text);
let tcOutSec = this.popupTCeditDivSecEnd.val(); if (isNaN(tempVal)) {
return defaultValue;
}
return tempVal;
}
let tcInMin = ensureNotNaN(this.popupTCeditDivMinStart.val());
let tcInSec = ensureNotNaN(this.popupTCeditDivSecStart.val());
let tcOutMin = ensureNotNaN(this.popupTCeditDivMinEnd.val());
let tcOutSec = ensureNotNaN(this.popupTCeditDivSecEnd.val());
let tcIn = (60 * tcInMin) + tcInSec; let tcIn = (60 * tcInMin) + tcInSec;
let tcOut = (60 * tcOutMin) + tcOutSec; let tcOut = (60 * tcOutMin) + tcOutSec;
...@@ -306,8 +327,12 @@ TCPanelInputEditor.prototype.closeEdition = function () { ...@@ -306,8 +327,12 @@ TCPanelInputEditor.prototype.closeEdition = function () {
} else { } else {
this.tag.setTimeStart(tcIn); this.tag.setTimeStart(tcIn);
this.tag.setTimeEnd(tcOut); this.tag.setTimeEnd(tcOut);
this.popupTcInDiv.html(tcInMin + ":" + tcInSec); this.popupTcInDiv.html(tcInMin.toString().padStart(2, '0') + ":" + tcInSec.toString().padStart(2, '0'));
this.popupTcOutDiv.html(tcOutMin + ":" + tcOutSec); this.popupTcOutDiv.html(tcOutMin.toString().padStart(2, '0') + ":" + tcOutSec.toString().padStart(2, '0'));
this.popupTCeditDivMinStart.val(tcInMin.toString().padStart(2, '0'));
this.popupTCeditDivSecStart.val(tcInSec.toString().padStart(2, '0'));
this.popupTCeditDivMinEnd.val(tcOutMin.toString().padStart(2, '0'));
this.popupTCeditDivSecEnd.val(tcOutSec.toString().padStart(2, '0'));
window.app.rekall.Rekall('pubSub').publish('tag.tc.updated', {tag: this.tag}); window.app.rekall.Rekall('pubSub').publish('tag.tc.updated', {tag: this.tag});
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment