3
$(document).ready(function() {
5
$('.swift-settings').each(function() {
6
var $container = $(this);
8
$('select.bucket', $container).change(function() {
11
if ($select.val() !== 'new') {
15
var error_func = function(jqXHR, textStatus, errorThrown) {
16
alert(swift_i18n.create_bucket_error + errorThrown);
17
$select[0].selectedIndex = 0;
19
console.log( textStatus );
20
console.log( errorThrown );
23
var success_func = function(data, textStatus, jqXHR) {
24
if (typeof data['success'] !== 'undefined') {
25
var opt = document.createElement('option');
26
opt.value = opt.innerHTML = bucket_name;
27
var inserted_at_position = 0;
28
$('option', $select).each(function() {
29
// For some reason, no error occurs when
30
// adding a bucket you've already added
31
if ($(this).val() == bucket_name) {
34
if ($(this).val() > bucket_name) {
35
$(opt).insertBefore($(this));
38
inserted_at_position = inserted_at_position + 1;
40
$select[0].selectedIndex = inserted_at_position;
42
// If they decided to create a new bucket before refreshing
43
// the page, we need another nonce
44
swift_i18n.create_bucket_nonce = data['_nonce'];
47
alert(swift_i18n.create_bucket_error + data['error']);
48
$select[0].selectedIndex = 0;
52
var bucket_name = window.prompt(swift_i18n.create_bucket_prompt);
54
$select[0].selectedIndex = 0;
59
action: 'swift-create-bucket',
60
bucket_name: bucket_name,
61
_nonce: swift_i18n.create_bucket_nonce
68
success: success_func,
b'\\ No newline at end of file'