From 45f4e1f22d7aca95161273abfb447b49877be36a Mon Sep 17 00:00:00 2001 From: amrita.vishnoi Date: Mon, 1 Aug 2016 10:44:46 +0530 Subject: [PATCH] Added null check --- 400-SOURCECODE/AIAHTML5.Web/extract-wp.js | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------ 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/extract-wp.js b/400-SOURCECODE/AIAHTML5.Web/extract-wp.js index a88b3a3..6ad8eb1 100644 --- a/400-SOURCECODE/AIAHTML5.Web/extract-wp.js +++ b/400-SOURCECODE/AIAHTML5.Web/extract-wp.js @@ -18,89 +18,91 @@ getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, colo grayImageData = previousGrayImageDataList[parseInt(bodyRegionId - 1)]; } - var grayImageDataVar = grayImageData.data; - var coloredImageDataVar = coloredImageData.data; + if (grayImageData != null) { + var grayImageDataVar = grayImageData.data; + var coloredImageDataVar = coloredImageData.data; - for (var i = 0; i < n; i += 4) { + for (var i = 0; i < n; i += 4) { - var RED = maskData[i] - 9; - var GREEN = maskData[i + 1] - 9; - var BLUE = maskData[i + 2] - 9; + var RED = maskData[i] - 9; + var GREEN = maskData[i + 1] - 9; + var BLUE = maskData[i + 2] - 9; - var Red; - var Green; - var Blue; - var zero = "0"; + var Red; + var Green; + var Blue; + var zero = "0"; - if ((RED).toString().length != 2) { - Red = zero.concat((RED).toString()) - } - else { - Red = (RED).toString() - } - if ((GREEN).toString().length != 2) { - Green = zero.concat((GREEN).toString()) - } - else { - Green = (GREEN).toString() + if ((RED).toString().length != 2) { + Red = zero.concat((RED).toString()) + } + else { + Red = (RED).toString() + } + if ((GREEN).toString().length != 2) { + Green = zero.concat((GREEN).toString()) + } + else { + Green = (GREEN).toString() - } - if ((BLUE).toString().length != 2) { - Blue = zero.concat((BLUE).toString()) - } - else { - Blue = (BLUE).toString() + } + if ((BLUE).toString().length != 2) { + Blue = zero.concat((BLUE).toString()) + } + else { + Blue = (BLUE).toString() - } + } - var Icolor = (Red + Green + Blue); - // alert('Icolor: ' + Icolor) + var Icolor = (Red + Green + Blue); + // alert('Icolor: ' + Icolor) - if (parseInt(termList[z]._TermNumber) == parseInt(Icolor)) { + if (parseInt(termList[z]._TermNumber) == parseInt(Icolor)) { - // debugger; + // debugger; - // matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i }); + // matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i }); - // matched = true; + // matched = true; - var RED_coloredImage = coloredImageDataVar[i]; + var RED_coloredImage = coloredImageDataVar[i]; - grayImageDataVar[i] = RED_coloredImage; + grayImageDataVar[i] = RED_coloredImage; - var GREEN_coloredImage = coloredImageDataVar[i + 1]; - grayImageDataVar[i + 1] = GREEN_coloredImage; + var GREEN_coloredImage = coloredImageDataVar[i + 1]; + grayImageDataVar[i + 1] = GREEN_coloredImage; - var BLUE_coloredImage = coloredImageDataVar[i + 2]; - grayImageDataVar[i + 2] = BLUE_coloredImage; + var BLUE_coloredImage = coloredImageDataVar[i + 2]; + grayImageDataVar[i + 2] = BLUE_coloredImage; - var ALPHA_coloredImage = coloredImageDataVar[i + 3]; - grayImageDataVar[i + 3] = ALPHA_coloredImage; + var ALPHA_coloredImage = coloredImageDataVar[i + 3]; + grayImageDataVar[i + 3] = ALPHA_coloredImage; - } + } - } - // debugger; - previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageData; + } + // debugger; + previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageData; - // if (matched == true) { + // if (matched == true) { - // } + // } - } - self.postMessage({ - 'bodyRegionId': bodyRegionId, - 'value': grayImageData, - 'canvasId': canvasId - }); + self.postMessage({ + 'bodyRegionId': bodyRegionId, + 'value': grayImageData, + 'canvasId': canvasId + }); + } + } } self.onmessage = function (e) { -- libgit2 0.21.4