1 | /*global $, dotclear */ |
---|
2 | 'use strict'; |
---|
3 | |
---|
4 | $(function() { |
---|
5 | $('.step-box').each(function() { |
---|
6 | var code = $('input[name=code]', this).val(); |
---|
7 | |
---|
8 | $('.step-submit', this).remove(); |
---|
9 | $('.step-back', this).hide(); |
---|
10 | $('.step-msg', this).after( |
---|
11 | $('<p>').addClass('step-wait').text( |
---|
12 | dotclear.msg.wait |
---|
13 | ) |
---|
14 | ); |
---|
15 | |
---|
16 | dcMaintenanceStep(this, code); |
---|
17 | |
---|
18 | function dcMaintenanceStep(box, code) { |
---|
19 | var params = { |
---|
20 | f: 'dcMaintenanceStep', |
---|
21 | xd_check: dotclear.nonce, |
---|
22 | task: $(box).attr('id'), |
---|
23 | code: code |
---|
24 | }; |
---|
25 | $.post('services.php', params, function(data) { |
---|
26 | if ($('rsp[status=failed]', data).length > 0) { |
---|
27 | $('.step-msg', box).text( |
---|
28 | $('rsp', data).text() |
---|
29 | ); |
---|
30 | $('.step-wait', box).remove(); |
---|
31 | $('.step-back', box).show(); |
---|
32 | } else { |
---|
33 | $('.step-msg', box).text( |
---|
34 | $('rsp>step', data).attr('title') |
---|
35 | ); |
---|
36 | var code = $('rsp>step', data).attr('code'); |
---|
37 | if (code > 0) { |
---|
38 | dcMaintenanceStep(box, code); |
---|
39 | } else { |
---|
40 | $('#content h2').after($('<div/>').addClass('success').append($('.step-msg', box))); |
---|
41 | $('.step-wait', box).remove(); |
---|
42 | $('.step-back', box).show(); |
---|
43 | } |
---|
44 | } |
---|
45 | }); |
---|
46 | } |
---|
47 | }); |
---|
48 | }); |
---|