source: other-projects/nz-flag-design/trunk/similarity-2d/flag-processing.js@ 29622

Last change on this file since 29622 was 29622, checked in by davidb, 9 years ago

Further restructuring of the display flags JSP page. Improved progress-bar loading

File size: 1.3 KB
Line 
1
2var progressVal = 0;
3
4
5function drawImage(imageObj, canvasId) {
6 "use strict";
7 var imgCanvas = document.getElementById(canvasId),
8 context, imageData, data,
9 imageX = 0, imageY = 0,
10 imageWidth = imageObj.width,
11 imageHeight = imageObj.height;
12 context = imgCanvas.getContext('2d');
13 context.drawImage(imageObj, imageX, imageY, imageWidth, imageHeight);
14 imageData = context.getImageData(imageX, imageY, imageWidth, imageHeight);
15 //data = imageData.data;
16 return imageData;
17}
18
19
20function displayFlags(img_list,$displayDiv,$progressArea,$progressBar)
21{
22 var i;
23
24 var root_img_re = /^.*\/(.*?)\..*?$/;
25
26 var img_list_len = img_list.length;
27 var progress_step = 100.0 / img_list_len;
28
29 var callback_count = 0;
30
31 for (i=0; i<img_list.length; i++) {
32 var img_url = img_list[i];
33 var img_matches = root_img_re.exec(img_url);
34 var title = img_matches[1];
35
36 var imageObj = new Image();
37 imageObj.onload = function () {
38 callback_count++;
39 progressVal += progress_step;
40 $progressBar.progressbar('value',progressVal);
41
42 //image1Data = drawImage(this, "canvas1");
43
44 if (callback_count == img_list_len) {
45 $progressArea.slideUp();
46 }
47 };
48
49 imageObj.src = img_url;
50 imageObj.title = title;
51
52 $displayDiv.append(imageObj);
53 }
54}
55
56
57
Note: See TracBrowser for help on using the repository browser.