11 var errorMessages = [];
18 var
run =
function(e) {
22 var total = $(
'#upgrade-total').
text();
25 $(
'.elgg-progressbar').progressbar({
31 $(
'#upgrade-run').addClass(
'hidden');
32 $(
'#upgrade-spinner').removeClass(
'hidden');
43 var upgradeBatch =
function(offset) {
51 options.data = elgg.security.addToken(options.data);
53 var upgradeCount = $(
'#upgrade-count');
54 var
action = $(
'#upgrade-run').attr(
'href');
56 options.success =
function(json) {
58 if (json.system_messages.error.length) {
60 $(json.system_messages.error).each(
function(key,
message) {
62 var msg =
'<li class="elgg-message elgg-state-error">' +
message +
'</li>';
63 $(
'#upgrade-messages').append(msg);
72 var numSuccess = $(
'#upgrade-success-count');
73 var successCount = parseInt(numSuccess.text()) + json.output.numSuccess;
74 numSuccess.text(successCount);
77 var numErrors = $(
'#upgrade-error-count');
78 var errorCount = parseInt(numErrors.text()) + json.output.numErrors;
79 numErrors.text(errorCount);
82 var numProcessed = successCount + errorCount;
83 upgradeCount.text(numProcessed);
86 $(
'.elgg-progressbar').progressbar({ value: numProcessed });
87 var total = $(
'#upgrade-total').
text();
90 if (numProcessed < total) {
91 percent = parseInt(numProcessed * 100 / total);
97 upgradeBatch(errorCount);
99 $(
'#upgrade-spinner').addClass(
'hidden');
101 if (errorCount > 0) {
103 elgg.register_error(elgg.echo(
'upgrade:finished_with_errors'));
106 elgg.action(action, {
'upgrade_completed': 1});
107 elgg.system_message(elgg.echo(
'upgrade:finished'));
112 $(
'#upgrade-counter').
text(percent +
'%');
117 return elgg.post(action, options);
120 $(
'#upgrade-run').
click(run);
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when run
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.
elgg require
Throw an error if the required package isn't present.
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})