1 |
|
---|
2 | var progressVal = 0;
|
---|
3 |
|
---|
4 |
|
---|
5 | function 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 |
|
---|
20 | function displayFlags(img_list,$displayDiv,$progressArea,$progressBar)
|
---|
21 | {
|
---|
22 | var img_list_len = img_list.length;
|
---|
23 | var show_progress = 5;
|
---|
24 |
|
---|
25 | if (img_list_len==0) {
|
---|
26 | return;
|
---|
27 | }
|
---|
28 | else if (img_list_len>show_progress) {
|
---|
29 | $progressArea.slideDown();
|
---|
30 | }
|
---|
31 |
|
---|
32 | var root_img_re = /^.*\/(.*?)\..*?$/;
|
---|
33 |
|
---|
34 | var progress_step = 100.0 / img_list_len;
|
---|
35 |
|
---|
36 | var callback_count = 0;
|
---|
37 |
|
---|
38 | var i;
|
---|
39 | for (i=0; i<img_list.length; i++) {
|
---|
40 | var img_url = img_list[i];
|
---|
41 | var img_matches = root_img_re.exec(img_url);
|
---|
42 | var title = img_matches[1];
|
---|
43 |
|
---|
44 | var imageObj = new Image();
|
---|
45 | imageObj.onload = function () {
|
---|
46 | callback_count++;
|
---|
47 | progressVal += progress_step;
|
---|
48 | $progressBar.progressbar('value',progressVal);
|
---|
49 |
|
---|
50 | //image1Data = drawImage(this, "canvas1");
|
---|
51 |
|
---|
52 | if (callback_count == img_list_len) {
|
---|
53 | if (img_list_len>show_progress) {
|
---|
54 | $progressArea.slideUp();
|
---|
55 | }
|
---|
56 | }
|
---|
57 | };
|
---|
58 |
|
---|
59 | imageObj.src = img_url;
|
---|
60 | imageObj.title = title;
|
---|
61 |
|
---|
62 | $displayDiv.append(imageObj);
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|