source: extensions/autoupdate/trunk/template/autoupdate.js @ 9721

Last change on this file since 9721 was 9721, checked in by patdenice, 13 years ago

Add ajax loader bar.

File size: 2.8 KB
Line 
1function updateAll() {
2  if (confirm(confirmMsg)) {
3    extList = [];
4    jQuery('.updateExtension').each( function() {
5      if (jQuery(this).parents('div').css('display') == 'block') {
6        extList.push(jQuery(this).attr('onClick'));
7      }
8    });
9    if (extList.length > 0) eval(extList[0]);
10  }
11  return false;
12};
13
14function resetIgnored() {
15  jQuery.post(
16    "plugins/autoupdate/ajax/ignore_list.php",
17    { reset: true },
18    function(data) {
19      if (data == "ok") {
20        jQuery(".pluginBox, fieldset").show();
21        jQuery("#update_all").show();
22        jQuery("#up_to_date").hide();
23        jQuery("#reset_ignore").hide();
24        jQuery("#ignored").hide();
25      }
26    }
27  );
28  return false;
29};
30
31function checkFieldsets() {
32  var types = new Array('plugin', 'theme', 'language');
33  var total = 0;
34  var ignored = 0;
35  for (i=0;i<3;i++) {
36    nbExtensions = 0;
37    jQuery("div[id^='"+types[i]+"_']").each(function(index) {
38        if (jQuery(this).css('display') == 'block')
39          nbExtensions++;
40        else
41          ignored++;
42      });
43    total = total + nbExtensions;
44    if (nbExtensions == 0)
45      jQuery("#"+types[i]+"s").hide();
46  }
47
48  if (total == 0) {
49    jQuery("#update_all").hide();
50    jQuery("#up_to_date").show();
51  }
52  if (ignored > 0) {
53    jQuery("#reset_ignore").val(restoreMsg + ' (' + ignored + ')');
54  }
55};
56
57function upgradeExtension(type, id, revision) {
58  jQuery('.autoupdate_bar').toggle();
59  jQuery.ajax({
60    type: 'POST',
61    url: 'plugins/autoupdate/ajax/update_'+type+'.php',
62    data: { id: id, revision: revision },
63    success: function(data) {
64      if (data['result']) {
65        jQuery("#"+type+"_"+id).remove();
66        checkFieldsets();
67        jQuery.jGrowl(
68          data['msg'],
69          {
70            theme:  'success',
71            header: successHead,
72            life:   4000,
73            sticky: false
74          }
75        );
76        if (extList.length > 0) extList.shift();
77        if (extList.length > 0) eval(extList[0]);
78      } else {
79        jQuery.jGrowl(
80          data['msg'],
81          {
82            theme:  'error',
83            header: errorHead,
84            sticky: true
85          }
86        );
87        extList = [];
88      }
89      jQuery('.autoupdate_bar').toggle();
90    },
91    error: function(data) {
92      jQuery.jGrowl(
93        errorMsg,
94        {
95          theme:  'error',
96          header: errorHead,
97          sticky: true
98        }
99      );
100      extList = [];
101      jQuery('.autoupdate_bar').toggle();
102    },
103    dataType: 'json'
104  });
105  return false;
106};
107
108function ignoreExtension(type, id) {
109  jQuery.post(
110    "plugins/autoupdate/ajax/ignore_list.php",
111    { type: type+'s', id: id },
112    function(data) {
113      if (data == "ok") {
114        jQuery("#"+type+"_"+id).hide();
115        jQuery("#reset_ignore").show();
116        checkFieldsets();
117      }
118    }
119  );
120  return false;
121};
Note: See TracBrowser for help on using the repository browser.