Commit 9e21c12e70127b3eff75fb6faa427fc63f02f8ef

Authored by Nikita Kulshreshtha
1 parent d351f192

Working Worker process sample code inside AIA

400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... ... @@ -478,6 +478,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
478 478 //}
479 479  
480 480 $scope.ColoredImageSRC = [];
  481 +
481 482  
482 483 angular.forEach($scope.bodyRegionCoordinates, function (value, key) {
483 484  
... ... @@ -1056,6 +1057,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1056 1057  
1057 1058 };
1058 1059  
  1060 + if (document.getElementById('canvasDiv') != null)
1059 1061 document.getElementById('canvasDiv').appendChild(FlipedImgCanvas);
1060 1062  
1061 1063  
... ... @@ -1314,7 +1316,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1314 1316 context.drawImage(img, 0, 0);
1315 1317 };
1316 1318  
1317   - document.getElementById('canvasDiv').appendChild(imgCanvas);
  1319 + if (document.getElementById('canvasDiv')!=null)
  1320 + document.getElementById('canvasDiv').appendChild(imgCanvas);
1318 1321  
1319 1322 }
1320 1323  
... ... @@ -1333,12 +1336,27 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1333 1336 $scope.machedTermNoLocation = [];
1334 1337 console.log(' TermList.length= ' + TermList.length)
1335 1338  
1336   - for (var i = 0; i < TermList.length; i++) {
  1339 + //for (var i = 0; i < TermList.length; i++) {
1337 1340  
1338   - $timeout(callHight(TermList[i]._TermNumber), 5)
  1341 + // $timeout(callHight(TermList[i]._TermNumber), 5)
1339 1342  
1340 1343  
1341   - }
  1344 + //}
  1345 +
  1346 + var worker = new Worker('term-wp.js');
  1347 +
  1348 + worker.onmessage = function (e) {
  1349 + alert(e.data.PiValue);
  1350 + };
  1351 + worker.onerror = function (e) {
  1352 + alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
  1353 + };
  1354 +
  1355 + //start the worker
  1356 + worker.postMessage({
  1357 +
  1358 + 'value':100000
  1359 + });
1342 1360 }
1343 1361  
1344 1362  
... ... @@ -1815,6 +1833,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1815 1833 tempCanvas.style.left = 200 + 'px';
1816 1834 tempCanvas.style.backgroundColor = "transparent";
1817 1835 tempCanvas.style.visibility = 'hidden';
  1836 + if (document.getElementById('canvasDiv')!=null)
1818 1837 document.getElementById('canvasDiv').appendChild(tempCanvas);
1819 1838  
1820 1839 // //debugger;
... ... @@ -2261,6 +2280,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2261 2280 tempCanvas.style.backgroundColor = "transparent";
2262 2281 tempCanvas.style.visibility = 'hidden';
2263 2282 tempCanvas.style.border = "black 1px solid";
  2283 + if( document.getElementById('canvasDiv')!=null)
2264 2284 document.getElementById('canvasDiv').appendChild(tempCanvas);
2265 2285 }
2266 2286  
... ... @@ -2295,6 +2315,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2295 2315 transparencyCanvas.style.border = "black 1px solid";
2296 2316 transparencyCanvas.style.backgroundColor = "transparent";
2297 2317 // transparencyCanvas.style.visibility = 'hidden';
  2318 + if (document.getElementById('canvasDiv') != null)
2298 2319 document.getElementById('canvasDiv').appendChild(transparencyCanvas);
2299 2320 $scope.transparencyChangeCounter = 0;
2300 2321  
... ... @@ -2571,6 +2592,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2571 2592 transparencyTempCanvas.style.visibility = 'hidden';
2572 2593 //transparencyTempCanvas.style.visibility = 'visible';
2573 2594 // transparencyCanvas.style.zIndex = 4000;
  2595 + if (document.getElementById('canvasDiv') != null)
2574 2596 document.getElementById('canvasDiv').appendChild(transparencyTempCanvas);
2575 2597  
2576 2598 //create temp mask canvas
... ... @@ -2582,6 +2604,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2582 2604 transparencyTempcanavsMask.style.visibility = 'hidden';
2583 2605 //transparencyTempCanvas.style.visibility = 'visible';
2584 2606 // transparencyCanvas.style.border = "black 1px solid";
  2607 + if (document.getElementById('canvasDiv') != null)
2585 2608 document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
2586 2609  
2587 2610  
... ... @@ -2813,6 +2836,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2813 2836 transparencyCanvas.style.left = tCanvas.style.left; // x + "px";
2814 2837 transparencyCanvas.style.top = tCanvas.style.top//y + "px";
2815 2838 transparencyCanvas.style.border = "black 1px solid";
  2839 + if (document.getElementById('canvasDiv') != null)
2816 2840 document.getElementById('canvasDiv').appendChild(transparencyCanvas);
2817 2841  
2818 2842 $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } });
... ... @@ -2838,6 +2862,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2838 2862 tempCanvas.style.visibility = 'hidden';
2839 2863 // tempCanvas.style.border = "black 1px solid";
2840 2864  
  2865 + if (document.getElementById('canvasDiv') != null)
2841 2866 document.getElementById('canvasDiv').appendChild(tempCanvas);
2842 2867  
2843 2868  
... ... @@ -2950,6 +2975,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2950 2975 transparencyTempcanavsMask.style.top = nomMirroredBodyRegion[0].Y + "px"//y + "px";
2951 2976 transparencyTempcanavsMask.style.visibility = 'hidden';
2952 2977  
  2978 + if (document.getElementById('canvasDiv') != null)
2953 2979 document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
2954 2980  
2955 2981 var tranparencyImgSrc = $scope.GetImageSource(clickedBodyRegion);
... ... @@ -3707,6 +3733,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3707 3733 paintCanvas.addEventListener('mousedown', OnPaintCanvasMouseDown, false)
3708 3734 paintCanvas.addEventListener('mouseup', OnPaintCanvasMouseUp, false)
3709 3735  
  3736 + if (document.getElementById('canvasDiv') != null)
3710 3737 document.getElementById('canvasDiv').appendChild(paintCanvas);
3711 3738  
3712 3739 $scope.paintCanvasContext = document.getElementById('paintCanvas').getContext('2d');
... ...
400-SOURCECODE/AIAHTML5.Web/libs/worker.js 0 → 100644
  1 +onmessage = function (event) {
  2 + var arguments = JSON.parse(event.data);
  3 + run(arguments.start, arguments.end);
  4 +};
  5 +function run(start, end) {
  6 + var n = start;
  7 +
  8 + while (n < end) {
  9 + var k = Math.sqrt(n);
  10 + var found = false;
  11 +
  12 + for (var i = 2; !found && i <= k; ++i) {
  13 + found = n % i === 0;
  14 + }
  15 +
  16 + if (!found) {
  17 + postMessage(n.toString());
  18 + }
  19 +
  20 + n++;
  21 + }
  22 +}
0 23 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.Web/term-wp.js 0 → 100644
  1 +
  2 +function CalculatePi(loop) {
  3 + var c = parseInt(loop);
  4 + var f = parseFloat(loop);
  5 + var n = 1;
  6 +
  7 +
  8 + if (isNaN(c) || f != c) {
  9 + throw ("errInvalidNumber");
  10 + } else if (c <= 0) {
  11 + throw ("errNegativeNumber");
  12 + }
  13 +
  14 + for (var i = 0, Pi = 0; i <= c; i++) {
  15 + Pi = Pi + (4 / n) - (4 / (n + 2));
  16 + n = n + 4;
  17 + }
  18 + self.postMessage({ 'PiValue': Pi });
  19 +}
  20 +
  21 +self.onmessage = function (e) {
  22 + CalculatePi(e.data.value);
  23 +}
0 24 \ No newline at end of file
... ...