5 elgg.provide(
'elgg.upgrades');
8 elgg.upgrades.errorMessages = [];
10 elgg.upgrades.init =
function () {
11 $(
'#upgrade-run').
click(
elgg.upgrades.run);
19 elgg.upgrades.run =
function(e) {
23 var total = $(
'#upgrade-total').
text();
26 $(
'.elgg-progressbar').progressbar({
32 $(
'#upgrade-run').addClass(
'hidden');
33 $(
'#upgrade-spinner').removeClass(
'hidden');
36 elgg.upgrades.upgradeBatch(0);
44 elgg.upgrades.upgradeBatch =
function(offset) {
52 options.data =
elgg.security.addToken(options.data);
54 var upgradeCount = $(
'#upgrade-count');
55 var
action = $(
'#upgrade-run').attr(
'href');
57 options.success =
function(json) {
59 if (json.system_messages.error.length) {
61 $(json.system_messages.error).each(
function(key,
message) {
62 if (jQuery.inArray(
message,
elgg.upgrades.errorMessages) === -1) {
63 var msg =
'<li class="elgg-message elgg-state-error">' +
message +
'</li>';
64 $(
'#upgrade-messages').append(msg);
73 var numSuccess = $(
'#upgrade-success-count');
74 var successCount = parseInt(numSuccess.text()) + json.output.numSuccess;
75 numSuccess.text(successCount);
78 var numErrors = $(
'#upgrade-error-count');
79 var errorCount = parseInt(numErrors.text()) + json.output.numErrors;
80 numErrors.text(errorCount);
83 var numProcessed = successCount + errorCount;
84 upgradeCount.text(numProcessed);
87 $(
'.elgg-progressbar').progressbar({ value: numProcessed });
88 var total = $(
'#upgrade-total').
text();
91 if (numProcessed < total) {
92 percent = parseInt(numProcessed * 100 / total);
98 elgg.upgrades.upgradeBatch(errorCount);
100 $(
'#upgrade-spinner').addClass(
'hidden');
102 if (errorCount > 0) {
104 elgg.register_error(
elgg.echo(
'upgrade:finished_with_errors'));
107 elgg.action(action, {
'upgrade_completed': 1});
108 elgg.system_message(
elgg.echo(
'upgrade:finished'));
113 $(
'#upgrade-counter').
text(percent +
'%');
118 return elgg.post(action, options);
121 elgg.register_hook_handler(
'init',
'system',
elgg.upgrades.init);
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})