Dates are objects, be caurfull when copying them!
This commit is contained in:
Luis Fernando Molina committed 2018-05-19 19:57:50 +02:00
1 parent 50678bc119
commit ac18c984b2
2 files changed
+30 -47

No files matched your search

+5 -2
View File
@@ -2,7 +2,7 @@
function newProductStorage(pName) {
const MODULE_NAME = "Product Storage";
const INFO_LOG = false;
const INFO_LOG = true;
const ERROR_LOG = true;
const logger = newDebugLog();
logger.fileName = MODULE_NAME;
@@ -451,6 +451,9 @@ function newProductStorage(pName) {
function setDatetime(pDatetime) {
console.log("recibi= " + pDatetime);
console.log("tenia = " + datetime);
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
/* If there is a change in the day, then we take some actions, otherwise, we dont. */
@@ -458,7 +461,7 @@ function newProductStorage(pName) {
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS);
let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS);
datetime = pDatetime;
datetime = new Date(pDatetime);
if (currentDate !== newDate) {
+25 -45
View File
@@ -1,7 +1,7 @@
function newTimelineChart() {
const MODULE_NAME = "Timeline Chart";
const INFO_LOG = false;
const INFO_LOG = true;
const INTENSIVE_LOG = false;
const ERROR_LOG = true;
const logger = newDebugLog();
@@ -75,7 +75,6 @@
viewPort.eventHandler.listenToEvent("Offset Changed", onOffsetChanged);
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
initializeCompetitionPlotters(onCompetitionPlottersInitialized);
@@ -718,21 +717,35 @@
}
}
function onDragFinished() {
function setDatetime(pDatetime) {
if (INFO_LOG === true) { logger.write("[INFO] onDragFinished -> Entering function."); }
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
if (initializationReady === true) {
/* This function is used when the time is changed through the user interface, but without zooming or panning. */
/* No matter if the day changed or not, we need to inform all visible Plotters. */
if (thisObject.container.frame.isInViewPort()) {
if (thisObject.container.frame.isInViewPort()) {
saveUserPosition(thisObject.container, timeLineCoordinateSystem);
for (let i = 0; i < productPlotters.length; i++) {
let productPlotter = productPlotters[i];
productPlotter.productCard.setDatetime(pDatetime);
productPlotter.plotter.setDatetime(pDatetime);
/* The time has changed, but the viewPort is still on the same place, so we request any of the plotters to reposition it. */
if (productPlotter.plotter.positionAtDatetime !== undefined) {
productPlotter.plotter.positionAtDatetime(pDatetime);
}
}
if (thisObject.container.frame.isInViewPort() && tooSmall() === false) {
for (let i = 0; i < competitionPlotters.length; i++) {
let competitionPlotter = competitionPlotters[i];
competitionPlotter.plotter.setDatetime(datetime);
}
}
@@ -747,7 +760,7 @@
if (thisObject.container.frame.isInViewPort()) {
recalculateCurrentDatetime();
saveUserPosition(thisObject.container, timeLineCoordinateSystem);
}
}
@@ -759,7 +772,7 @@
/*
The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that me
The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that we
must calculate.
*/
@@ -777,6 +790,8 @@
datetime = newDate;
console.log("nueva = " + datetime);
for (let i = 0; i < productPlotters.length; i++) {
let productPlotter = productPlotters[i];
@@ -820,41 +835,6 @@
}
function setDatetime(pDatetime) {
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
/* This function is used when the time is changed through the user interface, but without zooming or panning. */
/* No matter if the day changed or not, we need to inform all visible Plotters. */
if (thisObject.container.frame.isInViewPort()) {
for (let i = 0; i < productPlotters.length; i++) {
let productPlotter = productPlotters[i];
productPlotter.productCard.setDatetime(pDatetime);
productPlotter.storage.setDatetime(pDatetime);
productPlotter.plotter.setDatetime(pDatetime);
/* The time has changed, but the viewPort is still on the same place, so we request any of the plotters to reposition it. */
if (productPlotter.plotter.positionAtDatetime !== undefined) {
productPlotter.plotter.positionAtDatetime(pDatetime);
}
}
for (let i = 0; i < competitionPlotters.length; i++) {
let competitionPlotter = competitionPlotters[i];
competitionPlotter.plotter.setDatetime(datetime);
}
}
}
function recalculateScale() {
if (INFO_LOG === true) { logger.write("[INFO] recalculateScale -> Entering function."); }