1 | jQuery(document).ready( |
---|
2 | function (jQuery) { |
---|
3 | |
---|
4 | |
---|
5 | }); |
---|
6 | |
---|
7 | //============================================================ |
---|
8 | var derivatives = { |
---|
9 | elements: null, |
---|
10 | done: 0, |
---|
11 | total: 0, |
---|
12 | finished: function() { |
---|
13 | derivatives.elements.splice(0, 1); |
---|
14 | return derivatives.done == derivatives.total && derivatives.elements && derivatives.elements.length==0; |
---|
15 | } |
---|
16 | }; |
---|
17 | |
---|
18 | function progress(success,data) { |
---|
19 | if (success) { |
---|
20 | |
---|
21 | jQuery("#theMainImage").trigger("ON", [{ nb: derivatives.total - derivatives.done, total: derivatives.total, done: derivatives.done,status:"ok",src:data.url}]); |
---|
22 | } else { |
---|
23 | |
---|
24 | if (data.statusText == "OK") { |
---|
25 | |
---|
26 | } else { |
---|
27 | jQuery("#theMainImage").trigger("ON", [{ nb: derivatives.total - derivatives.done, total: derivatives.total, done: derivatives.done, status: "Nok", responseText: data.responseText}]); |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | if (derivatives.finished()) { |
---|
32 | jQuery("#theMainImage").trigger("Finish", [derivatives]); |
---|
33 | } |
---|
34 | |
---|
35 | } |
---|
36 | |
---|
37 | derivatives.elements = []; |
---|
38 | var ids = derivatives.elements.splice(0, 500); |
---|
39 | var params = { max_urls: 10, ids: ids, types: [], src: [] }; |
---|
40 | |
---|
41 | function getDerivativeUrls(nofile) { |
---|
42 | params.max_urls = nofile.length; |
---|
43 | jQuery(nofile).each(function (i, t) { |
---|
44 | if (typeof t.file != "undefined") { |
---|
45 | nbsrc = params.src.length; |
---|
46 | t.file= t.file.replace("/","",1); |
---|
47 | if (nbsrc == 0) { |
---|
48 | params.ids.push(t.id); |
---|
49 | params.types.push(t.type); |
---|
50 | params.src.push(t.file); |
---|
51 | } else if (~jQuery.inArray(t.file, params.src)) { |
---|
52 | jQuery.noop(); |
---|
53 | } else { |
---|
54 | params.ids.push(t.id); |
---|
55 | params.types.push(t.type); |
---|
56 | params.src.push(t.file); |
---|
57 | } |
---|
58 | } |
---|
59 | }); |
---|
60 | |
---|
61 | if(derivatives.elements.length==0) |
---|
62 | derivatives.elements = params.ids; |
---|
63 | derivatives.total += params.src.length; |
---|
64 | |
---|
65 | |
---|
66 | Set_images = function (dataUrls) { |
---|
67 | if (typeof jQuery.manageAjax != "undefined") { |
---|
68 | for (var i = 0; i < dataUrls.length; i++) { |
---|
69 | jQuery.manageAjax.add("queued", { |
---|
70 | type: 'GET', |
---|
71 | url: 'i.php?' + dataUrls[i] + "&ajaxload=true", |
---|
72 | dataType: 'json', |
---|
73 | success: (function (data) { |
---|
74 | derivatives.done++; |
---|
75 | progress(true, data); |
---|
76 | }), |
---|
77 | error: (function (data) { |
---|
78 | derivatives.done++; |
---|
79 | progress(data.statusText == "NOK", data); |
---|
80 | }), |
---|
81 | fail: (function (data) { |
---|
82 | a = data.statusText; |
---|
83 | }), |
---|
84 | progress: (function (data) { |
---|
85 | a = data.statusText; |
---|
86 | }), |
---|
87 | |
---|
88 | complete: (function (data) { |
---|
89 | progress(false, data); |
---|
90 | }), |
---|
91 | isRejected: (function (data) { |
---|
92 | a = data.responseText; |
---|
93 | }) |
---|
94 | |
---|
95 | }); |
---|
96 | } |
---|
97 | |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | if (derivatives.elements.length) { |
---|
103 | if (derivatives.total - derivatives.done > 0) |
---|
104 | setTimeout("Set_images(params.src)", 500 * (derivatives.total - derivatives.done)); |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | } //ready |
---|
110 | //=============================================================== |
---|