old code cleaned up

This commit is contained in:
Luis Fernando Molina committed 2019-10-07 16:09:35 +02:00
1 parent ec33648467
commit 340c0794ed
1 file changed
+10 -69
+10 -69
View File
@@ -86,41 +86,7 @@ function newPlottersManager () {
/* Listen to the event of change of status */
productsPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onProductCardStatusChanged)
initializeProductPlotters(onProductPlottersInitialized)
function onProductPlottersInitialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
initializationReady = true
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onProductPlottersInitialized -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
function initializeProductPlotters (callBack) {
try {
/* Lets get all the cards that needs to be loaded. */
/* Lets get all the cards that needs to be loaded. */
let initializationCounter = 0
let loadingProductCards = productsPanel.getLoadingProductCards()
@@ -128,11 +94,11 @@ function newPlottersManager () {
let failCounter = 0
if (loadingProductCards.length === 0) {
callBack(GLOBAL.DEFAULT_OK_RESPONSE)
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
return
}
for (let i = 0; i < loadingProductCards.length; i++) {
/* For each one, we will initialize the associated plotter. */
/* For each one, we will initialize the associated plotter. */
initializeProductPlotter(loadingProductCards[i], onProductPlotterInitialized)
function onProductPlotterInitialized (err) {
@@ -153,19 +119,19 @@ function newPlottersManager () {
}
}
if (initializationCounter === loadingProductCards.length) {
// This was the last one.
/* If less than 50% of plotters are initialized then we return FAIL. */
// This was the last one.
/* If less than 50% of plotters are initialized then we return FAIL. */
if (okCounter >= 1) {
callBack(GLOBAL.DEFAULT_OK_RESPONSE)
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
} else {
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotters -> err = ' + err.stack) }
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
@@ -238,7 +204,7 @@ function newPlottersManager () {
profile: undefined,
notes: undefined
}
/* Let the Plotter listen to the event of Cursor Files loaded, so that it can reack recalculating if needed. */
/* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */
storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded)
/* Lets load now this plotter panels. */
productPlotter.panels = []
@@ -261,27 +227,7 @@ function newPlottersManager () {
}
productPlotter.panels.push(plotterPanelHandle)
}
/* Create The Profie Picture FloatingObject */
if (productPlotter.plotter.payload !== undefined) {
let imageId = pProductCard.bot.devTeam + '.' + pProductCard.bot.profilePicture
productPlotter.plotter.payload.profile.subTitle = pProductCard.product.shortDisplayName
productPlotter.plotter.payload.profile.title = pProductCard.bot.displayName
productPlotter.plotter.payload.profile.imageId = imageId
productPlotter.plotter.payload.profile.botAvatar = pProductCard.bot.avatar
canvas.floatingSpace.profileBalls.createNewProfileBall(productPlotter.plotter.payload, onProfileBallCreated)
function onProfileBallCreated (err, pProfileHandle) {
productPlotter.profile = pProfileHandle
/* There is no policy yet of what to do if this fails. */
}
/* Create the Text Notes */
canvas.floatingSpace.noteSets.createNoteSet(productPlotter.plotter.payload, productPlotter.plotter.container.eventHandler, onNoteSetCreated)
function onNoteSetCreated (err, pNoteSetHandle) {
productPlotter.noteSet = pNoteSetHandle
/* There is no policy yet of what to do if this fails. */
}
}
/* Add the new Active Protter to the Array */
productPlotters.push(productPlotter)
callBack(GLOBAL.DEFAULT_OK_RESPONSE)
} catch (err) {
@@ -320,11 +266,6 @@ function newPlottersManager () {
/* If the plotter of this card is not on our Active Plotters list, then we remove it. */
for (let i = 0; i < productPlotters.length; i++) {
if (productPlotters[i].productCard.code === pProductCard.code) {
if (productPlotters[i].profile !== undefined) {
canvas.floatingSpace.profileBalls.destroyProfileBall(productPlotters[i].profile)
}
/* Destroyd the Note Set */
canvas.floatingSpace.noteSets.destroyNoteSet(productPlotters[i].noteSet)
/* Then the panels. */
for (let j = 0; j < productPlotters[i].panels.length; j++) {
canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j])