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
+649
-789
File diff suppressed because it is too large.
Load diff
+185
-219
@@ -1,274 +1,240 @@
|
||||
|
||||
function newFloatingObject() {
|
||||
|
||||
function newFloatingObject () {
|
||||
const MODULE_NAME = 'Floating Object'
|
||||
const INFO_LOG = false
|
||||
const INTENSIVE_LOG = false
|
||||
const ERROR_LOG = true
|
||||
|
||||
const MODULE_NAME = "Floating Object";
|
||||
const INFO_LOG = false;
|
||||
const INTENSIVE_LOG = false;
|
||||
const ERROR_LOG = true;
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
const logger = newWebDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
var thisObject = {
|
||||
|
||||
var thisObject = {
|
||||
physicsLoop: physicsLoop,
|
||||
eventHandler: undefined,
|
||||
|
||||
physicsLoop: physicsLoop,
|
||||
eventHandler: undefined,
|
||||
payload: undefined, // This is a reference to an object controlled by a Plotter. The plotter can change its internal value and we will see them from here.
|
||||
type: undefined, // Currently there are two types of Floating Objects: Profile Balls, and Notes.
|
||||
|
||||
payload: undefined, // This is a reference to an object controlled by a Plotter. The plotter can change its internal value and we will see them from here.
|
||||
type: undefined, // Currently there are two types of Floating Objects: Profile Balls, and Notes.
|
||||
physicsEnabled: false,
|
||||
|
||||
physicsEnabled: false,
|
||||
initializeMass: initializeMass,
|
||||
initializeRadius: initializeRadius,
|
||||
initializeImageSize: initializeImageSize,
|
||||
initializeFontSize: initializeFontSize,
|
||||
|
||||
initializeMass: initializeMass,
|
||||
initializeRadius: initializeRadius,
|
||||
initializeImageSize: initializeImageSize,
|
||||
initializeFontSize: initializeFontSize,
|
||||
imageId: undefined,
|
||||
|
||||
imageId: undefined,
|
||||
currentPosition: 0, // Current x,y position of the floating object at the floating object's layer, where there is no displacement or zoom. This position is always changing towards the target position.
|
||||
currentSpeed: 0, // This is the current speed of the floating object.
|
||||
currentRadius: 0, // This is the current radius of the floating object, including its zoom applied.
|
||||
currentMass: 0, // This is the current mass of the floating object, including its zoom applied.
|
||||
|
||||
currentPosition: 0, // Current x,y position of the floating object at the floating object's layer, where there is no displacement or zoom. This position is always changing towards the target position.
|
||||
currentSpeed: 0, // This is the current speed of the floating object.
|
||||
currentRadius: 0, // This is the current radius of the floating object, including its zoom applied.
|
||||
currentMass: 0, // This is the current mass of the floating object, including its zoom applied.
|
||||
friction: 0, // This is a factor that will ultimatelly desacelerate the floating object.
|
||||
|
||||
friction: 0, // This is a factor that will ultimatelly desacelerate the floating object.
|
||||
rawMass: 0, // This is the mass value without zoom.
|
||||
rawRadius: 0, // This is the radius of this floating object without zoom.
|
||||
|
||||
rawMass: 0, // This is the mass value without zoom.
|
||||
rawRadius: 0, // This is the radius of this floating object without zoom.
|
||||
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
|
||||
|
||||
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
|
||||
fillStyle: '',
|
||||
|
||||
fillStyle: '',
|
||||
labelStrokeStyle: '',
|
||||
|
||||
labelStrokeStyle: '',
|
||||
radomizeCurrentPosition: radomizeCurrentPosition,
|
||||
radomizeCurrentSpeed: radomizeCurrentSpeed,
|
||||
|
||||
radomizeCurrentPosition: radomizeCurrentPosition,
|
||||
radomizeCurrentSpeed: radomizeCurrentSpeed,
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
updateMass: updateMass, // Function to update the mass when the zoom level changed.
|
||||
updateRadius: updateRadius, // Function to update the radius when the zoom level changed.
|
||||
|
||||
updateMass: updateMass, // Function to update the mass when the zoom level changed.
|
||||
updateRadius: updateRadius, // Function to update the radius when the zoom level changed.
|
||||
linkedObject: undefined, // This is a reference to the object that this floating object is representing.
|
||||
linkedObjectType: '', // Since there might be floating objects for different types of objects, here we store the type of object we are linking to.
|
||||
|
||||
linkedObject: undefined, // This is a reference to the object that this floating object is representing.
|
||||
linkedObjectType: "", // Since there might be floating objects for different types of objects, here we store the type of object we are linking to.
|
||||
container: undefined, // This is a pointer to the object where the floating object belongs to.
|
||||
initialize: initialize
|
||||
|
||||
container: undefined, // This is a pointer to the object where the floating object belongs to.
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
};
|
||||
let underlayingObject
|
||||
|
||||
let underlayingObject;
|
||||
thisObject.eventHandler = newEventHandler()
|
||||
|
||||
thisObject.eventHandler = newEventHandler();
|
||||
return thisObject
|
||||
|
||||
return thisObject;
|
||||
function initialize (pType, callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
function initialize(pType, callBackFunction) {
|
||||
switch (pType) {
|
||||
|
||||
try {
|
||||
case 'Profile Ball': {
|
||||
underlayingObject = newProfileBall()
|
||||
underlayingObject.initialize(onInitialized)
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
function onInitialized (err) {
|
||||
|
||||
switch (pType) {
|
||||
}
|
||||
|
||||
case "Profile Ball": {
|
||||
|
||||
underlayingObject = newProfileBall();
|
||||
underlayingObject.initialize(onInitialized);
|
||||
|
||||
function onInitialized(err) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "Note": {
|
||||
|
||||
underlayingObject = newNote();
|
||||
underlayingObject.initialize(onInitialized);
|
||||
|
||||
function onInitialized(err) {
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
thisObject.type = pType;
|
||||
|
||||
thisObject.eventHandler.listenToEvent("onMouseOver", onMouseOver);
|
||||
canvas.eventHandler.listenToEvent("onMouseNotOver", onMouseNotOver);
|
||||
thisObject.eventHandler.listenToEvent("onMouseClick", onMouseClick);
|
||||
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); }
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err.message = " + err.message); }
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); }
|
||||
break
|
||||
}
|
||||
}
|
||||
case 'Note': {
|
||||
underlayingObject = newNote()
|
||||
underlayingObject.initialize(onInitialized)
|
||||
|
||||
function physicsLoop(callBackFunction) {
|
||||
function onInitialized (err) {
|
||||
|
||||
try {
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
|
||||
underlayingObject.physicsLoop();
|
||||
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); }
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] physicsLoop -> err.message = " + err.message); }
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); }
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseOver() {
|
||||
|
||||
thisObject.targetRadius = thisObject.rawRadius * 1.5;
|
||||
thisObject.targetImageSize = thisObject.rawImageSize * 1.5;
|
||||
thisObject.targetFontSize = thisObject.rawFontSize * 1.5;
|
||||
|
||||
underlayingObject.onMouseOver();
|
||||
}
|
||||
|
||||
function onMouseNotOver() {
|
||||
|
||||
thisObject.targetRadius = thisObject.rawRadius * 1;
|
||||
thisObject.targetImageSize = thisObject.rawImageSize * 1;
|
||||
thisObject.targetFontSize = thisObject.rawFontSize * 1;
|
||||
|
||||
underlayingObject.onMouseNotOver();
|
||||
}
|
||||
|
||||
function onMouseClick(pPoint) {
|
||||
|
||||
underlayingObject.onMouseClick(pPoint, thisObject);
|
||||
|
||||
}
|
||||
|
||||
function drawBackground() {
|
||||
|
||||
underlayingObject.drawBackground(thisObject);
|
||||
|
||||
}
|
||||
|
||||
function drawForeground() {
|
||||
|
||||
underlayingObject.drawForeground(thisObject);
|
||||
|
||||
}
|
||||
|
||||
function initializeMass(suggestedValue) {
|
||||
|
||||
var mass = suggestedValue;
|
||||
if (mass < 0.1) {
|
||||
mass = 0.1;
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
thisObject.rawMass = mass;
|
||||
thisObject.currentMass = mass;
|
||||
|
||||
}
|
||||
|
||||
function initializeRadius(suggestedValue) {
|
||||
|
||||
var radius = suggestedValue;
|
||||
if (radius < 2) {
|
||||
radius = 2;
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
thisObject.rawRadius = radius;
|
||||
thisObject.targetRadius = radius;
|
||||
thisObject.currentRadius = radius / 3;
|
||||
thisObject.type = pType
|
||||
|
||||
thisObject.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
canvas.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
thisObject.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err.message = ' + err.message) }
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) }
|
||||
}
|
||||
}
|
||||
|
||||
function physicsLoop (callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
underlayingObject.physicsLoop()
|
||||
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] physicsLoop -> err.message = ' + err.message) }
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) }
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseOver () {
|
||||
thisObject.targetRadius = thisObject.rawRadius * 1.5
|
||||
thisObject.targetImageSize = thisObject.rawImageSize * 1.5
|
||||
thisObject.targetFontSize = thisObject.rawFontSize * 1.5
|
||||
|
||||
underlayingObject.onMouseOver()
|
||||
}
|
||||
|
||||
function onMouseNotOver () {
|
||||
thisObject.targetRadius = thisObject.rawRadius * 1
|
||||
thisObject.targetImageSize = thisObject.rawImageSize * 1
|
||||
thisObject.targetFontSize = thisObject.rawFontSize * 1
|
||||
|
||||
underlayingObject.onMouseNotOver()
|
||||
}
|
||||
|
||||
function onMouseClick (pPoint) {
|
||||
underlayingObject.onMouseClick(pPoint, thisObject)
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
underlayingObject.drawBackground(thisObject)
|
||||
}
|
||||
|
||||
function drawForeground () {
|
||||
underlayingObject.drawForeground(thisObject)
|
||||
}
|
||||
|
||||
function initializeMass (suggestedValue) {
|
||||
var mass = suggestedValue
|
||||
if (mass < 0.1) {
|
||||
mass = 0.1
|
||||
}
|
||||
|
||||
function initializeImageSize(suggestedValue) {
|
||||
|
||||
var size = suggestedValue;
|
||||
if (size < 2) {
|
||||
size = 2;
|
||||
}
|
||||
|
||||
thisObject.rawImageSize = size;
|
||||
thisObject.targetImageSize = size;
|
||||
thisObject.currentImageSize = size / 3;
|
||||
thisObject.rawMass = mass
|
||||
thisObject.currentMass = mass
|
||||
}
|
||||
|
||||
function initializeRadius (suggestedValue) {
|
||||
var radius = suggestedValue
|
||||
if (radius < 2) {
|
||||
radius = 2
|
||||
}
|
||||
|
||||
function initializeFontSize(suggestedValue) {
|
||||
|
||||
var size = suggestedValue;
|
||||
if (size < 3) {
|
||||
size = 3;
|
||||
}
|
||||
|
||||
thisObject.rawFontSize = size;
|
||||
thisObject.targetFontSize = size;
|
||||
thisObject.currentFontSize = size / 3;
|
||||
thisObject.rawRadius = radius
|
||||
thisObject.targetRadius = radius
|
||||
thisObject.currentRadius = radius / 3
|
||||
}
|
||||
|
||||
function initializeImageSize (suggestedValue) {
|
||||
var size = suggestedValue
|
||||
if (size < 2) {
|
||||
size = 2
|
||||
}
|
||||
|
||||
function radomizeCurrentPosition(arroundPoint) {
|
||||
thisObject.rawImageSize = size
|
||||
thisObject.targetImageSize = size
|
||||
thisObject.currentImageSize = size / 3
|
||||
}
|
||||
|
||||
var position = {
|
||||
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
|
||||
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
|
||||
};
|
||||
|
||||
thisObject.currentPosition = position;
|
||||
function initializeFontSize (suggestedValue) {
|
||||
var size = suggestedValue
|
||||
if (size < 3) {
|
||||
size = 3
|
||||
}
|
||||
|
||||
function radomizeCurrentSpeed() {
|
||||
thisObject.rawFontSize = size
|
||||
thisObject.targetFontSize = size
|
||||
thisObject.currentFontSize = size / 3
|
||||
}
|
||||
|
||||
var initialXDirection;
|
||||
var randomX = Math.floor((Math.random() * 10) + 1);
|
||||
if (randomX > 5) {
|
||||
initialXDirection = 1;
|
||||
} else {
|
||||
initialXDirection = - 1;
|
||||
}
|
||||
|
||||
var initialYDirection;
|
||||
var randomY = Math.floor((Math.random() * 10) + 1);
|
||||
if (randomY > 5) {
|
||||
initialYDirection = 1;
|
||||
} else {
|
||||
initialYDirection = - 1;
|
||||
}
|
||||
|
||||
var velocity = {
|
||||
x: initialXDirection * Math.floor((Math.random() * 300) + 1) / 100,
|
||||
y: initialYDirection * Math.floor((Math.random() * 300) + 1) / 100
|
||||
};
|
||||
|
||||
thisObject.currentSpeed = velocity;
|
||||
function radomizeCurrentPosition (arroundPoint) {
|
||||
var position = {
|
||||
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
|
||||
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
|
||||
}
|
||||
|
||||
function updateMass() {
|
||||
|
||||
//thisObject.currentMass = thisObject.rawMass + thisObject.rawMass * thisObject.container.zoom.incrementM * thisObject.container.zoom.levelM;
|
||||
thisObject.currentPosition = position
|
||||
}
|
||||
|
||||
function radomizeCurrentSpeed () {
|
||||
var initialXDirection
|
||||
var randomX = Math.floor((Math.random() * 10) + 1)
|
||||
if (randomX > 5) {
|
||||
initialXDirection = 1
|
||||
} else {
|
||||
initialXDirection = -1
|
||||
}
|
||||
|
||||
function updateRadius() {
|
||||
|
||||
//thisObject.targetRadius = thisObject.rawRadius + thisObject.rawRadius * thisObject.container.zoom.incrementR * thisObject.container.zoom.levelR;
|
||||
|
||||
var initialYDirection
|
||||
var randomY = Math.floor((Math.random() * 10) + 1)
|
||||
if (randomY > 5) {
|
||||
initialYDirection = 1
|
||||
} else {
|
||||
initialYDirection = -1
|
||||
}
|
||||
|
||||
var velocity = {
|
||||
x: initialXDirection * Math.floor((Math.random() * 300) + 1) / 100,
|
||||
y: initialYDirection * Math.floor((Math.random() * 300) + 1) / 100
|
||||
}
|
||||
|
||||
thisObject.currentSpeed = velocity
|
||||
}
|
||||
|
||||
function updateMass () {
|
||||
|
||||
// thisObject.currentMass = thisObject.rawMass + thisObject.rawMass * thisObject.container.zoom.incrementM * thisObject.container.zoom.levelM;
|
||||
|
||||
}
|
||||
|
||||
function updateRadius () {
|
||||
|
||||
// thisObject.targetRadius = thisObject.rawRadius + thisObject.rawRadius * thisObject.container.zoom.incrementR * thisObject.container.zoom.levelR;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+212
-244
@@ -1,336 +1,304 @@
|
||||
|
||||
function newNote() {
|
||||
|
||||
function newNote () {
|
||||
var thisObject = {
|
||||
|
||||
var thisObject = {
|
||||
physicsLoop: physicsLoop,
|
||||
onMouseOver: onMouseOver,
|
||||
onMouseClick: onMouseClick,
|
||||
onMouseNotOver: onMouseNotOver,
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
initialize: initialize
|
||||
|
||||
physicsLoop: physicsLoop,
|
||||
onMouseOver: onMouseOver,
|
||||
onMouseClick: onMouseClick,
|
||||
onMouseNotOver: onMouseNotOver,
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
};
|
||||
return thisObject
|
||||
|
||||
return thisObject;
|
||||
function initialize (callBackFunction) {
|
||||
callBackFunction()
|
||||
}
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
function physicsLoop () {
|
||||
|
||||
callBackFunction();
|
||||
}
|
||||
|
||||
function onMouseOver () {
|
||||
|
||||
}
|
||||
|
||||
function onMouseNotOver () {
|
||||
|
||||
}
|
||||
|
||||
function onMouseClick (pPoint, pFloatingObject) {
|
||||
|
||||
}
|
||||
|
||||
function drawBackground (pFloatingObject) {
|
||||
let point = {
|
||||
x: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x,
|
||||
y: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y
|
||||
}
|
||||
|
||||
function physicsLoop() {
|
||||
|
||||
}
|
||||
|
||||
function onMouseOver() {
|
||||
|
||||
}
|
||||
|
||||
function onMouseNotOver() {
|
||||
|
||||
}
|
||||
|
||||
function onMouseClick(pPoint, pFloatingObject) {
|
||||
|
||||
}
|
||||
|
||||
function drawBackground(pFloatingObject) {
|
||||
|
||||
let point = {
|
||||
x: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x,
|
||||
y: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y
|
||||
};
|
||||
|
||||
point = viewPort.fitIntoVisibleArea(point);
|
||||
|
||||
if (pFloatingObject.currentRadius > 1) {
|
||||
point = viewPort.fitIntoVisibleArea(point)
|
||||
|
||||
if (pFloatingObject.currentRadius > 1) {
|
||||
/* Target Line */
|
||||
|
||||
browserCanvasContext.beginPath();
|
||||
browserCanvasContext.moveTo(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y);
|
||||
browserCanvasContext.lineTo(point.x, point.y);
|
||||
browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)';
|
||||
browserCanvasContext.setLineDash([4, 2]);
|
||||
browserCanvasContext.lineWidth = 1;
|
||||
browserCanvasContext.stroke();
|
||||
browserCanvasContext.setLineDash([0, 0]);
|
||||
|
||||
}
|
||||
|
||||
if (pFloatingObject.currentRadius > 0.5) {
|
||||
|
||||
/* Target Spot */
|
||||
|
||||
var radius = 1;
|
||||
|
||||
browserCanvasContext.beginPath();
|
||||
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true);
|
||||
browserCanvasContext.closePath();
|
||||
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)';
|
||||
browserCanvasContext.fill();
|
||||
|
||||
}
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y)
|
||||
browserCanvasContext.lineTo(point.x, point.y)
|
||||
browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)'
|
||||
browserCanvasContext.setLineDash([4, 2])
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
browserCanvasContext.setLineDash([0, 0])
|
||||
}
|
||||
|
||||
function drawForeground(pFloatingObject) {
|
||||
if (pFloatingObject.currentRadius > 0.5) {
|
||||
/* Target Spot */
|
||||
|
||||
const BUBBLE_CORNERS_RADIOUS = 5;
|
||||
const TITLE_BAR_HEIGHT = 14;
|
||||
var radius = 1
|
||||
|
||||
const BUBBLE_WIDTH = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 4;
|
||||
const BUBBLE_HEIGHT = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 2;
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)'
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
}
|
||||
|
||||
let borderPoint1;
|
||||
let borderPoint2;
|
||||
let borderPoint3;
|
||||
let borderPoint4;
|
||||
function drawForeground (pFloatingObject) {
|
||||
const BUBBLE_CORNERS_RADIOUS = 5
|
||||
const TITLE_BAR_HEIGHT = 14
|
||||
|
||||
let intialDisplace = {
|
||||
x: pFloatingObject.currentPosition.x - BUBBLE_WIDTH / 2,
|
||||
y: pFloatingObject.currentPosition.y - BUBBLE_HEIGHT / 2
|
||||
}
|
||||
const BUBBLE_WIDTH = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 4
|
||||
const BUBBLE_HEIGHT = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 2
|
||||
|
||||
if (pFloatingObject.currentRadius > 5) {
|
||||
let borderPoint1
|
||||
let borderPoint2
|
||||
let borderPoint3
|
||||
let borderPoint4
|
||||
|
||||
let intialDisplace = {
|
||||
x: pFloatingObject.currentPosition.x - BUBBLE_WIDTH / 2,
|
||||
y: pFloatingObject.currentPosition.y - BUBBLE_HEIGHT / 2
|
||||
}
|
||||
|
||||
if (pFloatingObject.currentRadius > 5) {
|
||||
/* Rounded Background */
|
||||
|
||||
borderPoint1 = {
|
||||
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
||||
};
|
||||
borderPoint1 = {
|
||||
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
||||
}
|
||||
|
||||
borderPoint2 = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
||||
};
|
||||
borderPoint2 = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
||||
}
|
||||
|
||||
borderPoint3 = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
||||
};
|
||||
borderPoint3 = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
||||
}
|
||||
|
||||
borderPoint4 = {
|
||||
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
||||
};
|
||||
borderPoint4 = {
|
||||
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
||||
y: intialDisplace.y + +BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
||||
}
|
||||
|
||||
titleBarPoint1 = {
|
||||
x: intialDisplace.x + 0,
|
||||
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
||||
};
|
||||
titleBarPoint1 = {
|
||||
x: intialDisplace.x + 0,
|
||||
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
||||
}
|
||||
|
||||
titleBarPoint2 = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH,
|
||||
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
||||
};
|
||||
titleBarPoint2 = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH,
|
||||
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
||||
}
|
||||
|
||||
/* We paint the panel background first */
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 249, 196, 0.75)';
|
||||
browserCanvasContext.beginPath();
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 249, 196, 0.75)'
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI);
|
||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS);
|
||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI);
|
||||
browserCanvasContext.lineTo(borderPoint3.x + BUBBLE_CORNERS_RADIOUS, borderPoint3.y);
|
||||
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, BUBBLE_CORNERS_RADIOUS, 0 * Math.PI, 0.5 * Math.PI);
|
||||
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + BUBBLE_CORNERS_RADIOUS);
|
||||
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, BUBBLE_CORNERS_RADIOUS, 0.5 * Math.PI, 1.0 * Math.PI);
|
||||
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y);
|
||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI)
|
||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS)
|
||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI)
|
||||
browserCanvasContext.lineTo(borderPoint3.x + BUBBLE_CORNERS_RADIOUS, borderPoint3.y)
|
||||
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, BUBBLE_CORNERS_RADIOUS, 0 * Math.PI, 0.5 * Math.PI)
|
||||
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + BUBBLE_CORNERS_RADIOUS)
|
||||
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, BUBBLE_CORNERS_RADIOUS, 0.5 * Math.PI, 1.0 * Math.PI)
|
||||
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y)
|
||||
|
||||
browserCanvasContext.closePath();
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.fill();
|
||||
browserCanvasContext.fill()
|
||||
|
||||
browserCanvasContext.lineWidth = 0.1;
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)';
|
||||
browserCanvasContext.stroke();
|
||||
browserCanvasContext.lineWidth = 0.1
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)'
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
/* We paint the title bar now */
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(244, 224, 44, 0.75)';
|
||||
browserCanvasContext.beginPath();
|
||||
browserCanvasContext.fillStyle = 'rgba(244, 224, 44, 0.75)'
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y);
|
||||
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y);
|
||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI);
|
||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS);
|
||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI);
|
||||
browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y);
|
||||
browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y)
|
||||
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y)
|
||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI)
|
||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS)
|
||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI)
|
||||
browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y)
|
||||
|
||||
browserCanvasContext.closePath();
|
||||
browserCanvasContext.fill();
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fill()
|
||||
|
||||
browserCanvasContext.lineWidth = 0.1;
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 0.75)';
|
||||
browserCanvasContext.stroke();
|
||||
|
||||
}
|
||||
|
||||
if (pFloatingObject.currentRadius > 0.5) {
|
||||
browserCanvasContext.lineWidth = 0.1
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 0.75)'
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
|
||||
if (pFloatingObject.currentRadius > 0.5) {
|
||||
/* Image */
|
||||
|
||||
let imagePosition = {
|
||||
x: pFloatingObject.currentPosition.x,
|
||||
y: pFloatingObject.currentPosition.y + BUBBLE_HEIGHT / 2
|
||||
};
|
||||
let imagePosition = {
|
||||
x: pFloatingObject.currentPosition.x,
|
||||
y: pFloatingObject.currentPosition.y + BUBBLE_HEIGHT / 2
|
||||
}
|
||||
|
||||
if (pFloatingObject.payloadImageId !== undefined) {
|
||||
if (pFloatingObject.payloadImageId !== undefined) {
|
||||
let image = document.getElementById(pFloatingObject.payloadImageId)
|
||||
|
||||
let image = document.getElementById(pFloatingObject.payloadImageId);
|
||||
|
||||
if (image !== null) {
|
||||
|
||||
browserCanvasContext.drawImage(image, imagePosition.x - pFloatingObject.currentImageSize / 2, imagePosition.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize, pFloatingObject.currentImageSize);
|
||||
|
||||
}
|
||||
}
|
||||
if (image !== null) {
|
||||
browserCanvasContext.drawImage(image, imagePosition.x - pFloatingObject.currentImageSize / 2, imagePosition.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize, pFloatingObject.currentImageSize)
|
||||
}
|
||||
}
|
||||
|
||||
/* Image Contourn */
|
||||
|
||||
browserCanvasContext.beginPath();
|
||||
browserCanvasContext.arc(imagePosition.x, imagePosition.y, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true);
|
||||
browserCanvasContext.closePath();
|
||||
browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.25)';
|
||||
browserCanvasContext.lineWidth = 1;
|
||||
browserCanvasContext.stroke();
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.arc(imagePosition.x, imagePosition.y, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true)
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.25)'
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
/* Labels */
|
||||
|
||||
if (pFloatingObject.currentRadius > 6) {
|
||||
if (pFloatingObject.currentRadius > 6) {
|
||||
browserCanvasContext.strokeStyle = pFloatingObject.labelStrokeStyle
|
||||
|
||||
browserCanvasContext.strokeStyle = pFloatingObject.labelStrokeStyle;
|
||||
const SIZE_PERCENTAGE = Math.trunc(pFloatingObject.currentRadius / pFloatingObject.targetRadius * 100) / 100
|
||||
let ALPHA
|
||||
|
||||
const SIZE_PERCENTAGE = Math.trunc(pFloatingObject.currentRadius / pFloatingObject.targetRadius * 100) / 100;
|
||||
let ALPHA;
|
||||
if (pFloatingObject.targetRadius > 0) {
|
||||
ALPHA = 0.5 - (1 - SIZE_PERCENTAGE) * 5
|
||||
} else {
|
||||
// Object is dying...
|
||||
|
||||
if (pFloatingObject.targetRadius > 0) {
|
||||
ALPHA = Math.trunc((0.5 - (100 - pFloatingObject.currentRadius / 100)) * 100) / 100
|
||||
|
||||
ALPHA = 0.5 - (1 - SIZE_PERCENTAGE) * 5;
|
||||
if (ALPHA < 0) { ALPHA = 0 }
|
||||
}
|
||||
|
||||
} else { // Object is dying...
|
||||
let labelPoint
|
||||
let fontSize = 10
|
||||
|
||||
ALPHA = Math.trunc((0.5 - (100 - pFloatingObject.currentRadius / 100) ) * 100) / 100;
|
||||
|
||||
if (ALPHA < 0) { ALPHA = 0}
|
||||
|
||||
}
|
||||
|
||||
let labelPoint;
|
||||
let fontSize = 10;
|
||||
|
||||
let label;
|
||||
let label
|
||||
|
||||
/* print the title */
|
||||
|
||||
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].title;
|
||||
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].title
|
||||
|
||||
if (label !== undefined) {
|
||||
if (label !== undefined) {
|
||||
if (SIZE_PERCENTAGE > 0.9) {
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||
|
||||
if (SIZE_PERCENTAGE > 0.9) {
|
||||
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO
|
||||
let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
||||
labelPoint = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH / 2 - xOffset,
|
||||
y: intialDisplace.y + TITLE_BAR_HEIGHT - yOffset
|
||||
}
|
||||
|
||||
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO;
|
||||
let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2;
|
||||
|
||||
labelPoint = {
|
||||
x: intialDisplace.x + BUBBLE_WIDTH / 2 - xOffset,
|
||||
y: intialDisplace.y + TITLE_BAR_HEIGHT - yOffset
|
||||
};
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, ' + ALPHA + ')'
|
||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
||||
|
||||
}
|
||||
}
|
||||
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, ' + ALPHA + ')'
|
||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||
}
|
||||
}
|
||||
|
||||
/* Message Body */
|
||||
|
||||
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].body;
|
||||
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].body
|
||||
|
||||
if (label !== undefined) {
|
||||
if (label !== undefined) {
|
||||
const WORDS_PER_ROW = 5
|
||||
const TOTAL_ROWS = 5
|
||||
|
||||
const WORDS_PER_ROW = 5;
|
||||
const TOTAL_ROWS = 5;
|
||||
|
||||
if (SIZE_PERCENTAGE > 0.9) {
|
||||
|
||||
let rawLabelArray = label.split(" ");
|
||||
let labelArray = [];
|
||||
if (SIZE_PERCENTAGE > 0.9) {
|
||||
let rawLabelArray = label.split(' ')
|
||||
let labelArray = []
|
||||
|
||||
/* Lets check when words are to long we add an empty space to the same line so as to roll all other words forward. */
|
||||
|
||||
for (let i = 0; i < rawLabelArray.length; i++) {
|
||||
for (let i = 0; i < rawLabelArray.length; i++) {
|
||||
let word = rawLabelArray[i]
|
||||
|
||||
let word = rawLabelArray[i];
|
||||
labelArray.push(word)
|
||||
|
||||
labelArray.push(word);
|
||||
if (word.length > 8) {
|
||||
labelArray.push('')
|
||||
}
|
||||
|
||||
if (word.length > 8) {
|
||||
labelArray.push("");
|
||||
}
|
||||
|
||||
if (word.length > 10) {
|
||||
labelArray.push("");
|
||||
}
|
||||
}
|
||||
if (word.length > 10) {
|
||||
labelArray.push('')
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate each ROW */
|
||||
|
||||
let labelRows = [];
|
||||
let labelRows = []
|
||||
|
||||
for (let i = 0; i < TOTAL_ROWS; i++) {
|
||||
for (let i = 0; i < TOTAL_ROWS; i++) {
|
||||
let labelRow = ''
|
||||
|
||||
let labelRow = "";
|
||||
for (let j = 0; j < WORDS_PER_ROW; j++) {
|
||||
let newWord = labelArray[j + i * WORDS_PER_ROW]
|
||||
|
||||
for (let j = 0; j < WORDS_PER_ROW; j++) {
|
||||
if (newWord !== undefined && newWord !== '') {
|
||||
labelRow = labelRow + ' ' + newWord
|
||||
}
|
||||
}
|
||||
|
||||
let newWord = labelArray[j + i * WORDS_PER_ROW];
|
||||
|
||||
if (newWord !== undefined && newWord !== "") {
|
||||
|
||||
labelRow = labelRow + " " + newWord;
|
||||
}
|
||||
}
|
||||
|
||||
if (labelRow !== "") {
|
||||
|
||||
labelRows.push(labelRow);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (labelRow !== '') {
|
||||
labelRows.push(labelRow)
|
||||
}
|
||||
}
|
||||
|
||||
/* Now we plot each row. */
|
||||
|
||||
for (let i = 0; i < labelRows.length; i++) {
|
||||
for (let i = 0; i < labelRows.length; i++) {
|
||||
let labelRow = labelRows[i]
|
||||
|
||||
let labelRow = labelRows[i];
|
||||
let startingPosition = {
|
||||
x: pFloatingObject.currentPosition.x,
|
||||
y: pFloatingObject.currentPosition.y - labelRows.length / 2 * (fontSize * FONT_ASPECT_RATIO + 10)
|
||||
}
|
||||
|
||||
let startingPosition = {
|
||||
x: pFloatingObject.currentPosition.x,
|
||||
y: pFloatingObject.currentPosition.y - labelRows.length / 2 * (fontSize * FONT_ASPECT_RATIO + 10)
|
||||
};
|
||||
labelPoint = {
|
||||
x: startingPosition.x - labelRow.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
||||
y: startingPosition.y + (i + 1) * (fontSize * FONT_ASPECT_RATIO + 10)
|
||||
}
|
||||
|
||||
labelPoint = {
|
||||
x: startingPosition.x - labelRow.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
||||
y: startingPosition.y + (i + 1) * (fontSize * FONT_ASPECT_RATIO + 10)
|
||||
};
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
||||
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, ' + ALPHA + ')'
|
||||
browserCanvasContext.fillText(labelRow, labelPoint.x, labelPoint.y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, ' + ALPHA + ')'
|
||||
browserCanvasContext.fillText(labelRow, labelPoint.x, labelPoint.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+186
-222
@@ -1,6 +1,5 @@
|
||||
|
||||
function newNoteSets() {
|
||||
|
||||
|
||||
function newNoteSets () {
|
||||
/*
|
||||
Different plotters will identify sets of notes whithin the data they are plotting. They will create with them arrays of Notes data.
|
||||
On the other hand the floating space, and a floting layer in particular, manages Notes floating objects, which are visible entities
|
||||
@@ -14,48 +13,43 @@ function newNoteSets() {
|
||||
This module is capable of managing an array of NoteSets.
|
||||
*/
|
||||
|
||||
const MODULE_NAME = "Note Sets";
|
||||
const INFO_LOG = false;
|
||||
const INFO_WARN = true;
|
||||
const ERROR_LOG = true;
|
||||
const logger = newWebDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
const MODULE_NAME = 'Note Sets'
|
||||
const INFO_LOG = false
|
||||
const INFO_WARN = true
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
createNoteSet: createNoteSet,
|
||||
destroyNoteSet: destroyNoteSet,
|
||||
initialize: initialize
|
||||
};
|
||||
let thisObject = {
|
||||
createNoteSet: createNoteSet,
|
||||
destroyNoteSet: destroyNoteSet,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
let noteSets = [];
|
||||
let floatingLayer;
|
||||
let noteSets = []
|
||||
let floatingLayer
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(pFloatingLayer, callBackFunction) {
|
||||
return thisObject
|
||||
|
||||
function initialize (pFloatingLayer, callBackFunction) {
|
||||
/*
|
||||
During the initialization process, we receive the floatingLayer where all the floatingObjects we will be creating here will live at.
|
||||
*/
|
||||
|
||||
try {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
floatingLayer = pFloatingLayer
|
||||
|
||||
floatingLayer = pFloatingLayer;
|
||||
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function createNoteSet(pPayload, pEventHandler, callBackFunction) {
|
||||
|
||||
try {
|
||||
function createNoteSet (pPayload, pEventHandler, callBackFunction) {
|
||||
try {
|
||||
/*
|
||||
During the creating of a NoteSet, no floating objects are created yet. What we do here is to create the data structure which will allocate
|
||||
the Notes floating objects, once we receive the array of notes raw data from the plotter. This array will come as an event raised by the
|
||||
@@ -63,41 +57,39 @@ function newNoteSets() {
|
||||
position the user gives to the viewport, but also, the plotter can be receiving actually new notes from its datasource.
|
||||
*/
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> Entering function."); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> Entering function.') }
|
||||
|
||||
let noteSet = {
|
||||
imageId: pPayload.profile.imageId,
|
||||
floatingNotes: [],
|
||||
payload: pPayload,
|
||||
handle: Math.floor((Math.random() * 10000000) + 1)
|
||||
};
|
||||
let noteSet = {
|
||||
imageId: pPayload.profile.imageId,
|
||||
floatingNotes: [],
|
||||
payload: pPayload,
|
||||
handle: Math.floor((Math.random() * 10000000) + 1)
|
||||
}
|
||||
|
||||
noteSets.push(noteSet);
|
||||
noteSets.push(noteSet)
|
||||
|
||||
pEventHandler.listenToEvent("Notes Changed", onNotesChanged, noteSets.length - 1)
|
||||
pEventHandler.listenToEvent('Notes Changed', onNotesChanged, noteSets.length - 1)
|
||||
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, noteSet.handle);
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, noteSet.handle)
|
||||
|
||||
function onNotesChanged(pNewNotes, pNoteSetIndex) {
|
||||
function onNotesChanged (pNewNotes, pNoteSetIndex) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Entering function.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> pNewNotes.length = ' + pNewNotes.length) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> pNoteSetIndex = ' + pNoteSetIndex) }
|
||||
|
||||
try {
|
||||
let noteSet = noteSets[pNoteSetIndex]
|
||||
let found = false
|
||||
let newFloatingNotes
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Entering function."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> pNewNotes.length = " + pNewNotes.length); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> pNoteSetIndex = " + pNoteSetIndex); }
|
||||
|
||||
let noteSet = noteSets[pNoteSetIndex];
|
||||
let found = false;
|
||||
let newFloatingNotes;
|
||||
|
||||
/*
|
||||
/*
|
||||
First we remove the old notes. This means that we are going to scan all the floating objects that we have, and see one by one if they
|
||||
are still present on the raw data sent by the plotter. If it is not there, that means that the floating object must be discarded.
|
||||
*/
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes."); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes.') }
|
||||
|
||||
newFloatingNotes = []; // We will create a new array of Floating Notes as a result of this operation.
|
||||
newFloatingNotes = [] // We will create a new array of Floating Notes as a result of this operation.
|
||||
|
||||
/*
|
||||
Here we scan the curren array of floating objects. We use the date + rate to create a unique key for each one, in order to be able to
|
||||
@@ -105,171 +97,156 @@ function newNoteSets() {
|
||||
that are still at the raw data array to a new array, and not adding the ones that are not.
|
||||
*/
|
||||
|
||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||
found = false
|
||||
|
||||
found = false;
|
||||
let floatingNote = noteSet.floatingNotes[j]
|
||||
let floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString()
|
||||
|
||||
let floatingNote = noteSet.floatingNotes[j];
|
||||
let floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString();
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> j = ' + j) }
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> j = " + j); }
|
||||
let i
|
||||
|
||||
let i;
|
||||
for (i = 0; i < pNewNotes.length; i++) {
|
||||
let plotterNote = pNewNotes[i]
|
||||
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString()
|
||||
|
||||
for (i = 0; i < pNewNotes.length; i++) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> i = ' + i) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNoteKey = ' + floatingNoteKey) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> plotterNoteKey = ' + plotterNoteKey) }
|
||||
|
||||
let plotterNote = pNewNotes[i];
|
||||
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString();
|
||||
if (plotterNoteKey === floatingNoteKey) {
|
||||
found = true
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> i = " + i); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNoteKey = " + floatingNoteKey); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> plotterNoteKey = " + plotterNoteKey); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> found = ' + found) }
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (plotterNoteKey === floatingNoteKey) {
|
||||
|
||||
found = true;
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> found = " + found); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> End of For i."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> found = " + found); }
|
||||
|
||||
if (found === false) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> End of For i.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> found = ' + found) }
|
||||
|
||||
if (found === false) {
|
||||
/*
|
||||
Each time we identify a floatingObject that is not at the raw data anymore, we request the floatinglayer to kill it.
|
||||
*/
|
||||
|
||||
floatingLayer.killFloatingObject(floatingNote.floatingHandle, onObjectKilled);
|
||||
floatingLayer.killFloatingObject(floatingNote.floatingHandle, onObjectKilled)
|
||||
|
||||
function onObjectKilled(err) {
|
||||
function onObjectKilled (err) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object Not Found.') }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object cannot be killed.') }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||
return
|
||||
}
|
||||
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Removed from Layer.') }
|
||||
}
|
||||
} else {
|
||||
newFloatingNotes.push(floatingNote)
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object Not Found."); }
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object cannot be killed."); }
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
||||
return;
|
||||
}
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Removed from Layer."); }
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
newFloatingNotes.push(floatingNote);
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Added to newFloatingNotes."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> newFloatingNotes.length = " + newFloatingNotes.length); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Added to newFloatingNotes.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> newFloatingNotes.length = ' + newFloatingNotes.length) }
|
||||
|
||||
/*
|
||||
We set a property at each floatingObject of which is the index of the note at the raw data array, so that it can later evaluate its position or its visibility.
|
||||
*/
|
||||
|
||||
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle);
|
||||
floatingObject.payloadNoteIndex = i;
|
||||
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle)
|
||||
floatingObject.payloadNoteIndex = i
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject index updated."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject.payloadNoteIndex = " + i); }
|
||||
|
||||
}
|
||||
}
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject index updated.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject.payloadNoteIndex = ' + i) }
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
We replace the current array, with the new one that only contains the surviving floating objects, meaning the ones that are still at the raw data received.
|
||||
*/
|
||||
|
||||
noteSet.floatingNotes = newFloatingNotes;
|
||||
noteSet.floatingNotes = newFloatingNotes
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> noteSet.floatingNotes.length = " + noteSet.floatingNotes.length); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> noteSet.floatingNotes.length = ' + noteSet.floatingNotes.length) }
|
||||
|
||||
/*
|
||||
/*
|
||||
Second we add the new notes. There might be new notes at the raw data received that we didnt have before at the NodeSet array. To figure out which
|
||||
ones are, we need to scan the raw data array and compare each element with the ones of the NodeSet array. Whenever we find one that is not there,
|
||||
we add it.
|
||||
*/
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes."); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes.') }
|
||||
|
||||
newFloatingNotes = []; // We will create a new array of Floating Notes as a result of this operation.
|
||||
newFloatingNotes = [] // We will create a new array of Floating Notes as a result of this operation.
|
||||
|
||||
/*
|
||||
We are using the date and rate as a unique key to identify each note. To prevent the cases of duplicate keys, we will check that at
|
||||
least to consecutive records dont have the same key, and if they do, will ignore the second one.
|
||||
*/
|
||||
|
||||
let lastPlotterKey = "";
|
||||
let lastPlotterKey = ''
|
||||
|
||||
for (let i = 0; i < pNewNotes.length; i++) {
|
||||
for (let i = 0; i < pNewNotes.length; i++) {
|
||||
found = false
|
||||
|
||||
found = false;
|
||||
let plotterNote = pNewNotes[i]
|
||||
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString()
|
||||
let floatingNote
|
||||
let floatingNoteKey
|
||||
|
||||
let plotterNote = pNewNotes[i];
|
||||
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString();
|
||||
let floatingNote;
|
||||
let floatingNoteKey;
|
||||
if (lastPlotterKey === plotterNoteKey) {
|
||||
if (INFO_WARN === true) { logger.write('[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> Duplicate record detected. Discarding it.') }
|
||||
if (INFO_WARN === true) { logger.write('[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> i = ' + i) }
|
||||
continue
|
||||
}
|
||||
|
||||
if (lastPlotterKey === plotterNoteKey) {
|
||||
lastPlotterKey = plotterNoteKey
|
||||
|
||||
if (INFO_WARN=== true) { logger.write("[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> Duplicate record detected. Discarding it."); }
|
||||
if (INFO_WARN === true) { logger.write("[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); }
|
||||
continue;
|
||||
}
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = ' + i) }
|
||||
|
||||
lastPlotterKey = plotterNoteKey;
|
||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||
floatingNote = noteSet.floatingNotes[j]
|
||||
floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString()
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> j = ' + j) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> floatingNoteKey = ' + floatingNoteKey) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNoteKey = ' + plotterNoteKey) }
|
||||
|
||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||
if (plotterNoteKey === floatingNoteKey) {
|
||||
found = true
|
||||
|
||||
floatingNote = noteSet.floatingNotes[j];
|
||||
floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString();
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = ' + found) }
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> j = " + j); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> floatingNoteKey = " + floatingNoteKey); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNoteKey = " + plotterNoteKey); }
|
||||
|
||||
if (plotterNoteKey === floatingNoteKey) {
|
||||
|
||||
found = true;
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = " + found); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> End of For j."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = " + found); }
|
||||
|
||||
if (found === false) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> End of For j.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = ' + found) }
|
||||
|
||||
if (found === false) {
|
||||
/*
|
||||
Before adding a new item to the array, we need to create a floatingObject of type Note. Once we set its basic parameters
|
||||
we can it to our array and to the floating layer.
|
||||
*/
|
||||
|
||||
let floatingObject = newFloatingObject();
|
||||
floatingObject.initialize("Note", onInitialized);
|
||||
let floatingObject = newFloatingObject()
|
||||
floatingObject.initialize('Note', onInitialized)
|
||||
|
||||
function onInitialized(err) {
|
||||
function onInitialized (err) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function.') }
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function."); }
|
||||
floatingObject.payload = noteSet.payload
|
||||
floatingObject.payloadNoteIndex = i
|
||||
floatingObject.payloadImageId = noteSet.imageId
|
||||
|
||||
floatingObject.payload = noteSet.payload;
|
||||
floatingObject.payloadNoteIndex = i;
|
||||
floatingObject.payloadImageId = noteSet.imageId;
|
||||
floatingObject.friction = 0.995
|
||||
|
||||
floatingObject.friction = .995;
|
||||
floatingObject.initializeMass(200)
|
||||
|
||||
floatingObject.initializeMass(200);
|
||||
|
||||
//let bodyText = pNewNotes[i].body;
|
||||
let radius;
|
||||
// let bodyText = pNewNotes[i].body;
|
||||
let radius
|
||||
|
||||
/*
|
||||
if (bodyText.length < 100) {
|
||||
@@ -278,96 +255,83 @@ function newNoteSets() {
|
||||
radius = bodyText.length;
|
||||
}
|
||||
*/
|
||||
radius = 50;
|
||||
radius = 50
|
||||
|
||||
floatingObject.initializeRadius(radius);
|
||||
floatingObject.initializeImageSize(15);
|
||||
floatingObject.initializeRadius(radius)
|
||||
floatingObject.initializeImageSize(15)
|
||||
|
||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)';
|
||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
|
||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)'
|
||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'
|
||||
|
||||
floatingLayer.addFloatingObject(floatingObject);
|
||||
floatingLayer.addFloatingObject(floatingObject)
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> New Note added to Layer."); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> New Note added to Layer.') }
|
||||
|
||||
plotterNote.floatingHandle = floatingObject.handle;
|
||||
plotterNote.floatingHandle = floatingObject.handle
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNote.floatingHandle = " + plotterNote.floatingHandle); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNote.floatingHandle = ' + plotterNote.floatingHandle) }
|
||||
|
||||
newFloatingNotes.push(plotterNote);
|
||||
newFloatingNotes.push(plotterNote)
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = " + newFloatingNotes.length); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = ' + newFloatingNotes.length) }
|
||||
}
|
||||
} else {
|
||||
newFloatingNotes.push(floatingNote)
|
||||
|
||||
}
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Old Note Kept.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = ' + newFloatingNotes.length) }
|
||||
|
||||
} else {
|
||||
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle)
|
||||
floatingObject.payloadNoteIndex = i
|
||||
|
||||
newFloatingNotes.push(floatingNote);
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Old Note Kept."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = " + newFloatingNotes.length); }
|
||||
|
||||
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle);
|
||||
floatingObject.payloadNoteIndex = i;
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject index updated."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject.payloadNoteIndex = " + i); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
noteSet.floatingNotes = newFloatingNotes;
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> noteSet.floatingNotes.length = " + noteSet.floatingNotes.length); }
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> err = " + err); }
|
||||
}
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject index updated.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject.payloadNoteIndex = ' + i) }
|
||||
}
|
||||
}
|
||||
|
||||
noteSet.floatingNotes = newFloatingNotes
|
||||
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> noteSet.floatingNotes.length = ' + noteSet.floatingNotes.length) }
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> err = " + err); }
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> err = ' + err) }
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> err = ' + err) }
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function destroyNoteSet(pHandle) {
|
||||
|
||||
try {
|
||||
function destroyNoteSet (pHandle) {
|
||||
try {
|
||||
/*
|
||||
Usually when a bot is disabled by the end user, or the zoom level changes to one where the notes must not be seen, this method
|
||||
to destroy an entire NoteSet is executed. What we do in this situation is to localize the NoteSet to be destroyed and we need to
|
||||
kill, one by one the floating objects in it. Finally we remove this NoteSet item from the NoteSets array.
|
||||
*/
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] destroyNoteSet -> Entering function."); }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] destroyNoteSet -> Entering function.') }
|
||||
|
||||
for (let i = 0; i < noteSets.length; i++) {
|
||||
for (let i = 0; i < noteSets.length; i++) {
|
||||
let noteSet = noteSets[i]
|
||||
|
||||
let noteSet = noteSets[i];
|
||||
if (noteSet.handle === pHandle) {
|
||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||
let floatingNote = noteSet.floatingNotes[j]
|
||||
|
||||
if (noteSet.handle === pHandle) {
|
||||
floatingLayer.killFloatingObject(floatingNote.floatingHandle)
|
||||
}
|
||||
|
||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||
|
||||
let floatingNote = noteSet.floatingNotes[j];
|
||||
|
||||
floatingLayer.killFloatingObject(floatingNote.floatingHandle);
|
||||
}
|
||||
|
||||
noteSets.splice(i, 1); // Delete item from array.
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] destroyNoteSet -> err = " + err); }
|
||||
noteSets.splice(i, 1) // Delete item from array.
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] destroyNoteSet -> err = ' + err) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -310,4 +310,3 @@ function newProfileBall () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
function newProfileBalls() {
|
||||
|
||||
const MODULE_NAME = "Profile Balls";
|
||||
const INFO_LOG = false;
|
||||
const ERROR_LOG = true;
|
||||
const logger = newWebDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
|
||||
function newProfileBalls () {
|
||||
const MODULE_NAME = 'Profile Balls'
|
||||
const INFO_LOG = false
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
/*
|
||||
|
||||
@@ -13,65 +12,56 @@ function newProfileBalls() {
|
||||
|
||||
*/
|
||||
|
||||
let thisObject = {
|
||||
let thisObject = {
|
||||
|
||||
createNewProfileBall: createNewProfileBall,
|
||||
destroyProfileBall: destroyProfileBall,
|
||||
initialize: initialize
|
||||
createNewProfileBall: createNewProfileBall,
|
||||
destroyProfileBall: destroyProfileBall,
|
||||
initialize: initialize
|
||||
|
||||
}
|
||||
|
||||
let floatingLayer
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (pFloatingLayer, callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
floatingLayer = pFloatingLayer
|
||||
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
let floatingLayer;
|
||||
function createNewProfileBall (pPayload, callBackFunction) {
|
||||
let floatingObject = newFloatingObject()
|
||||
floatingObject.initialize('Profile Ball', onInitialized)
|
||||
|
||||
return thisObject;
|
||||
function onInitialized (err) {
|
||||
floatingObject.payload = pPayload
|
||||
|
||||
function initialize(pFloatingLayer, callBackFunction) {
|
||||
floatingObject.friction = 0.995
|
||||
|
||||
try {
|
||||
floatingObject.initializeMass(100)
|
||||
floatingObject.initializeRadius(30)
|
||||
floatingObject.initializeImageSize(50)
|
||||
floatingObject.initializeFontSize(10)
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)'
|
||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'
|
||||
|
||||
floatingLayer = pFloatingLayer;
|
||||
floatingLayer.addFloatingObject(floatingObject)
|
||||
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, floatingObject.handle)
|
||||
}
|
||||
}
|
||||
|
||||
function createNewProfileBall(pPayload, callBackFunction) {
|
||||
|
||||
let floatingObject = newFloatingObject();
|
||||
floatingObject.initialize("Profile Ball", onInitialized);
|
||||
|
||||
function onInitialized(err) {
|
||||
|
||||
floatingObject.payload = pPayload;
|
||||
|
||||
floatingObject.friction = .995;
|
||||
|
||||
floatingObject.initializeMass(100);
|
||||
floatingObject.initializeRadius(30);
|
||||
floatingObject.initializeImageSize(50);
|
||||
floatingObject.initializeFontSize(10);
|
||||
|
||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)';
|
||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
|
||||
|
||||
floatingLayer.addFloatingObject(floatingObject);
|
||||
|
||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, floatingObject.handle);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function destroyProfileBall(pFloatingObjectHandle) {
|
||||
|
||||
floatingLayer.killFloatingObject(pFloatingObjectHandle);
|
||||
|
||||
}
|
||||
function destroyProfileBall (pFloatingObjectHandle) {
|
||||
floatingLayer.killFloatingObject(pFloatingObjectHandle)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user