/* * Copyright (c) 2014 * * This file is licensed under the Affero General Public License version 3 * or later. * * See the COPYING-README file. * */ (function() { OC.Update = { _started : false, /** * Start the upgrade process. * * @param $el progress list element */ start: function($el) { var self = this; if (this._started) { return; } this.$el = $el; this._started = true; this.addMessage(t( 'core', 'Updating {productName} to version {version}, this may take a while.', { productName: OC.theme.name, version: OC.config.versionstring }), 'bold' ).append('
'); // FIXME: these should be ul/li with CSS paddings! var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); updateEventSource.listen('success', function(message) { $('').append(message).append('
').appendTo($el); }); updateEventSource.listen('error', function(message) { $('').addClass('error').append(message).append('
').appendTo($el); message = t('core', 'Please reload the page.'); $('').addClass('error').append(message).append('
').appendTo($el); updateEventSource.close(); }); updateEventSource.listen('failure', function(message) { $('').addClass('error').append(message).append('
').appendTo($el); $('') .addClass('error bold') .append('
') .append(t('core', 'The update was unsuccessful.' + 'Please report this issue to the ownCloud community.')) .appendTo($el); }); updateEventSource.listen('done', function(message) { // FIXME: use product name $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($el); setTimeout(function () { OC.redirect(OC.webroot); }, 3000); }); }, addMessage: function(message, className) { var $span = $(''); $span.addClass(className).append(message).append('
').appendTo(this.$el); return $span; } }; })(); $(document).ready(function() { $('.updateForm').on('submit', function(ev) { ev.preventDefault(); var $progressEl = $('.updateProgress'); $progressEl.removeClass('hidden'); $('.updateForm').addClass('hidden'); OC.Update.start($progressEl); return false; }); });