Autoformatter applied on all js files
This commit is contained in:
1 parent
72c1017b20
commit
c627aedcf6
59 files changed
+9087
-10892
No files matched your search
+131
-155
@@ -1,219 +1,195 @@
|
||||
|
||||
function newBreakpointsBar() {
|
||||
|
||||
var thisObject = {
|
||||
setDatetime: setDatetime,
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
};
|
||||
function newBreakpointsBar () {
|
||||
var thisObject = {
|
||||
setDatetime: setDatetime,
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
var container = newContainer();
|
||||
container.initialize();
|
||||
thisObject.container = container;
|
||||
var container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
thisObject.container.frame.width = browserCanvasContext.width;
|
||||
thisObject.container.frame.height = 15;
|
||||
thisObject.container.frame.width = browserCanvasContext.width
|
||||
thisObject.container.frame.height = 15
|
||||
|
||||
container.frame.position.x = 0;
|
||||
container.frame.position.y = viewPort.visibleArea.bottomRight.y;
|
||||
container.frame.position.x = 0
|
||||
container.frame.position.y = viewPort.visibleArea.bottomRight.y
|
||||
|
||||
container.isDraggeable = false;
|
||||
container.isClickeable = true;
|
||||
container.isDraggeable = false
|
||||
container.isClickeable = true
|
||||
|
||||
let logo;
|
||||
let canDrawLogo = false;
|
||||
let logo
|
||||
let canDrawLogo = false
|
||||
|
||||
let datetime;
|
||||
let timePeriod;
|
||||
let timeLineCoordinateSystem;
|
||||
let chartContainer;
|
||||
let datetime
|
||||
let timePeriod
|
||||
let timeLineCoordinateSystem
|
||||
let chartContainer
|
||||
|
||||
let breakpointsByTimePeriod = new Map();
|
||||
let breakpointsByTimePeriod = new Map()
|
||||
|
||||
return thisObject;
|
||||
return thisObject
|
||||
|
||||
function initialize(pChartContainer, pTimeLineCoordinateSystem) {
|
||||
function initialize (pChartContainer, pTimeLineCoordinateSystem) {
|
||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem
|
||||
chartContainer = pChartContainer
|
||||
|
||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem;
|
||||
chartContainer = pChartContainer;
|
||||
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
|
||||
timePeriod = INITIAL_TIME_PERIOD
|
||||
|
||||
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
|
||||
timePeriod = INITIAL_TIME_PERIOD;
|
||||
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
||||
|
||||
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
||||
|
||||
let breakpointsMap = new Map();
|
||||
breakpointsByTimePeriod.set(marketFilesPeriods[i][0], breakpointsMap);
|
||||
|
||||
}
|
||||
|
||||
for (let i = 0; i < dailyFilePeriods.length; i++) {
|
||||
|
||||
let breakpointsMap = new Map();
|
||||
breakpointsByTimePeriod.set(dailyFilePeriods[i][0], breakpointsMap);
|
||||
|
||||
}
|
||||
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
||||
let breakpointsMap = new Map()
|
||||
breakpointsByTimePeriod.set(marketFilesPeriods[i][0], breakpointsMap)
|
||||
}
|
||||
|
||||
function onClick(pPoint) {
|
||||
for (let i = 0; i < dailyFilePeriods.length; i++) {
|
||||
let breakpointsMap = new Map()
|
||||
breakpointsByTimePeriod.set(dailyFilePeriods[i][0], breakpointsMap)
|
||||
}
|
||||
}
|
||||
|
||||
let point = {
|
||||
x: pPoint.x,
|
||||
y: pPoint.y
|
||||
};
|
||||
function onClick (pPoint) {
|
||||
let point = {
|
||||
x: pPoint.x,
|
||||
y: pPoint.y
|
||||
}
|
||||
|
||||
let miliSeconds = getMilisecondsFromPoint(point, chartContainer, timeLineCoordinateSystem);
|
||||
let miliSeconds = getMilisecondsFromPoint(point, chartContainer, timeLineCoordinateSystem)
|
||||
|
||||
miliSeconds = normalizeX(miliSeconds); // We are now exactly at the middle of the "candle" correspondind to the point clicked.
|
||||
miliSeconds = normalizeX(miliSeconds) // We are now exactly at the middle of the "candle" correspondind to the point clicked.
|
||||
|
||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod);
|
||||
let breakpoint = breakpointsMap.get(miliSeconds);
|
||||
|
||||
if (breakpoint === undefined) {
|
||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod)
|
||||
let breakpoint = breakpointsMap.get(miliSeconds)
|
||||
|
||||
if (breakpoint === undefined) {
|
||||
/* The breakpoint didnt exist, then we create one. */
|
||||
breakpointsMap.set(miliSeconds, 1);
|
||||
|
||||
} else {
|
||||
|
||||
breakpointsMap.set(miliSeconds, 1)
|
||||
} else {
|
||||
/* The breakpoint existed, so we remove it. */
|
||||
breakpointsMap.set(miliSeconds, undefined);
|
||||
|
||||
}
|
||||
breakpointsMap.set(miliSeconds, undefined)
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeX(pX) {
|
||||
function normalizeX (pX) {
|
||||
return Math.trunc(pX / timePeriod) * timePeriod + timePeriod / 2
|
||||
}
|
||||
|
||||
return Math.trunc(pX / timePeriod) * timePeriod + timePeriod / 2;
|
||||
function onZoomChanged (event) {
|
||||
timePeriod = recalculatePeriod(event.newLevel)
|
||||
}
|
||||
|
||||
}
|
||||
function setDatetime (pDatetime) {
|
||||
datetime = new Date(pDatetime)
|
||||
}
|
||||
|
||||
function onZoomChanged(event) {
|
||||
|
||||
timePeriod = recalculatePeriod(event.newLevel);
|
||||
|
||||
}
|
||||
|
||||
function setDatetime(pDatetime) {
|
||||
|
||||
datetime = new Date(pDatetime);
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
let container;
|
||||
function getContainer (point) {
|
||||
let container
|
||||
|
||||
/* First we check if this point is inside this object UI. */
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
|
||||
return this.container;
|
||||
|
||||
} else {
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return this.container
|
||||
} else {
|
||||
/* This point does not belong to this space. */
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
|
||||
function draw () {
|
||||
/*
|
||||
To draw the breakpoints, we will calculate the miliseconds for the first x pixel of the breakpoint bar, and for the last x pixel. Once we have that
|
||||
we can create an array with all the possible points for breack points. Finally we can see if brealpoints exists at those points. We plot only the ones
|
||||
that exists.
|
||||
*/
|
||||
|
||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod);
|
||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod)
|
||||
|
||||
let beginX = {
|
||||
x: viewPort.visibleArea.bottomLeft.x,
|
||||
y: 0
|
||||
};
|
||||
let beginX = {
|
||||
x: viewPort.visibleArea.bottomLeft.x,
|
||||
y: 0
|
||||
}
|
||||
|
||||
let endX = {
|
||||
x: viewPort.visibleArea.bottomRight.x,
|
||||
y: 0
|
||||
};
|
||||
let endX = {
|
||||
x: viewPort.visibleArea.bottomRight.x,
|
||||
y: 0
|
||||
}
|
||||
|
||||
let beginMiliseconds = getMilisecondsFromPoint(beginX, chartContainer, timeLineCoordinateSystem);
|
||||
let endMiliseconds = getMilisecondsFromPoint(endX, chartContainer, timeLineCoordinateSystem);
|
||||
let beginMiliseconds = getMilisecondsFromPoint(beginX, chartContainer, timeLineCoordinateSystem)
|
||||
let endMiliseconds = getMilisecondsFromPoint(endX, chartContainer, timeLineCoordinateSystem)
|
||||
|
||||
beginMiliseconds = normalizeX(beginMiliseconds);
|
||||
endMiliseconds = normalizeX(endMiliseconds);
|
||||
beginMiliseconds = normalizeX(beginMiliseconds)
|
||||
endMiliseconds = normalizeX(endMiliseconds)
|
||||
|
||||
window.AT_BREAKPOINT = false;
|
||||
window.AT_BREAKPOINT = false
|
||||
|
||||
for (let miliSeconds = beginMiliseconds; miliSeconds < endMiliseconds; miliSeconds = miliSeconds + timePeriod) {
|
||||
for (let miliSeconds = beginMiliseconds; miliSeconds < endMiliseconds; miliSeconds = miliSeconds + timePeriod) {
|
||||
let breakpoint = breakpointsMap.get(miliSeconds)
|
||||
|
||||
let breakpoint = breakpointsMap.get(miliSeconds);
|
||||
if (breakpoint !== undefined) {
|
||||
let point1 = {
|
||||
x: miliSeconds,
|
||||
y: 0
|
||||
}
|
||||
|
||||
if (breakpoint !== undefined) {
|
||||
point1 = timeLineCoordinateSystem.transformThisPoint(point1)
|
||||
point1 = transformThisPoint(point1, chartContainer)
|
||||
|
||||
let point1 = {
|
||||
x: miliSeconds,
|
||||
y: 0
|
||||
}
|
||||
let point2 = {
|
||||
x: miliSeconds,
|
||||
y: thisObject.container.frame.height / 2 + 1
|
||||
}
|
||||
|
||||
point1 = timeLineCoordinateSystem.transformThisPoint(point1);
|
||||
point1 = transformThisPoint(point1, chartContainer);
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
|
||||
let point2 = {
|
||||
x: miliSeconds,
|
||||
y: thisObject.container.frame.height / 2 + 1
|
||||
}
|
||||
let point = {
|
||||
x: point1.x,
|
||||
y: point2.y
|
||||
}
|
||||
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2);
|
||||
let isCurrentRecord = false
|
||||
|
||||
let point = {
|
||||
x: point1.x,
|
||||
y: point2.y
|
||||
}
|
||||
if (datetime !== undefined) {
|
||||
let dateValue = datetime.valueOf()
|
||||
if (dateValue >= miliSeconds - timePeriod / 2 && dateValue <= miliSeconds + timePeriod / 2 - 1) {
|
||||
isCurrentRecord = true
|
||||
}
|
||||
}
|
||||
|
||||
let isCurrentRecord = false;
|
||||
let radius = 5
|
||||
|
||||
if (datetime !== undefined) {
|
||||
let dateValue = datetime.valueOf();
|
||||
if (dateValue >= miliSeconds - timePeriod / 2 && dateValue <= miliSeconds + timePeriod / 2 - 1) {
|
||||
isCurrentRecord = true;
|
||||
}
|
||||
}
|
||||
let opacity = '0.5'
|
||||
|
||||
let radius = 5;
|
||||
|
||||
let opacity = '0.5';
|
||||
|
||||
browserCanvasContext.lineWidth = 1;
|
||||
browserCanvasContext.lineWidth = 1
|
||||
|
||||
/* Outer Circle */
|
||||
|
||||
browserCanvasContext.beginPath();
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(123, 50, 40, ' + opacity + ')';
|
||||
browserCanvasContext.strokeStyle = 'rgba(123, 50, 40, ' + opacity + ')'
|
||||
|
||||
if (isCurrentRecord === false) {
|
||||
browserCanvasContext.fillStyle = 'rgba(223, 70, 60, ' + opacity + ')';
|
||||
} else {
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, ' + opacity + ')'; /* highlight the current record */
|
||||
if (isCurrentRecord === false) {
|
||||
browserCanvasContext.fillStyle = 'rgba(223, 70, 60, ' + opacity + ')'
|
||||
} else {
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, ' + opacity + ')' /* highlight the current record */
|
||||
|
||||
window.AT_BREAKPOINT = true; // We are hitting a breakpoint!
|
||||
}
|
||||
|
||||
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true);
|
||||
browserCanvasContext.closePath();
|
||||
|
||||
if (point.x < viewPort.visibleArea.topLeft.x + 50 || point.x > viewPort.visibleArea.bottomRight.x - 50) {/*we leave this history without fill. */ } else {
|
||||
browserCanvasContext.fill();
|
||||
}
|
||||
|
||||
browserCanvasContext.stroke();
|
||||
}
|
||||
window.AT_BREAKPOINT = true // We are hitting a breakpoint!
|
||||
}
|
||||
|
||||
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
if (point.x < viewPort.visibleArea.topLeft.x + 50 || point.x > viewPort.visibleArea.bottomRight.x - 50) { /* we leave this history without fill. */ } else {
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user