This repository has been archived by the owner on Feb 23, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Cdn_RackSpaceCdn_Page_View.js
159 lines (117 loc) · 4.35 KB
/
Cdn_RackSpaceCdn_Page_View.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
jQuery(function($) {
function w3tc_rackspace_resize(o) {
o.options.height = jQuery('.w3tc_cdn_rackspace_form').height() + 30;
o.resize();
}
function w3tc_rackspace_created(o) {
w3tc_rackspace_resize(o);
w3tc_rackspace_check_service_state();
}
function w3tc_rackspace_check_service_state() {
var service_id = jQuery('input[name="service_id"]').val();
var access_token = jQuery('input[name="access_token"]').val();
var access_region_descriptor = jQuery('input[name="access_region_descriptor"]').val();
jQuery.post(ajaxurl,
{
'action': 'w3tc_ajax',
'_wpnonce': w3tc_nonce,
'service_id': service_id,
'access_token': access_token,
'access_region_descriptor': access_region_descriptor,
'w3tc_action': 'cdn_rackspace_service_get_state'
}, function(data) {
var state = 'unknown';
if (data && data['status'])
status = data['status'];
jQuery('.w3tc_rackspace_created_status').html(status);
if (status == 'deployed')
w3tc_rackspace_service_created_done(data);
else
setTimeout(w3tc_rackspace_check_service_state, 5000);
}, 'json'
).fail(function() {
jQuery('.w3tc_rackspace_created_state').html('Failed to obtain state');
setTimeout(w3tc_rackspace_check_service_state, 5000);
});
}
function w3tc_rackspace_service_created_done(data) {
jQuery('.w3tc_rackspace_cname').html(data['cname']);
jQuery('.w3tc_rackspace_access_url').html(data['access_url']);
jQuery('.w3tc_rackspace_created_in_progress').css('display', 'none');
jQuery('.w3tc_rackspace_created_done').css('display', '');
w3tc_rackspace_resize(W3tc_Lightbox);
}
$('body')
/**
* Authorize popup
*/
.on('click', '.w3tc_cdn_rackspace_authorize', function() {
W3tc_Lightbox.open({
id:'w3tc-overlay',
close: '',
width: 800,
height: 300,
url: ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
'&w3tc_action=cdn_rackspace_intro',
callback: w3tc_rackspace_resize
});
})
.on('click', '.w3tc_popup_submit', function() {
var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce;
W3tc_Lightbox.load_form(url, '.w3tc_cdn_rackspace_form',
w3tc_rackspace_resize);
})
.on('click', '.w3tc_cdn_rackspace_service_create_done', function() {
var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
'&w3tc_action=cdn_rackspace_service_create_done';
W3tc_Lightbox.load_form(url, '.w3tc_cdn_rackspace_form',
w3tc_rackspace_created);
})
.on('click', '.w3tc_cdn_rackspace_protocol', function() {
var protocol = '';
$('body').find('.w3tc_cdn_rackspace_protocol').each(function(i) {
if (!jQuery(this).prop('checked'))
return;
protocol = $(this).val();
});
//alert('ha ' + protocol);
$('.w3tc_cdn_rackspace_cname_http').css('display',
(protocol == 'http' ? '' : 'none'));
$('.w3tc_cdn_rackspace_cname_https').css('display',
(protocol == 'https' ? '' : 'none'));
})
/**
* CNAMEs popup
*/
.on('click', '.w3tc_cdn_rackspace_configure_domains', function() {
W3tc_Lightbox.open({
id:'w3tc-overlay',
close: '',
width: 1000,
height: 400,
url: ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
'&w3tc_action=cdn_rackspace_configure_domains',
callback: function(o) {
w3tc_rackspace_resize(o);
w3tc_cdn_cnames_assign();
}
});
})
.on('click', '.w3tc_cdn_rackspace_configure_domains_done', function() {
var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce +
'&w3tc_action=cdn_rackspace_configure_domains_done';
var v = $('.w3tc_cdn_rackspace_form').find('input').each(function(i) {
var name = $(this).attr('name');
if (name)
url += '&' + encodeURIComponent(name) + '=' +
encodeURIComponent($(this).val());
});
W3tc_Lightbox.load(url, function(o) {
w3tc_rackspace_resize(o);
w3tc_cdn_cnames_assign();
});
})
.on('size_change', '#cdn_cname_add', function() {
w3tc_rackspace_resize(W3tc_Lightbox);
})
});