1 | var todo = 0; |
---|
2 | var queuedManager = $.manageAjax.create('queued', { |
---|
3 | queue: true, |
---|
4 | maxRequests: 1, |
---|
5 | beforeSend: function() { autoupdate_bar_toggle(1); }, |
---|
6 | complete: function() { autoupdate_bar_toggle(-1); } |
---|
7 | }); |
---|
8 | |
---|
9 | function updateAll() { |
---|
10 | if (confirm(confirmMsg)) { |
---|
11 | jQuery('.updateExtension').each( function() { |
---|
12 | if (jQuery(this).parents('div').css('display') == 'block') |
---|
13 | jQuery(this).click(); |
---|
14 | }); |
---|
15 | } |
---|
16 | }; |
---|
17 | |
---|
18 | function resetIgnored() { |
---|
19 | jQuery.ajax({ |
---|
20 | type: 'GET', |
---|
21 | url: 'ws.php', |
---|
22 | dataType: 'json', |
---|
23 | data: { method: 'pwg.extensions.ignoreUpdates', reset: true, pwg_token: pwg_token, format: 'json' }, |
---|
24 | success: function(data) { |
---|
25 | if (data['stat'] == 'ok') { |
---|
26 | jQuery(".pluginBox, fieldset").show(); |
---|
27 | jQuery("#update_all").show(); |
---|
28 | jQuery("#up_to_date").hide(); |
---|
29 | jQuery("#reset_ignore").hide(); |
---|
30 | jQuery("#ignored").hide(); |
---|
31 | checkFieldsets(); |
---|
32 | } |
---|
33 | } |
---|
34 | }); |
---|
35 | }; |
---|
36 | |
---|
37 | function checkFieldsets() { |
---|
38 | var types = new Array('plugin', 'theme', 'language'); |
---|
39 | var total = 0; |
---|
40 | var ignored = 0; |
---|
41 | for (i=0;i<3;i++) { |
---|
42 | nbExtensions = 0; |
---|
43 | jQuery("div[id^='"+types[i]+"_']").each(function(index) { |
---|
44 | if (jQuery(this).css('display') == 'block') |
---|
45 | nbExtensions++; |
---|
46 | else |
---|
47 | ignored++; |
---|
48 | }); |
---|
49 | total = total + nbExtensions; |
---|
50 | if (nbExtensions == 0) |
---|
51 | jQuery("#"+types[i]+"s").hide(); |
---|
52 | } |
---|
53 | |
---|
54 | if (total == 0) { |
---|
55 | jQuery("#update_all").hide(); |
---|
56 | jQuery("#up_to_date").show(); |
---|
57 | } |
---|
58 | if (ignored > 0) { |
---|
59 | jQuery("#reset_ignore").val(restoreMsg + ' (' + ignored + ')'); |
---|
60 | } |
---|
61 | }; |
---|
62 | |
---|
63 | function upgradeExtension(type, id, revision) { |
---|
64 | queuedManager.add({ |
---|
65 | type: 'GET', |
---|
66 | dataType: 'json', |
---|
67 | url: 'ws.php', |
---|
68 | data: { method: 'pwg.'+type+'s.update', id: id, revision: revision, pwg_token: pwg_token, format: 'json' }, |
---|
69 | success: function(data) { |
---|
70 | if (data['stat'] == 'ok') { |
---|
71 | jQuery.jGrowl( data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false }); |
---|
72 | jQuery("#"+type+"_"+id).remove(); |
---|
73 | checkFieldsets(); |
---|
74 | } else { |
---|
75 | jQuery.jGrowl( data['result'], { theme: 'error', header: errorHead, sticky: true }); |
---|
76 | } |
---|
77 | }, |
---|
78 | error: function(data) { |
---|
79 | jQuery.jGrowl( errorMsg, { theme: 'error', header: errorHead, sticky: true }); |
---|
80 | } |
---|
81 | }); |
---|
82 | }; |
---|
83 | |
---|
84 | function ignoreExtension(type, id) { |
---|
85 | jQuery.ajax({ |
---|
86 | type: 'GET', |
---|
87 | url: 'ws.php', |
---|
88 | dataType: 'json', |
---|
89 | data: { method: 'pwg.extensions.ignoreUpdates', type: type+'s', id: id, pwg_token: pwg_token, format: 'json' }, |
---|
90 | success: function(data) { |
---|
91 | if (data['stat'] == 'ok') { |
---|
92 | jQuery("#"+type+"_"+id).hide(); |
---|
93 | jQuery("#reset_ignore").show(); |
---|
94 | checkFieldsets(); |
---|
95 | } |
---|
96 | } |
---|
97 | }); |
---|
98 | }; |
---|
99 | |
---|
100 | function autoupdate_bar_toggle(i) { |
---|
101 | todo = todo + i; |
---|
102 | if ((i == 1 && todo == 1) || (i == -1 && todo == 0)) |
---|
103 | jQuery('.autoupdate_bar').toggle(); |
---|
104 | } |
---|