diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo index f905bbc2f..c4ccd2e2d 100644 Binary files a/.vs/AAWeb/v15/.suo and b/.vs/AAWeb/v15/.suo differ diff --git a/Azure/azure-storage.blob.js b/Azure/azure-storage.blob.js index bd22ece54..9b26939cb 100644 --- a/Azure/azure-storage.blob.js +++ b/Azure/azure-storage.blob.js @@ -2679,7 +2679,7 @@ StorageServiceClient.prototype._performRequest = function (webResource, body, op oldEnd.call(requestStream); }; - // Bubble events up -- This is when the request is going to be made. + // Note events up -- This is when the request is going to be made. requestStream.on('response', function (response) { self.emit('receivedResponseEvent', response); }); diff --git a/FloatingSpace/BubbleSets.js b/FloatingSpace/BubbleSets.js deleted file mode 100644 index c7f61fbe6..000000000 --- a/FloatingSpace/BubbleSets.js +++ /dev/null @@ -1,268 +0,0 @@ - -function newBubbleSets() { - - const MODULE_NAME = "Bubble Sets"; - const INFO_LOG = false; - const ERROR_LOG = true; - const logger = newDebugLog(); - logger.fileName = MODULE_NAME; - - let thisObject = { - createBubbleSet: createBubbleSet, - destroyBubbleSet: destroyBubbleSet, - initialize: initialize - }; - - let bubbleSets = []; - 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.CUSTOM_FAIL_RESPONSE); - } - } - - function createBubbleSet(pPayload, pEventHandler, callBackFunction) { - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> Entering function."); } - - let bubbleSet = { - imageId: pPayload.profile.imageId, - floatingBubbles: [], - payload: pPayload, - handle: Math.floor((Math.random() * 10000000) + 1) - }; - - bubbleSets.push(bubbleSet); - - pEventHandler.listenToEvent("Bubbles Changed", onBubblesChanged, bubbleSets.length - 1) - - callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, bubbleSet.handle); - - function onBubblesChanged(pNewBubbles, pBubbleSetIndex) { - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Entering function."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> pNewBubbles.length = " + pNewBubbles.length); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> pBubbleSetIndex = " + pBubbleSetIndex); } - - let bubbleSet = bubbleSets[pBubbleSetIndex]; - let found = false; - let newFloatingBubbles; - - /* First we remove the old bubbles. */ - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles."); } - - newFloatingBubbles = []; // We will create a new array of Floating Bubbles as a result of this operation. - - for (let j = 0; j < bubbleSet.floatingBubbles.length; j++) { - - found = false; - - let floatingBubble = bubbleSet.floatingBubbles[j]; - let floatingBubbleKey = floatingBubble.date.toString() + floatingBubble.rate.toString(); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> j = " + j); } - - let i; - - for (i = 0; i < pNewBubbles.length; i++) { - - let plotterBubble = pNewBubbles[i]; - let plotterBubbleKey = plotterBubble.date.toString() + plotterBubble.rate.toString(); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> i = " + i); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> floatingBubbleKey = " + floatingBubbleKey); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> plotterBubbleKey = " + plotterBubbleKey); } - - if (plotterBubbleKey === floatingBubbleKey) { - - found = true; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> found = " + found); } - break; - } - } - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> End of For i."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> found = " + found); } - - if (found === false) { - - floatingLayer.removeFloatingObject(floatingBubble.floatingHandle); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> floatingBubble.floatingHandle = " + floatingBubble.floatingHandle); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> Removed from Layer."); } - - } else { - - newFloatingBubbles.push(floatingBubble); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> floatingBubble.floatingHandle = " + floatingBubble.floatingHandle); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> Added to newFloatingBubbles."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> newFloatingBubbles.length = " + newFloatingBubbles.length); } - - let floatingObject = floatingLayer.getFloatingObject(floatingBubble.floatingHandle); - floatingObject.payloadBubbleIndex = i; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> floatingObject index updated."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> floatingObject.payloadBubbleIndex = " + i); } - - } - } - - bubbleSet.floatingBubbles = newFloatingBubbles; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Remove old Bubbles -> bubbleSet.floatingBubbles.length = " + bubbleSet.floatingBubbles.length); } - - /* Second we add the new bubbles. */ - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles."); } - - newFloatingBubbles = []; // We will create a new array of Floating Bubbles as a result of this operation. - - for (let i = 0; i < pNewBubbles.length; i++) { - - found = false; - - let plotterBubble = pNewBubbles[i]; - let plotterBubbleKey = plotterBubble.date.toString() + plotterBubble.rate.toString(); - let floatingBubble; - let floatingBubbleKey; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> i = " + i); } - - for (let j = 0; j < bubbleSet.floatingBubbles.length; j++) { - - floatingBubble = bubbleSet.floatingBubbles[j]; - floatingBubbleKey = floatingBubble.date.toString() + floatingBubble.rate.toString(); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> j = " + j); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> floatingBubbleKey = " + floatingBubbleKey); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> plotterBubbleKey = " + plotterBubbleKey); } - - if (plotterBubbleKey === floatingBubbleKey) { - - found = true; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> found = " + found); } - break; - } - } - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> End of For j."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> found = " + found); } - - if (found === false) { - - let floatingObject = newFloatingObject(); - floatingObject.initialize("Bubble", onInitialized); - - function onInitialized(err) { - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> Entering function."); } - - floatingObject.payload = bubbleSet.payload; - floatingObject.payloadBubbleIndex = i; - floatingObject.payload.profile.imageId = bubbleSet.imageId; - - floatingObject.friction = .995; - - floatingObject.initializeMass(200); - - //let bodyText = pNewBubbles[i].body; - let radius; - - /* - if (bodyText.length < 100) { - radius = 100; - } else { - radius = bodyText.length; - } - */ - radius = 50; - - floatingObject.initializeRadius(radius); - floatingObject.initializeImageSize(15); - - floatingObject.fillStyle = 'rgba(255, 255, 255, 0.5)'; - floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'; - - floatingLayer.addFloatingObject(floatingObject); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> New Bubble added to Layer."); } - - plotterBubble.floatingHandle = floatingObject.handle; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> plotterBubble.floatingHandle = " + plotterBubble.floatingHandle); } - - newFloatingBubbles.push(plotterBubble); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> Added to newFloatingBubbles."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> newFloatingBubbles.length = " + newFloatingBubbles.length); } - - } - - } else { - - newFloatingBubbles.push(floatingBubble); - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> Old Bubble Kept."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> floatingBubble.floatingHandle = " + floatingBubble.floatingHandle); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> Added to newFloatingBubbles."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> newFloatingBubbles.length = " + newFloatingBubbles.length); } - - let floatingObject = floatingLayer.getFloatingObject(floatingBubble.floatingHandle); - floatingObject.payloadBubbleIndex = i; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> floatingObject index updated."); } - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> onInitialized -> floatingObject.payloadBubbleIndex = " + i); } - - } - } - - bubbleSet.floatingBubbles = newFloatingBubbles; - - if (INFO_LOG === true) { logger.write("[INFO] createBubbleSet -> onBubblesChanged -> Add new Bubbles -> bubbleSet.floatingBubbles.length = " + bubbleSet.floatingBubbles.length); } - - } - } - - function destroyBubbleSet(pHandle) { - - if (INFO_LOG === true) { logger.write("[INFO] destroyBubbleSet -> Entering function."); } - - for (let i = 0; i < bubbleSets.length; i++) { - - let bubbleSet = bubbleSets[i]; - - if (bubbleSet.handle === pHandle) { - - for (let j = 0; j < bubbleSet.floatingBubbles.length; j++) { - - let floatingBubble = bubbleSet.floatingBubbles[j]; - - floatingLayer.removeFloatingObject(floatingBubble.floatingHandle); - } - - bubbleSets.splice(i, 1); // Delete item from array. - return; - } - } - } -} - - diff --git a/FloatingSpace/FloatingLayer.js b/FloatingSpace/FloatingLayer.js index 80f7b34b5..a50e97ae7 100644 --- a/FloatingSpace/FloatingLayer.js +++ b/FloatingSpace/FloatingLayer.js @@ -149,10 +149,10 @@ function newFloatingLayer() { payload.visible = floatingObject.payload.profile.visible; break; } - case "Bubble": { + case "Note": { - payload.position = floatingObject.payload.bubbles[floatingObject.payloadBubbleIndex].position; - payload.visible = floatingObject.payload.bubbles[floatingObject.payloadBubbleIndex].visible; + payload.position = floatingObject.payload.notes[floatingObject.payloadNoteIndex].position; + payload.visible = floatingObject.payload.notes[floatingObject.payloadNoteIndex].visible; break; } @@ -269,10 +269,10 @@ function newFloatingLayer() { payload.visible = floatingObject.payload.profile.visible; break; } - case "Bubble": { + case "Note": { - payload.position = floatingObject.payload.bubbles[floatingObject.payloadBubbleIndex].position; - payload.visible = floatingObject.payload.bubbles[floatingObject.payloadBubbleIndex].visible; + payload.position = floatingObject.payload.notes[floatingObject.payloadNoteIndex].position; + payload.visible = floatingObject.payload.notes[floatingObject.payloadNoteIndex].visible; break; } default: { @@ -325,9 +325,9 @@ function newFloatingLayer() { payload.visible = floatingObject.payload.profile.visible; break; } - case "Bubble": { + case "Note": { - payload.visible = floatingObject.payload.bubbles[floatingObject.payloadBubbleIndex].visible; + payload.visible = floatingObject.payload.notes[floatingObject.payloadNoteIndex].visible; break; } default: { @@ -488,9 +488,9 @@ function newFloatingLayer() { payload.position = floatingObject2.payload.profile.position; break; } - case "Bubble": { + case "Note": { - payload.position = floatingObject2.payload.bubbles[floatingObject2.payloadBubbleIndex].position; + payload.position = floatingObject2.payload.notes[floatingObject2.payloadNoteIndex].position; break; } default: { diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index fd9dba610..acff5c61b 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -4,7 +4,7 @@ function newFloatingObject() { var thisObject = { 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 Bubbles. + type: undefined, // Currently there are two types of Floating Objects: Profile Balls, and Notes. physicsEnabled: false, @@ -67,9 +67,9 @@ function newFloatingObject() { break; } - case "Bubble": { + case "Note": { - underlayingObject = newBubble(); + underlayingObject = newNote(); underlayingObject.initialize(onInitialized); function onInitialized(err) { diff --git a/FloatingSpace/Bubble.js b/FloatingSpace/Note.js similarity index 94% rename from FloatingSpace/Bubble.js rename to FloatingSpace/Note.js index 39f32d0d8..b88785020 100644 --- a/FloatingSpace/Bubble.js +++ b/FloatingSpace/Note.js @@ -1,5 +1,5 @@  -function newBubble() { +function newNote() { var thisObject = { @@ -25,7 +25,7 @@ function newBubble() { browserCanvasContext.beginPath(); browserCanvasContext.moveTo(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y); - browserCanvasContext.lineTo(pFloatingObject.payload.bubbles[pFloatingObject.payloadBubbleIndex].position.x, pFloatingObject.payload.bubbles[pFloatingObject.payloadBubbleIndex].position.y); + browserCanvasContext.lineTo(pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x, pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y); browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)'; browserCanvasContext.setLineDash([4, 2]); browserCanvasContext.lineWidth = 1; @@ -41,7 +41,7 @@ function newBubble() { var radius = 1; browserCanvasContext.beginPath(); - browserCanvasContext.arc(pFloatingObject.payload.bubbles[pFloatingObject.payloadBubbleIndex].position.x, pFloatingObject.payload.bubbles[pFloatingObject.payloadBubbleIndex].position.y, radius, 0, Math.PI * 2, true); + browserCanvasContext.arc(pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x, pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y, radius, 0, Math.PI * 2, true); browserCanvasContext.closePath(); browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)'; browserCanvasContext.fill(); @@ -189,7 +189,7 @@ function newBubble() { /* print the title */ - label = pFloatingObject.payload.bubbles[pFloatingObject.payloadBubbleIndex].title; + label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].title; if (label !== undefined) { @@ -213,7 +213,7 @@ function newBubble() { /* Message Body */ - label = pFloatingObject.payload.bubbles[pFloatingObject.payloadBubbleIndex].body; + label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].body; if (label !== undefined) { diff --git a/FloatingSpace/NoteSets.js b/FloatingSpace/NoteSets.js new file mode 100644 index 000000000..f8218d7a6 --- /dev/null +++ b/FloatingSpace/NoteSets.js @@ -0,0 +1,268 @@ + +function newNoteSets() { + + const MODULE_NAME = "Note Sets"; + const INFO_LOG = false; + const ERROR_LOG = true; + const logger = newDebugLog(); + logger.fileName = MODULE_NAME; + + let thisObject = { + createNoteSet: createNoteSet, + destroyNoteSet: destroyNoteSet, + initialize: initialize + }; + + let noteSets = []; + 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.CUSTOM_FAIL_RESPONSE); + } + } + + function createNoteSet(pPayload, pEventHandler, callBackFunction) { + + 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) + }; + + noteSets.push(noteSet); + + pEventHandler.listenToEvent("Notes Changed", onNotesChanged, noteSets.length - 1) + + callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, noteSet.handle); + + function onNotesChanged(pNewNotes, pNoteSetIndex) { + + 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. */ + + 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. + + for (let j = 0; j < noteSet.floatingNotes.length; j++) { + + found = false; + + 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); } + + let i; + + for (i = 0; i < pNewNotes.length; i++) { + + let plotterNote = pNewNotes[i]; + let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString(); + + 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 (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) { + + floatingLayer.removeFloatingObject(floatingNote.floatingHandle); + + 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); } + + 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); } + + } + } + + noteSet.floatingNotes = newFloatingNotes; + + if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> noteSet.floatingNotes.length = " + noteSet.floatingNotes.length); } + + /* Second we add the 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. + + for (let i = 0; i < pNewNotes.length; i++) { + + found = false; + + let plotterNote = pNewNotes[i]; + let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString(); + let floatingNote; + let floatingNoteKey; + + if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); } + + 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 -> 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) { + + let floatingObject = newFloatingObject(); + floatingObject.initialize("Note", onInitialized); + + function onInitialized(err) { + + if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function."); } + + floatingObject.payload = noteSet.payload; + floatingObject.payloadNoteIndex = i; + floatingObject.payload.profile.imageId = noteSet.imageId; + + floatingObject.friction = .995; + + floatingObject.initializeMass(200); + + //let bodyText = pNewNotes[i].body; + let radius; + + /* + if (bodyText.length < 100) { + radius = 100; + } else { + radius = bodyText.length; + } + */ + radius = 50; + + floatingObject.initializeRadius(radius); + floatingObject.initializeImageSize(15); + + floatingObject.fillStyle = 'rgba(255, 255, 255, 0.5)'; + floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'; + + floatingLayer.addFloatingObject(floatingObject); + + if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> New Note added to Layer."); } + + plotterNote.floatingHandle = floatingObject.handle; + + if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNote.floatingHandle = " + plotterNote.floatingHandle); } + + 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); } + + } + + } 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); } + + 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); } + + } + } + + function destroyNoteSet(pHandle) { + + if (INFO_LOG === true) { logger.write("[INFO] destroyNoteSet -> Entering function."); } + + for (let i = 0; i < noteSets.length; i++) { + + let noteSet = noteSets[i]; + + if (noteSet.handle === pHandle) { + + for (let j = 0; j < noteSet.floatingNotes.length; j++) { + + let floatingNote = noteSet.floatingNotes[j]; + + floatingLayer.removeFloatingObject(floatingNote.floatingHandle); + } + + noteSets.splice(i, 1); // Delete item from array. + return; + } + } + } +} + + diff --git a/Project.njsproj b/Project.njsproj index 3f168d3f7..e2ecdeac0 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -32,10 +32,10 @@ - + Code - + Code diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index cba37e7c2..a1d20901d 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -9,7 +9,7 @@ function newFloatingSpace() { let thisObject = { floatingLayer: undefined, // This is the array of floatingObjects being displayed profileBalls: undefined, - bubbleSets: undefined, + noteSets: undefined, initialize: initialize }; @@ -27,10 +27,10 @@ function newFloatingSpace() { function onProfileBallsInitialized(err) { - thisObject.bubbleSets = newBubbleSets(); - thisObject.bubbleSets.initialize(thisObject.floatingLayer, onBubbleSetsInitialized); + thisObject.noteSets = newNoteSets(); + thisObject.noteSets.initialize(thisObject.floatingLayer, onNoteSetsInitialized); - function onBubbleSetsInitialized(err) { + function onNoteSetsInitialized(err) { diff --git a/TimelineChart.js b/TimelineChart.js index cedd4905c..3fc9a496c 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -269,7 +269,7 @@ plotter: plotter, storage: storage, profile: undefined, - bubbles: undefined + notes: undefined }; /* Let the Plotter listen to the event of Cursor Files loaded, so that it can reack recalculating if needed. */ @@ -323,13 +323,13 @@ } - /* Create the Text Bubbles */ + /* Create the Text Notes */ - canvas.floatingSpace.bubbleSets.createBubbleSet(productPlotter.plotter.payload, productPlotter.plotter.container.eventHandler, onBubbleSetCreated); + canvas.floatingSpace.noteSets.createNoteSet(productPlotter.plotter.payload, productPlotter.plotter.container.eventHandler, onNoteSetCreated); - function onBubbleSetCreated(err, pBubbleSetHandle) { + function onNoteSetCreated(err, pNoteSetHandle) { - productPlotter.bubbleSet = pBubbleSetHandle; + productPlotter.noteSet = pNoteSetHandle; } } @@ -384,9 +384,9 @@ } - /* Destroyd the Bubble Set */ + /* Destroyd the Note Set */ - canvas.floatingSpace.bubbleSets.destroyBubbleSet(productPlotters[i].bubbleSet); + canvas.floatingSpace.noteSets.destroyNoteSet(productPlotters[i].noteSet); /* Finally the panels. */ diff --git a/index.html b/index.html index 2d7969acf..bfe37ce1c 100644 --- a/index.html +++ b/index.html @@ -43,8 +43,8 @@ - - + +