diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 752d890c9..87e963a56 100644 Binary files a/.vs/AAWebPlatform/v15/.suo and b/.vs/AAWebPlatform/v15/.suo differ diff --git a/Dashboard.js b/Dashboard.js index 5c2f4766d..43dccd81c 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -34,6 +34,32 @@ let dailyFilePeriods = dailyFilePeriods = JSON.parse(dailyFilePeriods); +function convertTimePeriodToName(pTimePeriod) { + + for (let i = 0; i < dailyFilePeriods.length; i++) { + + let period = dailyFilePeriods[i]; + + if (period[0] === pTimePeriod) { + + return period[1]; + + } + } + + for (let i = 0; i < marketFilesPeriods.length; i++) { + + let period = marketFilesPeriods[i]; + + if (period[0] === pTimePeriod) { + + return period[1]; + + } + } +} + + var viewPort = newViewPort(); diff --git a/FileCursor.js b/FileCursor.js index b16b759a3..5c71f822c 100644 --- a/FileCursor.js +++ b/FileCursor.js @@ -6,6 +6,7 @@ function newFileCursor() { let fileCursor = { setDatetime: setDatetime, + setTimePeriod: setTimePeriod, files: undefined, initialize: initialize } @@ -20,10 +21,11 @@ function newFileCursor() { let fileCloud; let product; let periodName; + let timePeriod; return fileCursor; - function initialize(pFileCloud, pProduct, pExchange, pMarket, pPeriodName, pCursorDate, callBackFunction) { + function initialize(pFileCloud, pProduct, pExchange, pMarket, pPeriodName, pCursorDate, pTimePeriod, callBackFunction) { market = pMarket; exchange = pExchange; @@ -31,11 +33,212 @@ function newFileCursor() { product = pProduct; periodName = pPeriodName; cursorDate = pCursorDate; + timePeriod = pTimePeriod; + + setTimePeriod(pTimePeriod); getFiles(callBackFunction); } + function setTimePeriod(pTimePeriod) { + + /* + + We are implementing here an algorithm designed to save bandwidth, memory and processing power at the browser. + We say there is a saving mode where the cursor is running at a minimum size. When the end user aproaches the time period the cursor + is set, then it should exit the saving mode and go to its actual size. + + To do this we are going to measure the distance from the Time Period received to the one the cursors was initialized with. + If these periods are consecutive, it means that the cursor should exit saving mode and load its full size. + + */ + + let positionA; + + for (let i = 0; i < dailyFilePeriods.length; i++) { + + let period = dailyFilePeriods[i]; + + if (period[0] === pTimePeriod) { + + positionA = i; + + } + + if (period[0] === timePeriod) { + + positionB = i; + + } + } + + if (Math.abs(positionB - positionA) <= 1) { + + exitSavingMode(); + console.log("File Cursor with period " + periodName + " EXITED saving mode after being notified the user is at period " + convertTimePeriodToName(pTimePeriod)); + + } else { + + enterSavingMode(); + console.log("File Cursor with period " + periodName + " ENTERED saving mode after being notified the user is at period " + convertTimePeriodToName(pTimePeriod)); + + } + + + function enterSavingMode() { + + switch (timePeriod) { + + case _45_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 30; + } + break; + case _40_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 20; + } + break; + case _30_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _20_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _15_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _10_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _5_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _4_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _3_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _2_MINUTES_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + case _1_MINUTE_IN_MILISECONDS: + { + minCursorSize = 1; + maxCursorSize = 15; + } + break; + default: + } + } + + function exitSavingMode() { + + switch (timePeriod) { + + case _45_MINUTES_IN_MILISECONDS: + { + minCursorSize = 10; + maxCursorSize = 30; + } + break; + case _40_MINUTES_IN_MILISECONDS: + { + minCursorSize = 8; + maxCursorSize = 20; + } + break; + case _30_MINUTES_IN_MILISECONDS: + { + minCursorSize = 6; + maxCursorSize = 15; + } + break; + case _20_MINUTES_IN_MILISECONDS: + { + minCursorSize = 5; + maxCursorSize = 15; + } + break; + case _15_MINUTES_IN_MILISECONDS: + { + minCursorSize = 5; + maxCursorSize = 15; + } + break; + case _10_MINUTES_IN_MILISECONDS: + { + minCursorSize = 5; + maxCursorSize = 15; + } + break; + case _5_MINUTES_IN_MILISECONDS: + { + minCursorSize = 3; + maxCursorSize = 15; + } + break; + case _4_MINUTES_IN_MILISECONDS: + { + minCursorSize = 3; + maxCursorSize = 15; + } + break; + case _3_MINUTES_IN_MILISECONDS: + { + minCursorSize = 3; + maxCursorSize = 15; + } + break; + case _2_MINUTES_IN_MILISECONDS: + { + minCursorSize = 3; + maxCursorSize = 15; + } + break; + case _1_MINUTE_IN_MILISECONDS: + { + minCursorSize = 3; + maxCursorSize = 15; + } + break; + default: + } + } + + + } + + + function setDatetime(datetime) { if (datetime === undefined) { return; } diff --git a/FileCursorCache.js b/FileCursorCache.js index eaa283df4..24c89c631 100644 --- a/FileCursorCache.js +++ b/FileCursorCache.js @@ -12,11 +12,9 @@ function newFileCursorCache() { let marketFiles = new Map; let fileCursors = new Map; - let datetime; - return fileCursorCache; - function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, pDatetime, callBackFunction) { + function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pLayerCodeName, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { let product = ecosystem.getProduct(ecosystem.getBot(ecosystem.getTeam(pTeamCodeName), pBotCodeName), pProductCodeName); @@ -55,7 +53,7 @@ function newFileCursorCache() { if (layer.validPeriods.includes(periodName) === true) { let fileCursor = newFileCursor(); - fileCursor.initialize(fileCloud, product, exchange, pMarket, periodName, pDatetime, onFileReceived); + fileCursor.initialize(fileCloud, product, exchange, pMarket, periodName, pDatetime, pTimePeriod, onFileReceived); fileCursors.set(periodTime, fileCursor); @@ -74,15 +72,24 @@ function newFileCursorCache() { } - function setDatetime(newDatetime) { - - datetime = newDatetime; + function setDatetime(pDatetime) { fileCursors.forEach(setDatetimeToEach) function setDatetimeToEach(value, key, map) { - value.setDatetime(newDatetime); + value.setDatetime(pDatetime); + + } + } + + function setTimePeriod(pTimePeriod) { + + fileCursors.forEach(setTimePeriodToEach) + + function setTimePeriodToEach(value, key, map) { + + value.setTimePeriod(pTimePeriod); } }