var todo = 0; var queuedManager = $.manageAjax.create('queued', { queue: true, maxRequests: 1, beforeSend: function() { autoupdate_bar_toggle(1); }, complete: function() { autoupdate_bar_toggle(-1); } }); function updateAll() { if (confirm(confirmMsg)) { jQuery('.updateExtension').each( function() { if (jQuery(this).parents('div').css('display') == 'block') jQuery(this).click(); }); } }; function resetIgnored() { jQuery.ajax({ type: 'GET', url: 'ws.php', dataType: 'json', data: { method: 'pwg.extensions.ignoreUpdates', reset: true, pwg_token: pwg_token, format: 'json' }, success: function(data) { if (data['stat'] == 'ok') { jQuery(".pluginBox, fieldset").show(); jQuery("#update_all").show(); jQuery("#up_to_date").hide(); jQuery("#reset_ignore").hide(); jQuery("#ignored").hide(); checkFieldsets(); } } }); }; function checkFieldsets() { var types = new Array('plugin', 'theme', 'language'); var total = 0; var ignored = 0; for (i=0;i<3;i++) { nbExtensions = 0; jQuery("div[id^='"+types[i]+"_']").each(function(index) { if (jQuery(this).css('display') == 'block') nbExtensions++; else ignored++; }); total = total + nbExtensions; if (nbExtensions == 0) jQuery("#"+types[i]+"s").hide(); } if (total == 0) { jQuery("#update_all").hide(); jQuery("#up_to_date").show(); } if (ignored > 0) { jQuery("#reset_ignore").val(restoreMsg + ' (' + ignored + ')'); } }; function upgradeExtension(type, id, revision) { queuedManager.add({ type: 'GET', dataType: 'json', url: 'ws.php', data: { method: 'pwg.'+type+'s.update', id: id, revision: revision, pwg_token: pwg_token, format: 'json' }, success: function(data) { if (data['stat'] == 'ok') { jQuery.jGrowl( data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false }); jQuery("#"+type+"_"+id).remove(); checkFieldsets(); } else { jQuery.jGrowl( data['result'], { theme: 'error', header: errorHead, sticky: true }); } }, error: function(data) { jQuery.jGrowl( errorMsg, { theme: 'error', header: errorHead, sticky: true }); } }); }; function ignoreExtension(type, id) { jQuery.ajax({ type: 'GET', url: 'ws.php', dataType: 'json', data: { method: 'pwg.extensions.ignoreUpdates', type: type+'s', id: id, pwg_token: pwg_token, format: 'json' }, success: function(data) { if (data['stat'] == 'ok') { jQuery("#"+type+"_"+id).hide(); jQuery("#reset_ignore").show(); checkFieldsets(); } } }); }; function autoupdate_bar_toggle(i) { todo = todo + i; if ((i == 1 && todo == 1) || (i == -1 && todo == 0)) jQuery('.autoupdate_bar').toggle(); }