Elgg  Version 2.3
Functions
upgrades.js File Reference

Go to the source code of this file.

Functions

 define (function(require){var $=require('jquery');var elgg=require('elgg');var errorMessages=[];var run=function(e){e.preventDefault();var total=$('#upgrade-total').text();$('.elgg-progressbar').progressbar({value:0, max:total});$('#upgrade-run').addClass('hidden');$('#upgrade-spinner').removeClass('hidden');upgradeBatch(0);};var upgradeBatch=function(offset){var options={data:{offset:offset}, dataType: 'json'};options.data=elgg.security.addToken(options.data);var upgradeCount=$('#upgrade-count');var action=$('#upgrade-run').attr('href');options.success=function(json){if(json.system_messages.error.length){$(json.system_messages.error).each(function(key, message){if(jQuery.inArray(message, errorMessages)===-1){var msg= '< li class="elgg-message elgg-state-error">'+message+ '</li >';$('#upgrade-messages').append(msg);errorMessages.push(message);}});}var numSuccess=$('#upgrade-success-count');var successCount=parseInt(numSuccess.text())+json.output.numSuccess;numSuccess.text(successCount);var numErrors=$('#upgrade-error-count');var errorCount=parseInt(numErrors.text())+json.output.numErrors;numErrors.text(errorCount);var numProcessed=successCount+errorCount;upgradeCount.text(numProcessed);$('.elgg-progressbar').progressbar({value:numProcessed});var total=$('#upgrade-total').text();var percent=100;if(numProcessed< total){percent=parseInt(numProcessed *100/total);upgradeBatch(errorCount);}else{$('#upgrade-spinner').addClass('hidden');if(errorCount > 0){elgg.register_error(elgg.echo('upgrade:finished_with_errors'));}else{elgg.action(action,{'upgrade_completed':1});elgg.system_message(elgg.echo('upgrade:finished'));}}$('#upgrade-counter').text(percent+ '%');};return elgg.post(action, options);};$('#upgrade-run').click(run);})
 Provides functions for site upgrades performed through XHR. More...
 

Function Documentation

define ( function(require){var $=require('jquery');var elgg=require('elgg');var errorMessages=[];var run=function(e){e.preventDefault();var total=$('#upgrade-total').text();$('.elgg-progressbar').progressbar({value:0, max:total});$('#upgrade-run').addClass('hidden');$('#upgrade-spinner').removeClass('hidden');upgradeBatch(0);};var upgradeBatch=function(offset){var options={data:{offset:offset}, dataType: 'json'};options.data=elgg.security.addToken(options.data);var upgradeCount=$('#upgrade-count');var action=$('#upgrade-run').attr('href');options.success=function(json){if(json.system_messages.error.length){$(json.system_messages.error).each(function(key, message){if(jQuery.inArray(message, errorMessages)===-1){var msg= '< li class="elgg-message elgg-state-error">'+message+ '</li >';$('#upgrade-messages').append(msg);errorMessages.push(message);}});}var numSuccess=$('#upgrade-success-count');var successCount=parseInt(numSuccess.text())+json.output.numSuccess;numSuccess.text(successCount);var numErrors=$('#upgrade-error-count');var errorCount=parseInt(numErrors.text())+json.output.numErrors;numErrors.text(errorCount);var numProcessed=successCount+errorCount;upgradeCount.text(numProcessed);$('.elgg-progressbar').progressbar({value:numProcessed});var total=$('#upgrade-total').text();var percent=100;if(numProcessed< total){percent=parseInt(numProcessed *100/total);upgradeBatch(errorCount);}else{$('#upgrade-spinner').addClass('hidden');if(errorCount > 0){elgg.register_error(elgg.echo('upgrade:finished_with_errors'));}else{elgg.action(action,{'upgrade_completed':1});elgg.system_message(elgg.echo('upgrade:finished'));}}$('#upgrade-counter').text(percent+ '%');};return elgg.post(action, options);};$('#upgrade-run').click(run);}  )

Provides functions for site upgrades performed through XHR.

private

Parameters
function(require){var$=require('jquery');var elgg=require('elgg');var errorMessages=[];var run=function(e){e.preventDefault();var total=$('#upgrade-total').text();$('.elgg-progressbar').progressbar({value:0, max:total});$('#upgrade-run').addClass('hidden');$('#upgrade-spinner').removeClass('hidden');upgradeBatch(0);};var upgradeBatch=function(offset){var options={data:{offset:offset}, dataType: 'json'};options.data=elgg.security.addToken(options.data);var upgradeCount=$('#upgrade-count');var action=$('#upgrade-run').attr('href');options.success=function(json){if(json.system_messages.error.length){$(json.system_messages.error).each(function(key, message){if(jQuery.inArray(message, errorMessages)===-1){var msg= '< li class="elgg-message elgg-state-error">'+message+ '';$('#upgrade-messages').append(msg);errorMessages.push(message);}});}var numSuccess=$('#upgrade-success-count');var successCount=parseInt(numSuccess.text())+json.output.numSuccess;numSuccess.text(successCount);var numErrors=$('#upgrade-error-count');var errorCount=parseInt(numErrors.text())+json.output.numErrors;numErrors.text(errorCount);var numProcessed=successCount+errorCount;upgradeCount.text(numProcessed);$('.elgg-progressbar').progressbar({value:numProcessed});var total=$('#upgrade-total').text();var percent=100;if(numProcessed< total){percent=parseInt(numProcessed *100/total);upgradeBatch(errorCount);}else{$('#upgrade-spinner').addClass('hidden');if(errorCount > 0){elgg.register_error(elgg.echo('upgrade:finished_with_errors'));}else{elgg.action(action,{'upgrade_completed':1});elgg.system_message(elgg.echo('upgrade:finished'));}}$('#upgrade-counter').text(percent+ '');};return elgg.post(action, options);};$('#upgrade-run').click(run);} Initializes the XHR upgrade feature
{Object}e Event object

Fires the ajax action to upgrade a batch of items.

Parameters
{Number}offset The next upgrade offset

Start next upgrade call. Offset is the total amount of erros so far. This prevents faulty items from causing the same error again.