Commit 45f4e1f22d7aca95161273abfb447b49877be36a

Authored by Amrita Vishnoi
1 parent 9513c8ab

Added null check

400-SOURCECODE/AIAHTML5.Web/extract-wp.js
... ... @@ -18,89 +18,91 @@ getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, colo
18 18 grayImageData = previousGrayImageDataList[parseInt(bodyRegionId - 1)];
19 19  
20 20 }
21   - var grayImageDataVar = grayImageData.data;
22   - var coloredImageDataVar = coloredImageData.data;
  21 + if (grayImageData != null) {
  22 + var grayImageDataVar = grayImageData.data;
  23 + var coloredImageDataVar = coloredImageData.data;
23 24  
24   - for (var i = 0; i < n; i += 4) {
  25 + for (var i = 0; i < n; i += 4) {
25 26  
26 27  
27   - var RED = maskData[i] - 9;
28   - var GREEN = maskData[i + 1] - 9;
29   - var BLUE = maskData[i + 2] - 9;
  28 + var RED = maskData[i] - 9;
  29 + var GREEN = maskData[i + 1] - 9;
  30 + var BLUE = maskData[i + 2] - 9;
30 31  
31   - var Red;
32   - var Green;
33   - var Blue;
34   - var zero = "0";
  32 + var Red;
  33 + var Green;
  34 + var Blue;
  35 + var zero = "0";
35 36  
36   - if ((RED).toString().length != 2) {
37   - Red = zero.concat((RED).toString())
38   - }
39   - else {
40   - Red = (RED).toString()
41   - }
42   - if ((GREEN).toString().length != 2) {
43   - Green = zero.concat((GREEN).toString())
44   - }
45   - else {
46   - Green = (GREEN).toString()
  37 + if ((RED).toString().length != 2) {
  38 + Red = zero.concat((RED).toString())
  39 + }
  40 + else {
  41 + Red = (RED).toString()
  42 + }
  43 + if ((GREEN).toString().length != 2) {
  44 + Green = zero.concat((GREEN).toString())
  45 + }
  46 + else {
  47 + Green = (GREEN).toString()
47 48  
48   - }
49   - if ((BLUE).toString().length != 2) {
50   - Blue = zero.concat((BLUE).toString())
51   - }
52   - else {
53   - Blue = (BLUE).toString()
  49 + }
  50 + if ((BLUE).toString().length != 2) {
  51 + Blue = zero.concat((BLUE).toString())
  52 + }
  53 + else {
  54 + Blue = (BLUE).toString()
54 55  
55   - }
  56 + }
56 57  
57   - var Icolor = (Red + Green + Blue);
58   - // alert('Icolor: ' + Icolor)
  58 + var Icolor = (Red + Green + Blue);
  59 + // alert('Icolor: ' + Icolor)
59 60  
60   - if (parseInt(termList[z]._TermNumber) == parseInt(Icolor)) {
  61 + if (parseInt(termList[z]._TermNumber) == parseInt(Icolor)) {
61 62  
62   - // debugger;
  63 + // debugger;
63 64  
64 65  
65   - // matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i });
  66 + // matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i });
66 67  
67 68  
68   - // matched = true;
  69 + // matched = true;
69 70  
70   - var RED_coloredImage = coloredImageDataVar[i];
  71 + var RED_coloredImage = coloredImageDataVar[i];
71 72  
72   - grayImageDataVar[i] = RED_coloredImage;
  73 + grayImageDataVar[i] = RED_coloredImage;
73 74  
74 75  
75   - var GREEN_coloredImage = coloredImageDataVar[i + 1];
76   - grayImageDataVar[i + 1] = GREEN_coloredImage;
  76 + var GREEN_coloredImage = coloredImageDataVar[i + 1];
  77 + grayImageDataVar[i + 1] = GREEN_coloredImage;
77 78  
78   - var BLUE_coloredImage = coloredImageDataVar[i + 2];
79   - grayImageDataVar[i + 2] = BLUE_coloredImage;
  79 + var BLUE_coloredImage = coloredImageDataVar[i + 2];
  80 + grayImageDataVar[i + 2] = BLUE_coloredImage;
80 81  
81 82  
82   - var ALPHA_coloredImage = coloredImageDataVar[i + 3];
83   - grayImageDataVar[i + 3] = ALPHA_coloredImage;
  83 + var ALPHA_coloredImage = coloredImageDataVar[i + 3];
  84 + grayImageDataVar[i + 3] = ALPHA_coloredImage;
84 85  
85   - }
  86 + }
86 87  
87 88  
88   - }
89   - // debugger;
90   - previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageData;
  89 + }
  90 + // debugger;
  91 + previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageData;
91 92  
92   - // if (matched == true) {
  93 + // if (matched == true) {
93 94  
94   - // }
  95 + // }
95 96  
96   - }
97   - self.postMessage({
98   - 'bodyRegionId': bodyRegionId,
99   - 'value': grayImageData,
100   - 'canvasId': canvasId
101 97  
102   - });
  98 + self.postMessage({
  99 + 'bodyRegionId': bodyRegionId,
  100 + 'value': grayImageData,
  101 + 'canvasId': canvasId
103 102  
  103 + });
  104 + }
  105 + }
104 106 }
105 107  
106 108 self.onmessage = function (e) {
... ...