Version Description
Download this release
Release Info
Developer | unbouncewordpress |
Plugin | Unbounce Landing Pages |
Version | 0.1.20 |
Comparing to | |
See all releases |
Code changes from version 0.1.18 to 0.1.20
- UBConfig.php +61 -11
- UBHTTP.php +3 -1
- Unbounce-Page.php +113 -20
- js/rx.lite.compat.min.js +5 -0
- js/set-unbounce-domains.js +107 -0
- readme.txt +13 -4
UBConfig.php
CHANGED
@@ -5,16 +5,21 @@ class UBConfig {
|
|
5 |
const UB_PLUGIN_NAME = 'ub-wordpress';
|
6 |
const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
|
7 |
const UB_REMOTE_DEBUG_KEY = 'ub-remote-debug';
|
|
|
|
|
|
|
|
|
|
|
8 |
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
9 |
-
const UB_USER_AGENT = 'Unbounce WP Plugin 0.1.
|
10 |
-
const UB_VERSION = '0.1.
|
11 |
|
12 |
-
public static function
|
13 |
$domain = getenv('UB_PAGE_SERVER_DOMAIN');
|
14 |
return $domain ? $domain : 'wp.unbounce.com';
|
15 |
}
|
16 |
|
17 |
-
public static function
|
18 |
$url = getenv('UB_REMOTE_LOG_URL');
|
19 |
if ($url == null) {
|
20 |
return 'https://events-gateway.unbounce.com/events/wordpress_logs';
|
@@ -22,6 +27,41 @@ class UBConfig {
|
|
22 |
return $url;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
public static function debug_loggging_enabled() {
|
26 |
return WP_DEBUG || WP_DEBUG_LOG || UBConfig::remote_debug_logging_enabled();
|
27 |
}
|
@@ -30,13 +70,13 @@ class UBConfig {
|
|
30 |
return get_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0) == 1;
|
31 |
}
|
32 |
|
33 |
-
public static function fetch_proxyable_url_set($domain, $etag) {
|
34 |
if(!$domain) {
|
35 |
UBLogger::warning('Domain not provided, not fetching sitemap.xml');
|
36 |
return array('FAILURE', null, null, null);
|
37 |
}
|
38 |
|
39 |
-
$url = 'https://' .
|
40 |
$curl = curl_init();
|
41 |
$curl_options = array(
|
42 |
CURLOPT_URL => $url,
|
@@ -139,8 +179,8 @@ class UBConfig {
|
|
139 |
}
|
140 |
}
|
141 |
|
142 |
-
public static function _read_unbounce_domain_info($
|
143 |
-
$
|
144 |
$fetch_proxyable_url_set,
|
145 |
$domain,
|
146 |
$expire_now=false) {
|
@@ -149,7 +189,8 @@ class UBConfig {
|
|
149 |
|
150 |
$cache_max_time_default = 10;
|
151 |
|
152 |
-
$
|
|
|
153 |
$domain_info = UBUtil::array_fetch($domains_info, $domain, array());
|
154 |
|
155 |
$proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set');
|
@@ -165,7 +206,10 @@ class UBConfig {
|
|
165 |
is_null($proxyable_url_set) ||
|
166 |
($current_time - $proxyable_url_set_fetched_at > $cache_max_time)) {
|
167 |
|
168 |
-
$result_array = call_user_func($fetch_proxyable_url_set,
|
|
|
|
|
|
|
169 |
|
170 |
list($routes_status, $etag, $max_age, $proxyable_url_set_new) = $result_array;
|
171 |
|
@@ -191,7 +235,7 @@ class UBConfig {
|
|
191 |
|
192 |
$domain_info['proxyable_url_set_fetched_at'] = $current_time;
|
193 |
$domains_info[$domain] = $domain_info;
|
194 |
-
$
|
195 |
}
|
196 |
|
197 |
|
@@ -209,5 +253,11 @@ class UBConfig {
|
|
209 |
$expire_now);
|
210 |
}
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
?>
|
5 |
const UB_PLUGIN_NAME = 'ub-wordpress';
|
6 |
const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
|
7 |
const UB_REMOTE_DEBUG_KEY = 'ub-remote-debug';
|
8 |
+
const UB_PAGE_SERVER_DOMAIN_KEY = 'ub-page-server-domain';
|
9 |
+
const UB_REMOTE_LOG_URL_KEY = 'ub-remote-log-url';
|
10 |
+
const UB_API_URL_KEY = 'ub-api-url';
|
11 |
+
const UB_API_CLIENT_ID_KEY = 'ub-api-client-id';
|
12 |
+
const UB_AUTHORIZED_DOMAINS_KEY = 'ub-authorized-domains';
|
13 |
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
14 |
+
const UB_USER_AGENT = 'Unbounce WP Plugin 0.1.20';
|
15 |
+
const UB_VERSION = '0.1.20';
|
16 |
|
17 |
+
public static function default_page_server_domain() {
|
18 |
$domain = getenv('UB_PAGE_SERVER_DOMAIN');
|
19 |
return $domain ? $domain : 'wp.unbounce.com';
|
20 |
}
|
21 |
|
22 |
+
public static function default_remote_log_url() {
|
23 |
$url = getenv('UB_REMOTE_LOG_URL');
|
24 |
if ($url == null) {
|
25 |
return 'https://events-gateway.unbounce.com/events/wordpress_logs';
|
27 |
return $url;
|
28 |
}
|
29 |
|
30 |
+
public static function default_api_url() {
|
31 |
+
$url = getenv('UB_API_URL');
|
32 |
+
return $url ? $url : 'https://api.unbounce.com';
|
33 |
+
}
|
34 |
+
|
35 |
+
public static function default_api_client_id() {
|
36 |
+
$client_id = getenv('UB_API_CLIENT_ID');
|
37 |
+
return $client_id ? $client_id : '660a311881321b9d4e777993e50875dec5da9cc4ef44369d121544b21da52b92';
|
38 |
+
}
|
39 |
+
|
40 |
+
public static function default_authorized_domains() {
|
41 |
+
$domains = getenv('UB_AUTHORIZED_DOMAINS');
|
42 |
+
return $domains ? explode(',', $domains) : array();
|
43 |
+
}
|
44 |
+
|
45 |
+
public static function page_server_domain() {
|
46 |
+
return get_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY, UBConfig::default_page_server_domain());
|
47 |
+
}
|
48 |
+
|
49 |
+
public static function remote_log_url() {
|
50 |
+
return get_option(UBConfig::UB_REMOTE_LOG_URL_KEY, UBConfig::default_remote_log_url());
|
51 |
+
}
|
52 |
+
|
53 |
+
public static function api_url() {
|
54 |
+
return get_option(UBConfig::UB_API_URL_KEY, UBConfig::default_api_url());
|
55 |
+
}
|
56 |
+
|
57 |
+
public static function api_client_id() {
|
58 |
+
return get_option(UBConfig::UB_API_CLIENT_ID_KEY, UBConfig::default_api_client_id());
|
59 |
+
}
|
60 |
+
|
61 |
+
public static function authorized_domains() {
|
62 |
+
return get_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY, UBConfig::default_authorized_domains());
|
63 |
+
}
|
64 |
+
|
65 |
public static function debug_loggging_enabled() {
|
66 |
return WP_DEBUG || WP_DEBUG_LOG || UBConfig::remote_debug_logging_enabled();
|
67 |
}
|
70 |
return get_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0) == 1;
|
71 |
}
|
72 |
|
73 |
+
public static function fetch_proxyable_url_set($domain, $etag, $ps_domain) {
|
74 |
if(!$domain) {
|
75 |
UBLogger::warning('Domain not provided, not fetching sitemap.xml');
|
76 |
return array('FAILURE', null, null, null);
|
77 |
}
|
78 |
|
79 |
+
$url = 'https://' . $ps_domain . '/sitemap.xml';
|
80 |
$curl = curl_init();
|
81 |
$curl_options = array(
|
82 |
CURLOPT_URL => $url,
|
179 |
}
|
180 |
}
|
181 |
|
182 |
+
public static function _read_unbounce_domain_info($options_getter,
|
183 |
+
$options_setter,
|
184 |
$fetch_proxyable_url_set,
|
185 |
$domain,
|
186 |
$expire_now=false) {
|
189 |
|
190 |
$cache_max_time_default = 10;
|
191 |
|
192 |
+
$ps_domain = $options_getter(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY);
|
193 |
+
$domains_info = $options_getter(UBConfig::UB_ROUTES_CACHE_KEY);
|
194 |
$domain_info = UBUtil::array_fetch($domains_info, $domain, array());
|
195 |
|
196 |
$proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set');
|
206 |
is_null($proxyable_url_set) ||
|
207 |
($current_time - $proxyable_url_set_fetched_at > $cache_max_time)) {
|
208 |
|
209 |
+
$result_array = call_user_func($fetch_proxyable_url_set,
|
210 |
+
$domain,
|
211 |
+
$proxyable_url_set_etag,
|
212 |
+
$ps_domain);
|
213 |
|
214 |
list($routes_status, $etag, $max_age, $proxyable_url_set_new) = $result_array;
|
215 |
|
235 |
|
236 |
$domain_info['proxyable_url_set_fetched_at'] = $current_time;
|
237 |
$domains_info[$domain] = $domain_info;
|
238 |
+
$options_setter(UBConfig::UB_ROUTES_CACHE_KEY, $domains_info);
|
239 |
}
|
240 |
|
241 |
|
253 |
$expire_now);
|
254 |
}
|
255 |
|
256 |
+
public static function is_authorized_domain($domain0) {
|
257 |
+
$pieces = explode(':', $domain0);
|
258 |
+
$domain = $pieces[0];
|
259 |
+
return in_array($domain, UBConfig::authorized_domains());
|
260 |
+
}
|
261 |
+
|
262 |
}
|
263 |
?>
|
UBHTTP.php
CHANGED
@@ -205,7 +205,9 @@ class UBHTTP {
|
|
205 |
UBLogger::debug_var('get_url_purpose $path', $path);
|
206 |
UBLogger::debug_var('get_url_purpose $url_without_protocol', $url_without_protocol);
|
207 |
|
208 |
-
if ($http_method ==
|
|
|
|
|
209 |
preg_match("/^\/(fsn|fsg|fs)\/?$/", $path)) {
|
210 |
|
211 |
return "SubmitLead";
|
205 |
UBLogger::debug_var('get_url_purpose $path', $path);
|
206 |
UBLogger::debug_var('get_url_purpose $url_without_protocol', $url_without_protocol);
|
207 |
|
208 |
+
if ($http_method == 'GET' && $path == '/_ubhc') {
|
209 |
+
return 'HealthCheck';
|
210 |
+
} elseif ($http_method == "POST" &&
|
211 |
preg_match("/^\/(fsn|fsg|fs)\/?$/", $path)) {
|
212 |
|
213 |
return "SubmitLead";
|
Unbounce-Page.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Unbounce
|
4 |
Plugin URI: http://unbounce.com
|
5 |
Description: Publish Unbounce Landing Pages to your Wordpress Domain.
|
6 |
-
Version: 0.1.
|
7 |
Author: Unbounce
|
8 |
Author URI: http://unbounce.com
|
9 |
License: GPLv2
|
@@ -19,24 +19,45 @@ require_once dirname(__FILE__) . '/UBIcon.php';
|
|
19 |
register_activation_hook(__FILE__, function() {
|
20 |
add_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
|
21 |
add_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
});
|
23 |
|
24 |
register_deactivation_hook(__FILE__, function() {
|
25 |
delete_option(UBConfig::UB_ROUTES_CACHE_KEY);
|
26 |
delete_option(UBConfig::UB_REMOTE_DEBUG_KEY);
|
|
|
|
|
|
|
|
|
|
|
27 |
});
|
28 |
|
29 |
add_action('init', function() {
|
30 |
UBLogger::setup_logger();
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
$start = microtime(true);
|
33 |
|
34 |
-
$ps_domain = UBConfig::
|
35 |
$http_method = UBUtil::array_fetch($_SERVER, 'REQUEST_METHOD');
|
36 |
$referer = UBUtil::array_fetch($_SERVER, 'HTTP_REFERER');
|
37 |
$user_agent = UBUtil::array_fetch($_SERVER, 'HTTP_USER_AGENT');
|
38 |
$protocol = UBHTTP::determine_protocol($_SERVER, is_ssl());
|
39 |
-
$domain = UBUtil::array_fetch($_SERVER, 'HTTP_HOST');
|
40 |
$current_path = UBUtil::array_fetch($_SERVER, 'REQUEST_URI');
|
41 |
|
42 |
$raw_url = $protocol . $ps_domain . $current_path;
|
@@ -67,7 +88,26 @@ add_action('init', function() {
|
|
67 |
if ($url_purpose == null) {
|
68 |
UBLogger::debug("ignoring request to URL " . $current_url);
|
69 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
UBLogger::debug("perform ''" . $url_purpose . "'' on received URL " . $current_url);
|
72 |
|
73 |
$cookies_to_forward = UBUtil::array_select_by_key($_COOKIE,
|
@@ -98,36 +138,73 @@ add_action('init', function() {
|
|
98 |
}
|
99 |
});
|
100 |
|
101 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
echo '<h1>Unbounce Pages</h1>';
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
107 |
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
110 |
|
111 |
-
|
112 |
-
|
|
|
|
|
113 |
|
114 |
-
|
115 |
-
echo '<ul>' . join($list_items, "\n") . '</ul>';
|
116 |
-
echo '<p>Last refresh date: <span id="last-cache-fetch" style="font-weight: bold;">' . date('r', $proxyable_url_set_fetched_at) . '</span></p>';
|
117 |
-
echo '</div>';
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
-
$
|
122 |
-
echo "<
|
123 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
add_action('admin_menu', function() {
|
127 |
$print_admin_panel = function() {
|
128 |
$domain = UBUtil::array_fetch($_SERVER, 'HTTP_HOST');
|
129 |
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
130 |
-
|
|
|
131 |
};
|
132 |
|
133 |
add_menu_page('Unbounce Pages',
|
@@ -138,6 +215,22 @@ add_action('admin_menu', function() {
|
|
138 |
UBIcon::base64_encoded_svg());
|
139 |
});
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
add_action('admin_post_flush_unbounce_pages', function() {
|
142 |
$domain = UBUtil::array_fetch($_SERVER, 'HTTP_HOST');
|
143 |
// Expire cache and redirect
|
@@ -148,7 +241,7 @@ add_action('admin_post_flush_unbounce_pages', function() {
|
|
148 |
});
|
149 |
|
150 |
add_action('shutdown', function() {
|
151 |
-
UBLogger::upload_logs_to_unbounce(UBConfig::
|
152 |
});
|
153 |
|
154 |
?>
|
3 |
Plugin Name: Unbounce
|
4 |
Plugin URI: http://unbounce.com
|
5 |
Description: Publish Unbounce Landing Pages to your Wordpress Domain.
|
6 |
+
Version: 0.1.20
|
7 |
Author: Unbounce
|
8 |
Author URI: http://unbounce.com
|
9 |
License: GPLv2
|
19 |
register_activation_hook(__FILE__, function() {
|
20 |
add_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
|
21 |
add_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0);
|
22 |
+
add_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY,
|
23 |
+
UBConfig::default_page_server_domain());
|
24 |
+
add_option(UBConfig::UB_REMOTE_LOG_URL_KEY,
|
25 |
+
UBConfig::default_remote_log_url());
|
26 |
+
add_option(UBConfig::UB_API_URL_KEY,
|
27 |
+
UBConfig::default_api_url());
|
28 |
+
add_option(UBConfig::UB_API_CLIENT_ID_KEY,
|
29 |
+
UBConfig::default_api_client_id());
|
30 |
+
add_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY,
|
31 |
+
UBConfig::default_authorized_domains());
|
32 |
});
|
33 |
|
34 |
register_deactivation_hook(__FILE__, function() {
|
35 |
delete_option(UBConfig::UB_ROUTES_CACHE_KEY);
|
36 |
delete_option(UBConfig::UB_REMOTE_DEBUG_KEY);
|
37 |
+
delete_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY);
|
38 |
+
delete_option(UBConfig::UB_REMOTE_LOG_URL_KEY);
|
39 |
+
delete_option(UBConfig::UB_API_URL_KEY);
|
40 |
+
delete_option(UBConfig::UB_API_CLIENT_ID_KEY);
|
41 |
+
delete_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY);
|
42 |
});
|
43 |
|
44 |
add_action('init', function() {
|
45 |
UBLogger::setup_logger();
|
46 |
|
47 |
+
$domain = UBUtil::array_fetch($_SERVER, 'HTTP_HOST');
|
48 |
+
|
49 |
+
if(!UBConfig::is_authorized_domain($domain)) {
|
50 |
+
UBLogger::info("Domain: $domain has not been authorized");
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
$start = microtime(true);
|
55 |
|
56 |
+
$ps_domain = UBConfig::page_server_domain();
|
57 |
$http_method = UBUtil::array_fetch($_SERVER, 'REQUEST_METHOD');
|
58 |
$referer = UBUtil::array_fetch($_SERVER, 'HTTP_REFERER');
|
59 |
$user_agent = UBUtil::array_fetch($_SERVER, 'HTTP_USER_AGENT');
|
60 |
$protocol = UBHTTP::determine_protocol($_SERVER, is_ssl());
|
|
|
61 |
$current_path = UBUtil::array_fetch($_SERVER, 'REQUEST_URI');
|
62 |
|
63 |
$raw_url = $protocol . $ps_domain . $current_path;
|
88 |
if ($url_purpose == null) {
|
89 |
UBLogger::debug("ignoring request to URL " . $current_url);
|
90 |
}
|
91 |
+
elseif ($url_purpose == 'HealthCheck') {
|
92 |
+
header('Content-Type: application/json');
|
93 |
+
$version = UBConfig::UB_VERSION;
|
94 |
+
echo "{\"ub_wordpress\":{\"version\":\"$version\"}}";
|
95 |
+
exit(0);
|
96 |
+
}
|
97 |
else {
|
98 |
+
// Disable caching plugins. This should take care of:
|
99 |
+
// - W3 Total Cache
|
100 |
+
// - WP Super Cache
|
101 |
+
// - ZenCache (Previously QuickCache)
|
102 |
+
if(!defined('DONOTCACHEPAGE')) {
|
103 |
+
define('DONOTCACHEPAGE', true);
|
104 |
+
}
|
105 |
+
|
106 |
+
// Disable CDN for W3 Total Cache
|
107 |
+
if(!defined('DONOTCDN')) {
|
108 |
+
define('DONOTCDN', true);
|
109 |
+
}
|
110 |
+
|
111 |
UBLogger::debug("perform ''" . $url_purpose . "'' on received URL " . $current_url);
|
112 |
|
113 |
$cookies_to_forward = UBUtil::array_select_by_key($_COOKIE,
|
138 |
}
|
139 |
});
|
140 |
|
141 |
+
add_action('admin_init', function() {
|
142 |
+
wp_enqueue_script('ub-rx',
|
143 |
+
plugins_url('js/rx.lite.compat.min.js', __FILE__));
|
144 |
+
wp_enqueue_script('set-unbounce-domains-js',
|
145 |
+
plugins_url('js/set-unbounce-domains.js', __FILE__),
|
146 |
+
array('jquery', 'ub-rx'));
|
147 |
+
});
|
148 |
+
|
149 |
+
function render_unbounce_pages($domain_info, $domain) {
|
150 |
echo '<h1>Unbounce Pages</h1>';
|
151 |
|
152 |
+
if(UBConfig::is_authorized_domain($domain)) {
|
153 |
+
$proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set');
|
154 |
+
if(empty($proxyable_url_set)) {
|
155 |
+
echo '<p class="warning">No URLs have been registered from Unbounce</p>';
|
156 |
|
157 |
+
} else {
|
158 |
+
$proxyable_url_set_fetched_at = UBUtil::array_fetch($domain_info, 'proxyable_url_set_fetched_at');
|
159 |
+
|
160 |
+
$list_items = array_map(function($url) { return '<li><a href="//'. $url .'">' . $url . '</a></li>'; },
|
161 |
+
$proxyable_url_set);
|
162 |
|
163 |
+
echo '<div class="unbounce-page-list">';
|
164 |
+
echo '<ul>' . join($list_items, "\n") . '</ul>';
|
165 |
+
echo '<p>Last refresh date: <span id="last-cache-fetch" style="font-weight: bold;">' . date('r', $proxyable_url_set_fetched_at) . '</span></p>';
|
166 |
+
echo '</div>';
|
167 |
|
168 |
+
}
|
|
|
|
|
|
|
169 |
|
170 |
+
$flush_pages_url = admin_url('admin-post.php');
|
171 |
+
echo "<form method='get' action='$flush_pages_url'>";
|
172 |
+
echo '<input type="hidden" name="action" value="flush_unbounce_pages" />';
|
173 |
+
echo get_submit_button('Refresh Cache', 'secondary', 'flush-unbounce-pages', true);
|
174 |
+
echo '</form>';
|
175 |
+
|
176 |
+
echo '<p><a href="https://app.unbounce.com">Go to Unbounce</a></p>';
|
177 |
+
} else {
|
178 |
+
echo '<div class="error">This domain has not been authorized with Unbounce.</div>';
|
179 |
}
|
180 |
|
181 |
+
$set_domains_url = admin_url('admin-post.php?action=set_unbounce_domains');
|
182 |
+
echo "<form method='post' action='$set_domains_url'>";
|
183 |
+
echo "<input type='hidden' name='domains' />";
|
184 |
+
echo get_submit_button('Authorize With Unbounce',
|
185 |
+
'primary',
|
186 |
+
'set-unbounce-domains',
|
187 |
+
true,
|
188 |
+
array('data-set-domains-url' => $set_domains_url,
|
189 |
+
'data-redirect-uri' => admin_url('admin.php?page=unbounce-pages'),
|
190 |
+
'data-api-url' => UBConfig::api_url(),
|
191 |
+
'data-api-client-id' => UBConfig::api_client_id()));
|
192 |
+
echo '</form>';
|
193 |
+
|
194 |
+
$authorization = UBUtil::array_fetch($_GET, 'authorization');
|
195 |
+
if($authorization === 'success') {
|
196 |
+
echo '<div class="updated">Successfully authorized with Unbounce.</div>';
|
197 |
+
} elseif($authorization === 'failure') {
|
198 |
+
echo '<div class="error">Sorry, there was an error authorizing with Unbounce. Please try again.</div>';
|
199 |
+
}
|
200 |
}
|
201 |
|
202 |
add_action('admin_menu', function() {
|
203 |
$print_admin_panel = function() {
|
204 |
$domain = UBUtil::array_fetch($_SERVER, 'HTTP_HOST');
|
205 |
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
206 |
+
|
207 |
+
render_unbounce_pages($domain_info, $domain);
|
208 |
};
|
209 |
|
210 |
add_menu_page('Unbounce Pages',
|
215 |
UBIcon::base64_encoded_svg());
|
216 |
});
|
217 |
|
218 |
+
add_action('admin_post_set_unbounce_domains', function() {
|
219 |
+
$domains_json = UBUtil::array_fetch($_POST, 'domains', '');
|
220 |
+
$domains = explode(',', $domains_json);
|
221 |
+
|
222 |
+
if($domains_json && is_array($domains)) {
|
223 |
+
update_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY, $domains);
|
224 |
+
$authorization = 'success';
|
225 |
+
} else {
|
226 |
+
$authorization = 'failure';
|
227 |
+
}
|
228 |
+
|
229 |
+
status_header(301);
|
230 |
+
$location = admin_url("admin.php?page=unbounce-pages&authorization=$authorization");
|
231 |
+
header("Location: $location");
|
232 |
+
});
|
233 |
+
|
234 |
add_action('admin_post_flush_unbounce_pages', function() {
|
235 |
$domain = UBUtil::array_fetch($_SERVER, 'HTTP_HOST');
|
236 |
// Expire cache and redirect
|
241 |
});
|
242 |
|
243 |
add_action('shutdown', function() {
|
244 |
+
UBLogger::upload_logs_to_unbounce(get_option(UBConfig::UB_REMOTE_LOG_URL_KEY));
|
245 |
});
|
246 |
|
247 |
?>
|
js/rx.lite.compat.min.js
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
2 |
+
(function(a){function b(a){for(var b=a.length,c=new Array(b),d=0;b>d;d++)c[d]=a[d];return c}function c(a,b){if(ma&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(qa)){for(var c=[],e=b;e;e=e.source)e.stack&&c.unshift(e.stack);c.unshift(a.stack);var f=c.join("\n"+qa+"\n");a.stack=d(f)}}function d(a){for(var b=a.split("\n"),c=[],d=0,g=b.length;g>d;d++){var h=b[d];e(h)||f(h)||!h||c.push(h)}return c.join("\n")}function e(a){var b=h(a);if(!b)return!1;var c=b[0],d=b[1];return c===oa&&d>=pa&&Vc>=d}function f(a){return-1!==a.indexOf("(module.js:")||-1!==a.indexOf("(node.js:")}function g(){if(ma)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=h(c);if(!d)return;return oa=d[0],d[1]}}function h(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function i(a){var b=[];if(!Za(a))return b;Ya.nonEnumArgs&&a.length&&$a(a)&&(a=cb.call(a));var c=Ya.enumPrototypes&&"function"==typeof a,d=Ya.enumErrorProps&&(a===Ta||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(Ya.nonEnumShadows&&a!==Ua){var f=a.constructor,g=-1,h=Fa;if(a===(f&&f.prototype))var i=a===Va?Pa:a===Ta?Ka:Qa.call(a),j=Xa[i];for(;++g<h;)e=Ea[g],j&&j[e]||!Ra.call(a,e)||b.push(e)}return b}function j(a,b,c){for(var d=-1,e=c(a),f=e.length;++d<f;){var g=e[d];if(b(a[g],g,a)===!1)break}return a}function k(a,b){return j(a,b,i)}function l(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function m(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;var e=typeof a,f=typeof b;if(a===a&&(null==a||null==b||"function"!=e&&"object"!=e&&"function"!=f&&"object"!=f))return!1;var g=Qa.call(a),h=Qa.call(b);if(g==Ga&&(g=Na),h==Ga&&(h=Na),g!=h)return!1;switch(g){case Ia:case Ja:return+a==+b;case Ma:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case Oa:case Pa:return a==String(b)}var i=g==Ha;if(!i){if(g!=Na||!Ya.nodeClass&&(l(a)||l(b)))return!1;var j=!Ya.argsObject&&$a(a)?Object:a.constructor,n=!Ya.argsObject&&$a(b)?Object:b.constructor;if(!(j==n||Ra.call(a,"constructor")&&Ra.call(b,"constructor")||la(j)&&j instanceof j&&la(n)&&n instanceof n||!("constructor"in a&&"constructor"in b)))return!1}c||(c=[]),d||(d=[]);for(var o=c.length;o--;)if(c[o]==a)return d[o]==b;var p=0,q=!0;if(c.push(a),d.push(b),i){if(o=a.length,p=b.length,q=p==o)for(;p--;){var r=b[p];if(!(q=m(a[p],r,c,d)))break}}else k(b,function(b,e,f){return Ra.call(f,e)?(p++,q=Ra.call(a,e)&&m(a[e],b,c,d)):void 0}),q&&k(a,function(a,b,c){return Ra.call(c,b)?q=--p>-1:void 0});return c.pop(),d.pop(),q}function n(){try{return _a.apply(this,arguments)}catch(a){return bb.e=a,bb}}function o(a){if(!la(a))throw new TypeError("fn must be a function");return _a=a,n}function p(a){throw a}function q(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function r(a,b){this.id=a,this.value=b}function t(a){this._s=s}function u(a){this._s=s,this._l=s.length,this._i=0}function v(a){this._a=a}function w(a){this._a=a,this._l=A(a),this._i=0}function x(a){return"number"==typeof a&&$.isFinite(a)}function y(b){var c,d=b[ya];if(!d&&"string"==typeof b)return c=new t(b),c[ya]();if(!d&&b.length!==a)return c=new v(b),c[ya]();if(!d)throw new TypeError("Object is not iterable");return b[ya]()}function z(a){var b=+a;return 0===b?b:isNaN(b)?b:0>b?-1:1}function A(a){var b=+a.length;return isNaN(b)?0:0!==b&&x(b)?(b=z(b)*Math.floor(Math.abs(b)),0>=b?0:b>bc?bc:b):b}function B(a,b){this.observer=a,this.parent=b}function C(a,b){return vb(a)||(a=zb),new dc(b,a)}function D(a,b){this.observer=a,this.parent=b}function E(a,b){this.observer=a,this.parent=b}function F(a,b){return new Nc(function(c){var d=new qb,e=new rb;return e.setDisposable(d),d.setDisposable(a.subscribe(function(a){c.onNext(a)},function(a){try{var d=b(a)}catch(f){return c.onError(f)}ka(d)&&(d=Gc(d));var g=new qb;e.setDisposable(g),g.setDisposable(d.subscribe(c))},function(a){c.onCompleted(a)})),e},a)}function G(){return!1}function H(a,b){var c=this;return new Nc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g=a[e++],h=o(b)(c,g);if(h===bb)return d.onError(h.e);d.onNext(h)}else d.onCompleted()},function(a){d.onError(a)},function(){d.onCompleted()})},c)}function G(){return!1}function I(){return[]}function G(){return!1}function J(){return[]}function K(a,b){this.observer=a,this.accumulator=b.accumulator,this.hasSeed=b.hasSeed,this.seed=b.seed,this.hasAccumulation=!1,this.accumulation=null,this.hasValue=!1,this.isStopped=!1}function L(a,b,c){var d=Da(b,c,3);return a.map(function(b,c){var e=d(b,c,a);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e}).concatAll()}function M(a,b,c){var d=Da(b,c,3);return a.map(function(b,c){var e=d(b,c,a);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e}).mergeAll()}function N(a){return window.StaticNodeList?a instanceof window.StaticNodeList||a instanceof window.NodeList:"[object NodeList]"==Object.prototype.toString.call(a)}function O(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=$.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function P(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),mb(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(O(a))};return a.attachEvent("on"+b,d),mb(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,mb(function(){a["on"+b]=null})}function Q(a,b,c){var d=new jb;if(N(a)||"[object HTMLCollection]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(Q(a.item(e),b,c));else a&&d.add(P(a,b,c));return d}function R(a,b){return new Nc(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function S(a,b,c){return new Nc(function(d){var e=a,f=ub(b);return c.scheduleRecursiveWithAbsoluteAndState(0,e,function(a,b){if(f>0){var g=c.now();e+=f,g>=e&&(e=g+f)}d.onNext(a),b(a+1,e)})})}function T(a,b){return new Nc(function(c){return b.scheduleWithRelative(ub(a),function(){c.onNext(0),c.onCompleted()})})}function U(a,b,c){return a===b?new Nc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Yb(function(){return S(c.now()+a,b,c)})}function V(a,b,c){return new Nc(function(d){var e,f=!1,g=new rb,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.exception,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new qb,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveWithRelative(b,function(a){var b,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-c.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-c.now())):f=!1,b=h,j=!1,null!==b?d.onError(b):k&&a(e)}}))))}),new jb(e,g)},a)}function W(a,b,c){return Yb(function(){return V(a,b-c.now(),c)})}function X(a,b){return new Nc(function(c){function d(){g&&(g=!1,c.onNext(e)),f&&c.onCompleted()}var e,f=!1,g=!1,h=new qb;return h.setDisposable(a.subscribe(function(a){g=!0,e=a},function(a){c.onError(a)},function(){f=!0,h.dispose()})),new jb(h,b.subscribe(d,function(a){c.onError(a)},d))},a)}function Y(a,b,c){return new Nc(function(d){function e(a,b){if(j[b]=a,g[b]=!0,h||(h=g.every(fa))){if(f)return d.onError(f);var e=o(c).apply(null,j);if(e===bb)return d.onError(e.e);d.onNext(e)}i&&j[1]&&d.onCompleted()}var f,g=[!1,!1],h=!1,i=!1,j=new Array(2);return new jb(a.subscribe(function(a){e(a,0)},function(a){j[1]?d.onError(a):f=a},function(){i=!0,j[1]&&d.onCompleted()}),b.subscribe(function(a){e(a,1)},function(a){d.onError(a)},function(){i=!0,e(!0,1)}))},a)}var Z={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$=Z[typeof window]&&window||this,_=Z[typeof exports]&&exports&&!exports.nodeType&&exports,aa=Z[typeof module]&&module&&!module.nodeType&&module,ba=aa&&aa.exports===_&&_,ca=Z[typeof global]&&global;!ca||ca.global!==ca&&ca.window!==ca||($=ca);var da={internals:{},config:{Promise:$.Promise},helpers:{}},ea=da.helpers.noop=function(){},fa=(da.helpers.notDefined=function(a){return"undefined"==typeof a},da.helpers.identity=function(a){return a}),ga=(da.helpers.pluck=function(a){return function(b){return b[a]}},da.helpers.just=function(a){return function(){return a}},da.helpers.defaultNow=function(){return Date.now?Date.now:function(){return+new Date}}()),ha=da.helpers.defaultComparer=function(a,b){return ab(a,b)},ia=da.helpers.defaultSubComparer=function(a,b){return a>b?1:b>a?-1:0},ja=(da.helpers.defaultKeySerializer=function(a){return a.toString()},da.helpers.defaultError=function(a){throw a}),ka=da.helpers.isPromise=function(a){return!!a&&"function"!=typeof a.subscribe&&"function"==typeof a.then},la=(da.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},da.helpers.not=function(a){return!a},da.helpers.isFunction=function(){var a=function(a){return"function"==typeof a||!1};return a(/x/)&&(a=function(a){return"function"==typeof a&&"[object Function]"==Qa.call(a)}),a}());da.config.longStackSupport=!1;var ma=!1;try{throw new Error}catch(na){ma=!!na.stack}var oa,pa=g(),qa="From previous event:",ra=da.EmptyError=function(){this.message="Sequence contains no elements.",Error.call(this)};ra.prototype=Error.prototype;var sa=da.ObjectDisposedError=function(){this.message="Object has been disposed",Error.call(this)};sa.prototype=Error.prototype;var ta=da.ArgumentOutOfRangeError=function(){this.message="Argument out of range",Error.call(this)};ta.prototype=Error.prototype;var ua=da.NotSupportedError=function(a){this.message=a||"This operation is not supported",Error.call(this)};ua.prototype=Error.prototype;var va=da.NotImplementedError=function(a){this.message=a||"This operation is not implemented",Error.call(this)};va.prototype=Error.prototype;var wa=da.helpers.notImplemented=function(){throw new va},xa=da.helpers.notSupported=function(){throw new ua},ya="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";$.Set&&"function"==typeof(new $.Set)["@@iterator"]&&(ya="@@iterator");var za=da.doneEnumerator={done:!0,value:a},Aa=da.helpers.isIterable=function(b){return b[ya]!==a},Ba=da.helpers.isArrayLike=function(b){return b&&b.length!==a};da.helpers.iterator=ya;var Ca,Da=da.internals.bindCallback=function(a,b,c){if("undefined"==typeof b)return a;switch(c){case 0:return function(){return a.call(b)};case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)}}return function(){return a.apply(b,arguments)}},Ea=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Fa=Ea.length,Ga="[object Arguments]",Ha="[object Array]",Ia="[object Boolean]",Ja="[object Date]",Ka="[object Error]",La="[object Function]",Ma="[object Number]",Na="[object Object]",Oa="[object RegExp]",Pa="[object String]",Qa=Object.prototype.toString,Ra=Object.prototype.hasOwnProperty,Sa=Qa.call(arguments)==Ga,Ta=Error.prototype,Ua=Object.prototype,Va=String.prototype,Wa=Ua.propertyIsEnumerable;try{Ca=!(Qa.call(document)==Na&&!({toString:0}+""))}catch(na){Ca=!0}var Xa={};Xa[Ha]=Xa[Ja]=Xa[Ma]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Xa[Ia]=Xa[Pa]={constructor:!0,toString:!0,valueOf:!0},Xa[Ka]=Xa[La]=Xa[Oa]={constructor:!0,toString:!0},Xa[Na]={constructor:!0};var Ya={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);Ya.enumErrorProps=Wa.call(Ta,"message")||Wa.call(Ta,"name"),Ya.enumPrototypes=Wa.call(a,"prototype"),Ya.nonEnumArgs=0!=c,Ya.nonEnumShadows=!/valueOf/.test(b)}(1);var Za=da.internals.isObject=function(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1},$a=function(a){return a&&"object"==typeof a?Qa.call(a)==Ga:!1};Sa||($a=function(a){return a&&"object"==typeof a?Ra.call(a,"callee"):!1});{var _a,ab=da.internals.isEqual=function(a,b){return m(a,b,[],[])},bb={e:{}},cb=({}.hasOwnProperty,Array.prototype.slice),db=this.inherits=da.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c},eb=da.internals.addProperties=function(a){for(var b=[],c=1,d=arguments.length;d>c;c++)b.push(arguments[c]);for(var e=0,f=b.length;f>e;e++){var g=b[e];for(var h in g)a[h]=g[h]}};da.internals.addRef=function(a,b){return new Nc(function(c){return new jb(b.getDisposable(),a.subscribe(c))})}}Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=cb.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(cb.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(cb.call(arguments)))};return d}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;f>d;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}});var fb=Object("a"),gb="a"!=fb[0]||!(0 in fb);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=gb&&{}.toString.call(this)==Pa?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=La)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=gb&&{}.toString.call(this)==Pa?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=La)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return{}.toString.call(a)==Ha}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!=1/0&&d!==-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Object.prototype.propertyIsEnumerable||(Object.prototype.propertyIsEnumerable=function(a){for(var b in this)if(b===a)return!0;return!1}),Object.keys||(Object.keys=function(){"use strict";var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString");return function(c){if("object"!=typeof c&&("function"!=typeof c||null===c))throw new TypeError("Object.keys called on non-object");var d,e,f=[];for(d in c)a.call(c,d)&&f.push(d);if(b)for(e=0;Fa>e;e++)a.call(c,Ea[e])&&f.push(Ea[e]);return f}}()),r.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var hb=da.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},ib=hb.prototype;ib.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},ib.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},ib.heapify=function(a){if(+a||(a=0),!(a>=this.length||0>a)){var b=2*a+1,c=2*a+2,d=a;if(b<this.length&&this.isHigherPriority(b,d)&&(d=b),c<this.length&&this.isHigherPriority(c,d)&&(d=c),d!==a){var e=this.items[a];this.items[a]=this.items[d],this.items[d]=e,this.heapify(d)}}},ib.peek=function(){return this.items[0].value},ib.removeAt=function(b){this.items[b]=this.items[--this.length],this.items[this.length]=a,this.heapify()},ib.dequeue=function(){var a=this.peek();return this.removeAt(0),a},ib.enqueue=function(a){var b=this.length++;this.items[b]=new r(hb.count++,a),this.percolate(b)},ib.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},hb.count=0;var jb=da.CompositeDisposable=function(){var a,b,c=[];if(Array.isArray(arguments[0]))c=arguments[0],b=c.length;else for(b=arguments.length,c=new Array(b),a=0;b>a;a++)c[a]=arguments[a];for(a=0;b>a;a++)if(!ob(c[a]))throw new TypeError("Not a disposable");this.disposables=c,this.isDisposed=!1,this.length=c.length},kb=jb.prototype;kb.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},kb.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},kb.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=this.disposables.length,b=new Array(a),c=0;a>c;c++)b[c]=this.disposables[c];for(this.disposables=[],this.length=0,c=0;a>c;c++)b[c].dispose()}};var lb=da.Disposable=function(a){this.isDisposed=!1,this.action=a||ea};lb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var mb=lb.create=function(a){return new lb(a)},nb=lb.empty={dispose:ea},ob=lb.isDisposable=function(a){return a&&la(a.dispose)},pb=lb.checkDisposed=function(a){if(a.isDisposed)throw new sa},qb=da.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null};qb.prototype.getDisposable=function(){return this.current},qb.prototype.setDisposable=function(a){if(this.current)throw new Error("Disposable has already been assigned");var b=this.isDisposed;!b&&(this.current=a),b&&a&&a.dispose()},qb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()};var rb=da.SerialDisposable=function(){this.isDisposed=!1,this.current=null};rb.prototype.getDisposable=function(){return this.current},rb.prototype.setDisposable=function(a){var b=this.isDisposed;if(!b){var c=this.current;this.current=a}c&&c.dispose(),b&&a&&a.dispose()},rb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()};var sb=(da.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?nb:new a(this)},b}(),da.internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||ia,this.disposable=new qb});sb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},sb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},sb.prototype.isCancelled=function(){return this.disposable.isDisposed},sb.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var tb=da.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){return b(),nb}a.isScheduler=function(b){return b instanceof a};var c=a.prototype;return c.schedule=function(a){return this._schedule(a,b)},c.scheduleWithState=function(a,b){return this._schedule(a,b)},c.scheduleWithRelative=function(a,c){return this._scheduleRelative(c,a,b)},c.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},c.scheduleWithAbsolute=function(a,c){return this._scheduleAbsolute(c,a,b)},c.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},a.now=ga,a.normalize=function(a){return 0>a&&(a=0),a},a}(),ub=tb.normalize,vb=tb.isScheduler;!function(a){function b(a,b){function c(b){e(b,function(b){var d=!1,e=!1,g=a.scheduleWithState(b,function(a,b){return d?f.remove(g):e=!0,c(b),nb});e||(f.add(g),d=!0)})}var d=b[0],e=b[1],f=new jb;return c(d),f}function c(a,b,c){function d(b){f(b,function(b,e){var f=!1,h=!1,i=a[c](b,e,function(a,b){return f?g.remove(i):h=!0,d(b),nb});h||(g.add(i),f=!0)})}var e=b[0],f=b[1],g=new jb;return d(e),g}function d(a,b){a(function(c){b(a,c)})}a.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,d)},a.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState([a,c],b)},a.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,d)},a.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative([a,d],b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},a.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,d)},a.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute([a,d],b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})}}(tb.prototype),function(a){tb.prototype.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,b)},tb.prototype.schedulePeriodicWithState=function(a,b,c){if("undefined"==typeof $.setInterval)throw new ua;b=ub(b);var d=a,e=$.setInterval(function(){d=c(d)},b);return mb(function(){$.clearInterval(e)})}}(tb.prototype);var wb,xb,yb=tb.immediate=function(){function a(a,b){return b(this,a)}return new tb(ga,a,xa,xa)}(),zb=tb.currentThread=function(){function a(){for(;c.length>0;){var a=c.dequeue();!a.isCancelled()&&a.invoke()}}function b(b,d){var e=new sb(this,b,d,this.now());if(c)c.enqueue(e);else{c=new hb(4),c.enqueue(e);var f=o(a)();if(c=null,f===bb)return p(f.e)}return e.disposable}var c,d=new tb(ga,b,xa,xa);return d.scheduleRequired=function(){return!c},d}(),Ab=(da.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new qb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),function(){var a,b=ea;if($.setTimeout)a=$.setTimeout,b=$.clearTimeout;else{if(!$.WScript)throw new ua;a=function(a,b){$.WScript.Sleep(b),a()}}return{setTimeout:a,clearTimeout:b}}()),Bb=Ab.setTimeout,Cb=Ab.clearTimeout;!function(){function a(b){if(f)Bb(function(){a(b)},0);else{var c=e[b];if(c){f=!0;var d=o(c)();if(xb(b),f=!1,d===bb)return p(d.e)}}}function b(){if(!$.postMessage||$.importScripts)return!1;var a=!1,b=$.onmessage;return $.onmessage=function(){a=!0},$.postMessage("","*"),$.onmessage=b,a}function c(b){"string"==typeof b.data&&b.data.substring(0,i.length)===i&&a(b.data.substring(i.length))}var d=1,e={},f=!1;xb=function(a){delete e[a]};var g=RegExp("^"+String(Qa).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),h="function"==typeof(h=ca&&ba&&ca.setImmediate)&&!g.test(h)&&h;if(la(h))wb=function(b){var c=d++;return e[c]=b,h(function(){a(c)}),c};else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))wb=function(b){var c=d++;return e[c]=b,process.nextTick(function(){a(c)}),c};else if(b()){var i="ms.rx.schedule"+Math.random();$.addEventListener?$.addEventListener("message",c,!1):$.attachEvent?$.attachEvent("onmessage",c):$.onmessage=c,wb=function(a){var b=d++;return e[b]=a,$.postMessage(i+currentId,"*"),b}}else if($.MessageChannel){var j=new $.MessageChannel;j.port1.onmessage=function(b){a(b.data)},wb=function(a){var b=d++;return e[b]=a,j.port2.postMessage(b),b}}else wb="document"in $&&"onreadystatechange"in $.document.createElement("script")?function(b){var c=$.document.createElement("script"),f=d++;return e[f]=b,c.onreadystatechange=function(){a(f),c.onreadystatechange=null,c.parentNode.removeChild(c),c=null},$.document.documentElement.appendChild(c),f}:function(b){var c=d++;return e[c]=b,Bb(function(){a(c)},0),c}}();var Db,Eb=tb.timeout=tb["default"]=function(){function a(a,b){var c=this,d=new qb,e=wb(function(){!d.isDisposed&&d.setDisposable(b(c,a))});return new jb(d,mb(function(){xb(e)}))}function b(a,b,c){var d=this,e=tb.normalize(b),f=new qb;if(0===e)return d.scheduleWithState(a,c);var g=Bb(function(){!f.isDisposed&&f.setDisposable(c(d,a))},e);return new jb(f,mb(function(){Cb(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new tb(ga,a,b,c)}(),Fb=da.Notification=function(){function a(a,b,c,d,e,f){this.kind=a,this.value=b,this.exception=c,this._accept=d,this._acceptObservable=e,this.toString=f}return a.prototype.accept=function(a,b,c){return a&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},a.prototype.toObservable=function(a){var b=this;return vb(a)||(a=yb),new Nc(function(c){return a.scheduleWithState(b,function(a,b){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),Gb=Fb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){return new Fb("N",d,null,a,b,c)}}(),Hb=Fb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){return new Fb("E",null,d,a,b,c)}}(),Ib=Fb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){return new Fb("C",null,null,a,b,c)}}(),Jb=da.Observer=function(){},Kb=Jb.create=function(a,b,c){return a||(a=ea),b||(b=ja),c||(c=ea),new Mb(a,b,c)},Lb=da.internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}return db(b,a),b.prototype.next=wa,b.prototype.error=wa,b.prototype.completed=wa,b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(Jb),Mb=da.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return db(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(Lb),Nb=da.Observable=function(){function a(a){if(da.config.longStackSupport&&ma){try{throw new Error}catch(b){this.stack=b.stack.substring(b.stack.indexOf("\n")+1)}var d=this;this._subscribe=function(b){var e=b.onError.bind(b);return b.onError=function(a){c(a,d),e(a)},a.call(d,b)}}else this._subscribe=a}return Db=a.prototype,Db.subscribe=Db.forEach=function(a,b,c){return this._subscribe("object"==typeof a?a:Kb(a,b,c))},Db.subscribeOnNext=function(a,b){return this._subscribe(Kb("undefined"!=typeof b?function(c){a.call(b,c)}:a))},Db.subscribeOnError=function(a,b){return this._subscribe(Kb(null,"undefined"!=typeof b?function(c){a.call(b,c)}:a))},Db.subscribeOnCompleted=function(a,b){return this._subscribe(Kb(null,null,"undefined"!=typeof b?function(){a.call(b)}:a))},a}(),Ob=da.ObservableBase=function(a){function b(a){return a&&la(a.dispose)?a:la(a)?mb(a):nb}function c(a,c){var d=c[0],e=c[1],f=o(e.subscribeCore).call(e,d);return f!==bb||d.fail(bb.e)?void d.setDisposable(b(f)):p(bb.e)}function d(a){var b=new Oc(a),d=[b,this];return zb.scheduleRequired()?zb.scheduleWithState(d,c):c(null,d),b}function e(){a.call(this,d)}return db(e,a),e.prototype.subscribeCore=wa,e}(Nb),Pb=da.internals.Enumerable=function(){},Qb=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b,c){this.o=a,this.s=b,this.e=c,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){var b,d=new rb,e=yb.scheduleRecursiveWithState(this.sources[ya](),function(e,f){if(!b){var g=o(e.next).call(e);if(g===bb)return a.onError(g.e);if(g.done)return a.onCompleted();var h=g.value;ka(h)&&(h=Gc(h));var i=new qb;d.setDisposable(i),i.setDisposable(h.subscribe(new c(a,f,e)))}});return new jb(d,e,mb(function(){b=!0}))},c.prototype.onNext=function(a){this.isStopped||this.o.onNext(a)},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.s(this.e))},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Pb.prototype.concat=function(){return new Qb(this)};var Rb=function(a){function b(b){this.sources=b,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b,c=this.sources[ya](),d=new rb,e=yb.scheduleRecursiveWithState(null,function(e,f){if(!b){var g=o(c.next).call(c);if(g===bb)return a.onError(g.e);if(g.done)return null!==e?a.onError(e):a.onCompleted();var h=g.value;ka(h)&&(h=Gc(h));var i=new qb;d.setDisposable(i),i.setDisposable(h.subscribe(function(b){a.onNext(b)},f,function(){a.onCompleted()}))}});return new jb(d,e,mb(function(){b=!0}))},b}(Ob);Pb.prototype.catchError=function(){return new Rb(this)},Pb.prototype.catchErrorWhen=function(a){var b=this;return new Nc(function(c){var d,e,f=new Qc,g=new Qc,h=a(f),i=h.subscribe(g),j=b[ya](),k=new rb,l=yb.scheduleRecursive(function(a){if(!d){var b=o(j.next).call(j);if(b===bb)return c.onError(b.e);if(b.done)return void(e?c.onError(e):c.onCompleted());var h=b.value;ka(h)&&(h=Gc(h));var i=new qb,l=new qb;k.setDisposable(new jb(l,i)),i.setDisposable(h.subscribe(function(a){c.onNext(a)},function(b){l.setDisposable(g.subscribe(a,function(a){c.onError(a)},function(){c.onCompleted()})),f.onNext(b)},function(){c.onCompleted()}))}});return new jb(i,k,l,mb(function(){d=!0}))})};var Sb=function(a){function b(a,b){this.v=a,this.c=null==b?-1:b}function c(a){this.v=a.v,this.l=a.c}return db(b,a),b.prototype[ya]=function(){return new c(this)},c.prototype.next=function(){return 0===this.l?za:(this.l>0&&this.l--,{done:!1,value:this.v})},b}(Pb),Tb=Pb.repeat=function(a,b){return new Sb(a,b)},Ub=function(a){function b(a,b,c){this.s=a,this.fn=b?Da(b,c,3):null}function c(a){this.i=-1,this.s=a.s,this.l=this.s.length,this.fn=a.fn}return db(b,a),b.prototype[ya]=function(){return new c(this)},c.prototype.next=function(){return++this.i<this.l?{done:!1,value:this.fn?this.fn(this.s[this.i],this.i,this.s):this.s[this.i]}:za},b}(Pb),Vb=Pb.of=function(a,b,c){return new Ub(a,b,c)},Wb=da.internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new rb}return db(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){
|
3 |
+
var c;if(!(b.queue.length>0))return void(b.isAcquired=!1);c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Lb),Xb=function(a){function b(b){this.source=b,a.call(this)}function c(a){this.o=a,this.a=[],this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a))},c.prototype.onNext=function(a){this.isStopped||this.a.push(a)},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onNext(this.a),this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.toArray=function(){return new Xb(this)},Nb.create=Nb.createWithDisposable=function(a,b){return new Nc(a,b)};var Yb=Nb.defer=function(a){return new Nc(function(b){var c;try{c=a()}catch(d){return mc(d).subscribe(b)}return ka(c)&&(c=Gc(c)),c.subscribe(b)})},Zb=function(a){function b(b){this.scheduler=b,a.call(this)}function c(a,b){this.observer=a,this.parent=b}function d(a,b){b.onCompleted()}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(a,this);return b.run()},c.prototype.run=function(){return this.parent.scheduler.scheduleWithState(this.observer,d)},b}(Ob),$b=Nb.empty=function(a){return vb(a)||(a=yb),new Zb(a)},_b=function(a){function b(b,c,d){this.iterable=b,this.mapper=c,this.scheduler=d,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new ac(a,this);return b.run()},b}(Ob),ac=function(){function a(a,b){this.observer=a,this.parent=b}return a.prototype.run=function(){function a(a,b){try{var f=c.next()}catch(g){return d.onError(g)}if(f.done)return d.onCompleted();var h=f.value;if(e)try{h=e(h,a)}catch(g){return d.onError(g)}d.onNext(h),b(a+1)}var b=Object(this.parent.iterable),c=y(b),d=this.observer,e=this.parent.mapper;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},a}(),bc=Math.pow(2,53)-1;t.prototype[ya]=function(){return new u(this._s)},u.prototype[ya]=function(){return this},u.prototype.next=function(){return this._i<this._l?{done:!1,value:this._s.charAt(this._i++)}:za},v.prototype[ya]=function(){return new w(this._a)},w.prototype[ya]=function(){return this},w.prototype.next=function(){return this._i<this._l?{done:!1,value:this._a[this._i++]}:za};var cc=Nb.from=function(a,b,c,d){if(null==a)throw new Error("iterable cannot be null.");if(b&&!la(b))throw new Error("mapFn when provided must be a function");if(b)var e=Da(b,c,2);return vb(d)||(d=zb),new _b(a,e,d)},dc=function(a){function b(b,c){this.args=b,this.scheduler=c,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new B(a,this);return b.run()},b}(Ob);B.prototype.run=function(){function a(a,e){d>a?(b.onNext(c[a]),e(a+1)):b.onCompleted()}var b=this.observer,c=this.parent.args,d=c.length;return this.parent.scheduler.scheduleRecursiveWithState(0,a)};{var ec=Nb.fromArray=function(a,b){return vb(b)||(b=zb),new dc(a,b)},fc=function(a){function b(){a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){return nb},b}(Ob);Nb.never=function(){return new fc}}Nb.of=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return new dc(b,zb)},Nb.ofWithScheduler=function(a){for(var b=arguments.length,c=new Array(b-1),d=1;b>d;d++)c[d-1]=arguments[d];return new dc(c,a)};var gc=function(a){function b(b,c){this.obj=b,this.keys=Object.keys(b),this.scheduler=c,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new D(a,this);return b.run()},b}(Ob);D.prototype.run=function(){function a(a,f){if(e>a){var g=d[a];b.onNext([g,c[g]]),f(a+1)}else b.onCompleted()}var b=this.observer,c=this.parent.obj,d=this.parent.keys,e=d.length;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},Nb.pairs=function(a,b){return b||(b=zb),new gc(a,b)};var hc=function(a){function b(b,c,d){this.start=b,this.rangeCount=c,this.scheduler=d,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new ic(a,this);return b.run()},b}(Ob),ic=function(){function a(a,b){this.observer=a,this.parent=b}return a.prototype.run=function(){function a(a,e){c>a?(d.onNext(b+a),e(a+1)):d.onCompleted()}var b=this.parent.start,c=this.parent.rangeCount,d=this.observer;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},a}();Nb.range=function(a,b,c){return vb(c)||(c=zb),new hc(a,b,c)};var jc=function(a){function b(b,c,d){this.value=b,this.repeatCount=null==c?-1:c,this.scheduler=d,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new E(a,this);return b.run()},b}(Ob);E.prototype.run=function(){function a(a,d){return(-1===a||a>0)&&(b.onNext(c),a>0&&a--),0===a?b.onCompleted():void d(a)}var b=this.observer,c=this.parent.value;return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount,a)},Nb.repeat=function(a,b,c){return vb(c)||(c=zb),new jc(a,b,c)};var kc=function(a){function b(b,c){this.value=b,this.scheduler=c,a.call(this)}function c(a,b){this.observer=a,this.parent=b}function d(a,b){var c=b[0],d=b[1];d.onNext(c),d.onCompleted()}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(a,this);return b.run()},c.prototype.run=function(){return this.parent.scheduler.scheduleWithState([this.parent.value,this.observer],d)},b}(Ob),lc=(Nb["return"]=Nb.just=Nb.returnValue=function(a,b){return vb(b)||(b=yb),new kc(a,b)},function(a){function b(b,c){this.error=b,this.scheduler=c,a.call(this)}function c(a,b){this.o=a,this.p=b}function d(a,b){var c=b[0],d=b[1];d.onError(c)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(a,this);return b.run()},c.prototype.run=function(){return this.p.scheduler.scheduleWithState([this.p.error,this.o],d)},b}(Ob)),mc=Nb["throw"]=Nb.throwError=Nb.throwException=function(a,b){return vb(b)||(b=yb),new lc(a,b)};Db["catch"]=Db.catchError=Db.catchException=function(a){return"function"==typeof a?F(this,a):nc([this,a])};var nc=Nb.catchError=Nb["catch"]=Nb.catchException=function(){var a=[];if(Array.isArray(arguments[0]))a=arguments[0];else for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return Vb(a).catchError()};Db.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return Array.isArray(b[0])?b[0].unshift(this):b.unshift(this),oc.apply(this,b)};var oc=Nb.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.pop();return Array.isArray(b[0])&&(b=b[0]),new Nc(function(a){function c(b){if(h[b]=!0,i||(i=h.every(fa))){try{var c=d.apply(null,k)}catch(e){return a.onError(e)}a.onNext(c)}else j.filter(function(a,c){return c!==b}).every(fa)&&a.onCompleted()}function e(b){j[b]=!0,j.every(fa)&&a.onCompleted()}for(var f=b.length,g=function(){return!1},h=q(f,g),i=!1,j=q(f,g),k=new Array(f),l=new Array(f),m=0;f>m;m++)!function(d){var f=b[d],g=new qb;ka(f)&&(f=Gc(f)),g.setDisposable(f.subscribe(function(a){k[d]=a,c(d)},function(b){a.onError(b)},function(){e(d)})),l[d]=g}(m);return new jb(l)},this)};Db.concat=function(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return a.unshift(this),qc.apply(null,a)};var pc=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b){this.sources=a,this.o=b}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(this.sources,a);return b.run()},c.prototype.run=function(){var a,b=new rb,c=this.sources,d=c.length,e=this.o,f=yb.scheduleRecursiveWithState(0,function(f,g){if(!a){if(f===d)return e.onCompleted();var h=c[f];ka(h)&&(h=Gc(h));var i=new qb;b.setDisposable(i),i.setDisposable(h.subscribe(function(a){e.onNext(a)},function(a){e.onError(a)},function(){g(f+1)}))}});return new jb(b,f,mb(function(){a=!0}))},b}(Ob),qc=Nb.concat=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{a=new Array(arguments.length);for(var b=0,c=arguments.length;c>b;b++)a[b]=arguments[b]}return new pc(a)};Db.concatAll=Db.concatObservable=function(){return this.merge(1)};var rc=function(a){function b(b,c){this.source=b,this.maxConcurrent=c,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new jb;return b.add(this.source.subscribe(new sc(a,this.maxConcurrent,b))),b},b}(Ob),sc=function(){function a(a,b,c){this.o=a,this.max=b,this.g=c,this.done=!1,this.q=[],this.activeCount=0,this.isStopped=!1}function b(a,b){this.parent=a,this.sad=b,this.isStopped=!1}return a.prototype.handleSubscribe=function(a){var c=new qb;this.g.add(c),ka(a)&&(a=Gc(a)),c.setDisposable(a.subscribe(new b(this,c)))},a.prototype.onNext=function(a){this.isStopped||(this.activeCount<this.max?(this.activeCount++,this.handleSubscribe(a)):this.q.push(a))},a.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},a.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,0===this.activeCount&&this.o.onCompleted())},a.prototype.dispose=function(){this.isStopped=!0},a.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b.prototype.onNext=function(a){this.isStopped||this.parent.o.onNext(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.parent.o.onError(a))},b.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var a=this.parent;a.g.remove(this.sad),a.q.length>0?a.handleSubscribe(a.q.shift()):(a.activeCount--,a.done&&0===a.activeCount&&a.o.onCompleted())}},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(a),!0)},a}();Db.merge=function(a){return"number"!=typeof a?tc(this,a):new rc(this,a)};var tc=Nb.merge=function(){var a,b,c=[],d=arguments.length;if(arguments[0])if(vb(arguments[0]))for(a=arguments[0],b=1;d>b;b++)c.push(arguments[b]);else for(a=yb,b=0;d>b;b++)c.push(arguments[b]);else for(a=yb,b=1;d>b;b++)c.push(arguments[b]);return Array.isArray(c[0])&&(c=c[0]),C(a,c).mergeAll()},uc=function(a){function b(b){this.source=b,a.call(this)}function c(a,b){this.o=a,this.g=b,this.isStopped=!1,this.done=!1}function d(a,b,c){this.parent=a,this.g=b,this.sad=c,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){var b=new jb,d=new qb;return b.add(d),d.setDisposable(this.source.subscribe(new c(a,b))),b},c.prototype.onNext=function(a){if(!this.isStopped){var b=new qb;this.g.add(b),ka(a)&&(a=Gc(a)),b.setDisposable(a.subscribe(new d(this,this.g,b)))}},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,1===this.g.length&&this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},d.prototype.onNext=function(a){this.isStopped||this.parent.o.onNext(a)},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.parent.o.onError(a))},d.prototype.onCompleted=function(){if(!this.isStopped){var a=this.parent;this.isStopped=!0,a.g.remove(this.sad),a.done&&1===a.g.length&&a.o.onCompleted()}},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(a),!0)},b}(Ob);Db.mergeAll=Db.mergeObservable=function(){return new uc(this)};var vc=da.CompositeError=function(a){this.name="NotImplementedError",this.innerErrors=a,this.message="This contains multiple errors. Check the innerErrors",Error.call(this)};vc.prototype=Error.prototype,Nb.mergeDelayError=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}var d=C(null,a);return new Nc(function(a){function b(){0===g.length?a.onCompleted():a.onError(1===g.length?g[0]:new vc(g))}var c=new jb,e=new qb,f=!1,g=[];return c.add(e),e.setDisposable(d.subscribe(function(d){var e=new qb;c.add(e),ka(d)&&(d=Gc(d)),e.setDisposable(d.subscribe(function(b){a.onNext(b)},function(a){g.push(a),c.remove(e),f&&1===c.length&&b()},function(){c.remove(e),f&&1===c.length&&b()}))},function(a){g.push(a),f=!0,1===c.length&&b()},function(){f=!0,1===c.length&&b()})),c})},Db.skipUntil=function(a){var b=this;return new Nc(function(c){var d=!1,e=new jb(b.subscribe(function(a){d&&c.onNext(a)},function(a){c.onError(a)},function(){d&&c.onCompleted()}));ka(a)&&(a=Gc(a));var f=new qb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},function(a){c.onError(a)},function(){f.dispose()})),e},b)};var wc=function(a){function b(b){this.source=b,a.call(this)}function c(a,b){this.o=a,this.inner=b,this.stopped=!1,this.latest=0,this.hasLatest=!1,this.isStopped=!1}function d(a,b){this.parent=a,this.id=b,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){var b=new rb,d=this.source.subscribe(new c(a,b));return new jb(d,b)},c.prototype.onNext=function(a){if(!this.isStopped){var b=new qb,c=++this.latest;this.hasLatest=!0,this.inner.setDisposable(b),ka(a)&&(a=Gc(a)),b.setDisposable(a.subscribe(new d(this,c)))}},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.stopped=!0,!this.hasLatest&&this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},d.prototype.onNext=function(a){this.isStopped||this.parent.latest===this.id&&this.parent.o.onNext(a)},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&this.parent.o.onError(a))},d.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&(this.parent.hasLatest=!1,this.parent.isStopped&&this.parent.o.onCompleted()))},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(a),!0)},b}(Ob);Db["switch"]=Db.switchLatest=function(){return new wc(this)};var xc=function(a){function b(b,c){this.source=b,this.other=ka(c)?Gc(c):c,a.call(this)}function c(a){this.o=a,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return new jb(this.source.subscribe(a),this.other.subscribe(new c(a)))},c.prototype.onNext=function(a){this.isStopped||this.o.onCompleted()},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){!this.isStopped&&(this.isStopped=!0)},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.takeUntil=function(a){return new xc(this,a)},Db.withLatestFrom=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.pop(),e=this;return Array.isArray(b[0])&&(b=b[0]),new Nc(function(a){for(var c=b.length,f=q(c,G),g=!1,h=new Array(c),i=new Array(c+1),j=0;c>j;j++)!function(c){var d=b[c],e=new qb;ka(d)&&(d=Gc(d)),e.setDisposable(d.subscribe(function(a){h[c]=a,f[c]=!0,g=f.every(fa)},function(b){a.onError(b)},ea)),i[c]=e}(j);var k=new qb;return k.setDisposable(e.subscribe(function(b){var c=[b].concat(h);if(g){var e=o(d).apply(null,c);return e===bb?a.onError(e.e):void a.onNext(e)}},function(b){a.onError(b)},function(){a.onCompleted()})),i[c]=k,new jb(i)},this)},Db.zip=function(){if(Array.isArray(arguments[0]))return H.apply(this,arguments);for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=this,e=b.pop();return b.unshift(d),new Nc(function(a){for(var c=b.length,f=q(c,I),g=q(c,G),h=new Array(c),i=0;c>i;i++)!function(c){var i=b[c],j=new qb;ka(i)&&(i=Gc(i)),j.setDisposable(i.subscribe(function(b){if(f[c].push(b),f.every(function(a){return a.length>0})){var h=f.map(function(a){return a.shift()}),i=o(e).apply(d,h);if(i===bb)return a.onError(i.e);a.onNext(i)}else g.filter(function(a,b){return b!==c}).every(fa)&&a.onCompleted()},function(b){a.onError(b)},function(){g[c]=!0,g.every(fa)&&a.onCompleted()})),h[c]=j}(i);return new jb(h)},d)},Nb.zip=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.shift();return d.zip.apply(d,b)},Nb.zipArray=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}return new Nc(function(b){for(var c=a.length,d=q(c,J),e=q(c,G),f=new Array(c),g=0;c>g;g++)!function(c){f[c]=new qb,f[c].setDisposable(a[c].subscribe(function(a){if(d[c].push(a),d.every(function(a){return a.length>0})){var f=d.map(function(a){return a.shift()});b.onNext(f)}else if(e.filter(function(a,b){return b!==c}).every(fa))return b.onCompleted()},function(a){b.onError(a)},function(){e[c]=!0,e.every(fa)&&b.onCompleted()}))}(g);return new jb(f)})},Db.asObservable=function(){var a=this;return new Nc(function(b){return a.subscribe(b)},a)},Db.dematerialize=function(){var a=this;return new Nc(function(b){return a.subscribe(function(a){return a.accept(b)},function(a){b.onError(a)},function(){b.onCompleted()})},this)},Db.distinctUntilChanged=function(a,b){var c=this;return b||(b=ha),new Nc(function(d){var e,f=!1;return c.subscribe(function(c){var g=c;if(a&&(g=o(a)(c),g===bb))return d.onError(g.e);if(f){var h=o(b)(e,g);if(h===bb)return d.onError(h.e)}f&&h||(f=!0,e=g,d.onNext(c))},function(a){d.onError(a)},function(){d.onCompleted()})},this)};var yc=function(a){function b(b,c,d,e){this.source=b,this.t=!c||la(c)?Kb(c||ea,d||ea,e||ea):c,a.call(this)}function c(a,b){this.o=a,this.t=b,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this.t))},c.prototype.onNext=function(a){if(!this.isStopped){var b=o(this.t.onNext).call(this.t,a);b===bb&&this.o.onError(b.e),this.o.onNext(a)}},c.prototype.onError=function(a){if(!this.isStopped){this.isStopped=!0;var b=o(this.t.onError).call(this.t,a);if(b===bb)return this.o.onError(b.e);this.o.onError(a)}},c.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var a=o(this.t.onCompleted).call(this.t);if(a===bb)return this.o.onError(a.e);this.o.onCompleted()}},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db["do"]=Db.tap=Db.doAction=function(a,b,c){return new yc(this,a,b,c)},Db.doOnNext=Db.tapOnNext=function(a,b){return this.tap("undefined"!=typeof b?function(c){a.call(b,c)}:a)},Db.doOnError=Db.tapOnError=function(a,b){return this.tap(ea,"undefined"!=typeof b?function(c){a.call(b,c)}:a)},Db.doOnCompleted=Db.tapOnCompleted=function(a,b){return this.tap(ea,null,"undefined"!=typeof b?function(){a.call(b)}:a)},Db["finally"]=Db.ensure=function(a){var b=this;return new Nc(function(c){var d;try{d=b.subscribe(c)}catch(e){throw a(),e}return mb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})},this)},Db.finallyAction=function(a){return this.ensure(a)};var zc=function(a){function b(b){this.source=b,a.call(this)}function c(a){this.o=a,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a))},c.prototype.onNext=ea,c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},b}(Ob);Db.ignoreElements=function(){return new zc(this)},Db.materialize=function(){var a=this;return new Nc(function(b){return a.subscribe(function(a){b.onNext(Gb(a))},function(a){b.onNext(Hb(a)),b.onCompleted()},function(){b.onNext(Ib()),b.onCompleted()})},a)},Db.repeat=function(a){return Tb(this,a).concat()},Db.retry=function(a){return Tb(this,a).catchError()},Db.retryWhen=function(a){return Tb(this).catchErrorWhen(a)};var Ac=function(a){function b(b,c,d,e){this.source=b,this.accumulator=c,this.hasSeed=d,this.seed=e,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new K(a,this))},b}(Ob);K.prototype.onNext=function(a){if(!this.isStopped){!this.hasValue&&(this.hasValue=!0);try{this.hasAccumulation?this.accumulation=this.accumulator(this.accumulation,a):(this.accumulation=this.hasSeed?this.accumulator(this.seed,a):a,this.hasAccumulation=!0)}catch(b){return this.observer.onError(b)}this.observer.onNext(this.accumulation)}},K.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.observer.onError(a))},K.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,!this.hasValue&&this.hasSeed&&this.observer.onNext(this.seed),this.observer.onCompleted())},K.prototype.dispose=function(){this.isStopped=!0},K.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},Db.scan=function(){var a,b,c=!1;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new Ac(this,b,c,a)},Db.skipLast=function(a){if(0>a)throw new ta;var b=this;return new Nc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},function(a){c.onError(a)},function(){c.onCompleted()})},b)},Db.startWith=function(){var a,b=0;arguments.length&&vb(arguments[0])?(a=arguments[0],b=1):a=yb;for(var c=[],d=b,e=arguments.length;e>d;d++)c.push(arguments[d]);return Vb([ec(c,a),this]).concat()},Db.takeLast=function(a){if(0>a)throw new ta;var b=this;return new Nc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},function(a){c.onError(a)},function(){for(;d.length>0;)c.onNext(d.shift());c.onCompleted()})},b)},Db.selectConcat=Db.concatMap=function(a,b,c){return la(a)&&la(b)?this.concatMap(function(c,d){var e=a(c,d);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e.map(function(a,e){return b(c,a,d,e)})}):la(a)?L(this,a,c):L(this,function(){return a})};var Bc=function(a){function b(b,c,d){this.source=b,this.selector=Da(c,d,3),a.call(this)}function c(a,b){return function(c,d,e){return a.call(this,b.selector(c,d,e),d,e)}}function d(a,b,c){this.o=a,this.selector=b,this.source=c,this.i=0,this.isStopped=!1}return db(b,a),b.prototype.internalMap=function(a,d){return new b(this.source,c(a,this),d)},b.prototype.subscribeCore=function(a){return this.source.subscribe(new d(a,this.selector,this))},d.prototype.onNext=function(a){if(!this.isStopped){var b=o(this.selector)(a,this.i++,this.source);return b===bb?this.o.onError(b.e):void this.o.onNext(b)}},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},d.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.map=Db.select=function(a,b){var c="function"==typeof a?a:function(){return a};return this instanceof Bc?this.internalMap(c,b):new Bc(this,c,b)},Db.pluck=function(){var b=arguments,c=arguments.length;if(0===c)throw new Error("List of properties cannot be empty.");return this.map(function(d){for(var e=d,f=0;c>f;f++){var g=e[b[f]];if("undefined"==typeof g)return a;e=g}return e})},Db.selectMany=Db.flatMap=function(a,b,c){return la(a)&&la(b)?this.flatMap(function(c,d){var e=a(c,d);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e.map(function(a,e){return b(c,a,d,e)})},c):la(a)?M(this,a,c):M(this,function(){return a})},Db.selectSwitch=Db.flatMapLatest=Db.switchMap=function(a,b){return this.select(a,b).switchLatest()};var Cc=function(a){function b(b,c){this.source=b,this.skipCount=c,a.call(this)}function c(a,b){this.c=b,this.r=b,this.o=a,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this.skipCount))},c.prototype.onNext=function(a){this.isStopped||(this.r<=0?this.o.onNext(a):this.r--)},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.skip=function(a){if(0>a)throw new ta;return new Cc(this,a)},Db.skipWhile=function(a,b){var c=this,d=Da(a,b,3);return new Nc(function(a){var b=0,e=!1;return c.subscribe(function(f){if(!e)try{e=!d(f,b++,c)}catch(g){return void a.onError(g)}e&&a.onNext(f)},function(b){a.onError(b)},function(){a.onCompleted()})},c)},Db.take=function(a,b){if(0>a)throw new ta;if(0===a)return $b(b);var c=this;return new Nc(function(b){var d=a;return c.subscribe(function(a){d-->0&&(b.onNext(a),0>=d&&b.onCompleted())},function(a){b.onError(a)},function(){b.onCompleted()})},c)},Db.takeWhile=function(a,b){var c=this,d=Da(a,b,3);return new Nc(function(a){var b=0,e=!0;return c.subscribe(function(f){if(e){try{e=d(f,b++,c)}catch(g){return void a.onError(g)}e?a.onNext(f):a.onCompleted()}},function(b){a.onError(b)},function(){a.onCompleted()})},c)};var Dc=function(a){function b(b,c,d){this.source=b,this.predicate=Da(c,d,3),a.call(this)}function c(a,b){return function(c,d,e){return b.predicate(c,d,e)&&a.call(this,c,d,e)}}function d(a,b,c){this.o=a,this.predicate=b,this.source=c,this.i=0,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new d(a,this.predicate,this))},b.prototype.internalFilter=function(a,d){return new b(this.source,c(a,this),d)},d.prototype.onNext=function(a){if(!this.isStopped){var b=o(this.predicate)(a,this.i++,this.source);return b===bb?this.o.onError(b.e):void(b&&this.o.onNext(a))}},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},d.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.filter=Db.where=function(a,b){return this instanceof Dc?this.internalFilter(a,b):new Dc(this,a,b)},Nb.fromCallback=function(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return new Nc(function(d){function f(){for(var a=arguments.length,e=new Array(a),f=0;a>f;f++)e[f]=arguments[f];if(c){try{e=c.apply(b,e)}catch(g){return d.onError(g)}d.onNext(e)}else e.length<=1?d.onNext.apply(d,e):d.onNext(e);d.onCompleted()}e.push(f),a.apply(b,e)}).publishLast().refCount()}},Nb.fromNodeCallback=function(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return new Nc(function(d){function f(a){if(a)return void d.onError(a);for(var e=arguments.length,f=[],g=1;e>g;g++)f[g-1]=arguments[g];if(c){try{f=c.apply(b,f)}catch(h){return d.onError(h)}d.onNext(f)}else f.length<=1?d.onNext.apply(d,f):d.onNext(f);d.onCompleted()}e.push(f),a.apply(b,e)}).publishLast().refCount()}},da.config.useNativeEvents=!1,Nb.fromEvent=function(a,b,c){return a.addListener?Ec(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},c):da.config.useNativeEvents||"function"!=typeof a.on||"function"!=typeof a.off?new Nc(function(d){return Q(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e)}d.onNext(b)})}).publish().refCount():Ec(function(c){a.on(b,c)},function(c){a.off(b,c)},c)};var Ec=Nb.fromEventPattern=function(a,b,c){return new Nc(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e)}d.onNext(b)}var f=a(e);return mb(function(){b&&b(e,f)})}).publish().refCount()},Fc=function(a){function b(b){this.p=b,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){return this.p.then(function(b){a.onNext(b),a.onCompleted()},function(b){a.onError(b)}),nb},b}(Ob),Gc=Nb.fromPromise=function(a){return new Fc(a)};Db.toPromise=function(a){if(a||(a=da.config.Promise),!a)throw new ua("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},c,function(){e&&a(d)})})},Nb.startAsync=function(a){var b;try{b=a()}catch(c){return mc(c)}return Gc(b)},Db.multicast=function(a,b){var c=this;return"function"==typeof a?new Nc(function(d){var e=c.multicast(a());return new jb(b(e).subscribe(d),e.connect())},c):new Hc(c,a)},Db.publish=function(a){return a&&la(a)?this.multicast(function(){return new Qc},a):this.multicast(new Qc)},Db.share=function(){return this.publish().refCount()},Db.publishLast=function(a){return a&&la(a)?this.multicast(function(){return new Rc},a):this.multicast(new Rc)},Db.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new Tc(b)},a):this.multicast(new Tc(a))},Db.shareValue=function(a){return this.publishValue(a).refCount()},Db.replay=function(a,b,c,d){return a&&la(a)?this.multicast(function(){return new Uc(b,c,d)},a):this.multicast(new Uc(b,c,d))},Db.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};{var Hc=da.ConnectableObservable=function(a){function b(b,c){var d,e=!1,f=b.asObservable();this.connect=function(){return e||(e=!0,d=new jb(f.subscribe(c),mb(function(){e=!1}))),d},a.call(this,function(a){return c.subscribe(a)})}return db(b,a),b.prototype.refCount=function(){var a,b=0,c=this;return new Nc(function(d){var e=1===++b,f=c.subscribe(d);return e&&(a=c.connect()),function(){f.dispose(),0===--b&&a.dispose()}})},b}(Nb),Ic=Nb.interval=function(a,b){return U(a,a,vb(b)?b:Eb)};Nb.timer=function(b,c,d){var e;return vb(d)||(d=Eb),c!==a&&"number"==typeof c?e=c:vb(c)&&(d=c),b instanceof Date&&e===a?R(b.getTime(),d):b instanceof Date&&e!==a?(e=c,S(b.getTime(),e,d)):e===a?T(b,d):U(b,e,d)}}Db.delay=function(a,b){return vb(b)||(b=Eb),a instanceof Date?W(this,a.getTime(),b):V(this,a,b)},Db.debounce=Db.throttleWithTimeout=function(a,b){vb(b)||(b=Eb);var c=this;return new Nc(function(d){var e,f=new rb,g=!1,h=0,i=c.subscribe(function(c){g=!0,e=c,h++;var i=h,j=new qb;f.setDisposable(j),j.setDisposable(b.scheduleWithRelative(a,function(){g&&h===i&&d.onNext(e),g=!1}))},function(a){f.dispose(),d.onError(a),g=!1,h++},function(){f.dispose(),g&&d.onNext(e),d.onCompleted(),g=!1,h++});return new jb(i,f)},this)},Db.throttle=function(a,b){return this.debounce(a,b)},Db.timestamp=function(a){return vb(a)||(a=Eb),this.map(function(b){return{value:b,timestamp:a.now()}})},Db.sample=Db.throttleLatest=function(a,b){return vb(b)||(b=Eb),"number"==typeof a?X(this,Ic(a,b)):X(this,a)},Db.timeout=function(a,b,c){(null==b||"string"==typeof b)&&(b=mc(new Error(b||"Timeout"))),vb(c)||(c=Eb);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new Nc(function(f){function g(){var d=h;l.setDisposable(c[e](a,function(){h===d&&(ka(b)&&(b=Gc(b)),j.setDisposable(b.subscribe(f)))}))}var h=0,i=new qb,j=new rb,k=!1,l=new rb;return j.setDisposable(i),g(),i.setDisposable(d.subscribe(function(a){k||(h++,f.onNext(a),g())},function(a){k||(h++,f.onError(a))},function(){k||(h++,f.onCompleted())})),new jb(j,l)},d)},Db.throttleFirst=function(a,b){vb(b)||(b=Eb);var c=+a||0;if(0>=c)throw new RangeError("windowDuration cannot be less or equal zero.");var d=this;return new Nc(function(a){var e=0;return d.subscribe(function(d){var f=b.now();(0===e||f-e>=c)&&(e=f,a.onNext(d))},function(b){a.onError(b)},function(){a.onCompleted()})},d)};var Jc=function(a){function b(a){var b=this.source.publish(),c=b.subscribe(a),d=nb,e=this.pauser.distinctUntilChanged().subscribe(function(a){a?d=b.connect():(d.dispose(),d=nb)});return new jb(c,d,e)}function c(c,d){this.source=c,this.controller=new Qc,d&&d.subscribe?this.pauser=this.controller.merge(d):this.pauser=this.controller,a.call(this,b,c)}return db(c,a),c.prototype.pause=function(){this.controller.onNext(!1)},
|
4 |
+
c.prototype.resume=function(){this.controller.onNext(!0)},c}(Nb);Db.pausable=function(a){return new Jc(this,a)};var Kc=function(b){function c(b){function c(){for(;e.length>0;)b.onNext(e.shift())}var d,e=[],f=Y(this.source,this.pauser.distinctUntilChanged().startWith(!1),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(f){d!==a&&f.shouldFire!=d?(d=f.shouldFire,f.shouldFire&&c()):(d=f.shouldFire,f.shouldFire?b.onNext(f.data):e.push(f.data))},function(a){c(),b.onError(a)},function(){c(),b.onCompleted()});return f}function d(a,d){this.source=a,this.controller=new Qc,d&&d.subscribe?this.pauser=this.controller.merge(d):this.pauser=this.controller,b.call(this,c,a)}return db(d,b),d.prototype.pause=function(){this.controller.onNext(!1)},d.prototype.resume=function(){this.controller.onNext(!0)},d}(Nb);Db.pausableBuffered=function(a){return new Kc(this,a)};var Lc=function(a){function b(a){return this.source.subscribe(a)}function c(c,d,e){a.call(this,b,c),this.subject=new Mc(d,e),this.source=c.multicast(this.subject).refCount()}return db(c,a),c.prototype.request=function(a){return this.subject.request(null==a?-1:a)},c}(Nb),Mc=function(a){function b(a){return this.subject.subscribe(a)}function c(c,d){null==c&&(c=!0),a.call(this,b),this.subject=new Qc,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=nb,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.scheduler=d||zb}return db(c,a),eb(c.prototype,Jb,{onCompleted:function(){this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length?this.queue.push(Fb.createOnCompleted()):this.subject.onCompleted()},onError:function(a){this.hasFailed=!0,this.error=a,this.enableQueue&&0!==this.queue.length?this.queue.push(Fb.createOnError(a)):this.subject.onError(a)},onNext:function(a){var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(Fb.createOnNext(a)):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0||this.queue.length>0&&"N"!==this.queue[0].kind;){var b=this.queue.shift();b.accept(this.subject),"N"===b.kind?a--:(this.disposeCurrentRequest(),this.queue=[])}return{numberOfItems:a,returnValue:0!==this.queue.length}}return{numberOfItems:a,returnValue:!1}},request:function(a){this.disposeCurrentRequest();var b=this;return this.requestedDisposable=this.scheduler.scheduleWithState(a,function(a,c){var d=b._processRequest(c),e=d.numberOfItems;d.returnValue||(b.requestedCount=e,b.requestedDisposable=mb(function(){b.requestedCount=0}))}),this.requestedDisposable},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=nb}}),c}(Nb);Db.controlled=function(a,b){return a&&vb(a)&&(b=a,a=!0),null==a&&(a=!0),new Lc(this,a,b)},Db.pipe=function(a){function b(){c.resume()}var c=this.pausableBuffered();return a.addListener("drain",b),c.subscribe(function(b){!a.write(String(b))&&c.pause()},function(b){a.emit("error",b)},function(){!a._isStdio&&a.end(),a.removeListener("drain",b)}),c.resume(),a},Db.transduce=function(a){function b(a){return{"@@transducer/init":function(){return a},"@@transducer/step":function(a,b){return a.onNext(b)},"@@transducer/result":function(a){return a.onCompleted()}}}var c=this;return new Nc(function(d){var e=a(b(d));return c.subscribe(function(a){try{e["@@transducer/step"](d,a)}catch(b){d.onError(b)}},function(a){d.onError(a)},function(){e["@@transducer/result"](d)})},c)};var Nc=da.AnonymousObservable=function(a){function b(a){return a&&la(a.dispose)?a:la(a)?mb(a):nb}function c(a,c){var d=c[0],e=c[1],f=o(e)(d);return f!==bb||d.fail(bb.e)?void d.setDisposable(b(f)):p(bb.e)}function d(b,d){function e(a){var d=new Oc(a),e=[d,b];return zb.scheduleRequired()?zb.scheduleWithState(e,c):c(null,e),d}this.source=d,a.call(this,e)}return db(d,a),d}(Nb),Oc=function(a){function b(b){a.call(this),this.observer=b,this.m=new qb}db(b,a);var c=b.prototype;return c.next=function(a){var b=o(this.observer.onNext).call(this.observer,a);b===bb&&(this.dispose(),p(b.e))},c.error=function(a){var b=o(this.observer.onError).call(this.observer,a);this.dispose(),b===bb&&p(b.e)},c.completed=function(){var a=o(this.observer.onCompleted).call(this.observer);this.dispose(),a===bb&&p(a.e)},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Lb),Pc=function(a,b){this.subject=a,this.observer=b};Pc.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var Qc=da.Subject=function(a){function c(a){return pb(this),this.isStopped?this.hasError?(a.onError(this.error),nb):(a.onCompleted(),nb):(this.observers.push(a),new Pc(this,a))}function d(){a.call(this,c),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return db(d,a),eb(d.prototype,Jb.prototype,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(pb(this),!this.isStopped){this.isStopped=!0;for(var a=0,c=b(this.observers),d=c.length;d>a;a++)c[a].onCompleted();this.observers.length=0}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onError(a);this.observers.length=0}},onNext:function(a){if(pb(this),!this.isStopped)for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),d.create=function(a,b){return new Sc(a,b)},d}(Nb),Rc=da.AsyncSubject=function(a){function c(a){return pb(this),this.isStopped?(this.hasError?a.onError(this.error):this.hasValue?(a.onNext(this.value),a.onCompleted()):a.onCompleted(),nb):(this.observers.push(a),new Pc(this,a))}function d(){a.call(this,c),this.isDisposed=!1,this.isStopped=!1,this.hasValue=!1,this.observers=[],this.hasError=!1}return db(d,a),eb(d.prototype,Jb,{hasObservers:function(){return pb(this),this.observers.length>0},onCompleted:function(){var a,c;if(pb(this),!this.isStopped){this.isStopped=!0;var d=b(this.observers),c=d.length;if(this.hasValue)for(a=0;c>a;a++){var e=d[a];e.onNext(this.value),e.onCompleted()}else for(a=0;c>a;a++)d[a].onCompleted();this.observers.length=0}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onError(a);this.observers.length=0}},onNext:function(a){pb(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),d}(Nb),Sc=da.AnonymousSubject=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){this.observer=c,this.observable=d,a.call(this,b)}return db(c,a),eb(c.prototype,Jb.prototype,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Nb),Tc=da.BehaviorSubject=function(a){function c(a){return pb(this),this.isStopped?(this.hasError?a.onError(this.error):a.onCompleted(),nb):(this.observers.push(a),a.onNext(this.value),new Pc(this,a))}function d(b){a.call(this,c),this.value=b,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.hasError=!1}return db(d,a),eb(d.prototype,Jb,{getValue:function(){if(pb(this),this.hasError)throw this.error;return this.value},hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(pb(this),!this.isStopped){this.isStopped=!0;for(var a=0,c=b(this.observers),d=c.length;d>a;a++)c[a].onCompleted();this.observers.length=0}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onError(a);this.observers.length=0}},onNext:function(a){if(pb(this),!this.isStopped){this.value=a;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),d}(Nb),Uc=da.ReplaySubject=function(a){function c(a,b){return mb(function(){b.dispose(),!a.isDisposed&&a.observers.splice(a.observers.indexOf(b),1)})}function d(a){var b=new Wb(this.scheduler,a),d=c(this,b);pb(this),this._trim(this.scheduler.now()),this.observers.push(b);for(var e=0,f=this.q.length;f>e;e++)b.onNext(this.q[e].value);return this.hasError?b.onError(this.error):this.isStopped&&b.onCompleted(),b.ensureActive(),d}function e(b,c,e){this.bufferSize=null==b?f:b,this.windowSize=null==c?f:c,this.scheduler=e||zb,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,d)}var f=Math.pow(2,53)-1;return db(e,a),eb(e.prototype,Jb.prototype,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){if(pb(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=0,e=b(this.observers),f=e.length;f>d;d++){var g=e[d];g.onNext(a),g.ensureActive()}}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=0,e=b(this.observers),f=e.length;f>d;d++){var g=e[d];g.onError(a),g.ensureActive()}this.observers.length=0}},onCompleted:function(){if(pb(this),!this.isStopped){this.isStopped=!0;var a=this.scheduler.now();this._trim(a);for(var c=0,d=b(this.observers),e=d.length;e>c;c++){var f=d[c];f.onCompleted(),f.ensureActive()}this.observers.length=0}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(Nb);da.Pauser=function(a){function b(){a.call(this)}return db(b,a),b.prototype.pause=function(){this.onNext(!1)},b.prototype.resume=function(){this.onNext(!0)},b}(Qc),"function"==typeof define&&"object"==typeof define.amd&&define.amd?($.Rx=da,define(function(){return da})):_&&aa?ba?(aa.exports=da).Rx=da:_.Rx=da:$.Rx=da;var Vc=g()}).call(this);
|
5 |
+
//# sourceMappingURL=rx.lite.compat.map
|
js/set-unbounce-domains.js
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($) {
|
2 |
+
|
3 |
+
function apiGet(url, token) {
|
4 |
+
var request = $.ajax({
|
5 |
+
url: url,
|
6 |
+
method: 'get',
|
7 |
+
headers: { 'Authorization': 'Bearer ' + token,
|
8 |
+
'Accept': 'application/vnd.unbounce.api.v0.4+json' },
|
9 |
+
dataType: 'json'
|
10 |
+
});
|
11 |
+
return Rx.Observable.fromPromise(request.promise());
|
12 |
+
}
|
13 |
+
|
14 |
+
function getApiResult(modelName, attributeName, result) {
|
15 |
+
if($.isArray(result[modelName])) {
|
16 |
+
return Rx.Observable.fromArray(
|
17 |
+
$.map(result[modelName], function(resultModelName) {
|
18 |
+
if(resultModelName && resultModelName[attributeName]) {
|
19 |
+
return resultModelName[attributeName];
|
20 |
+
} else {
|
21 |
+
throw 'Unable to fetch ' + attributeName;
|
22 |
+
}
|
23 |
+
}));
|
24 |
+
} else {
|
25 |
+
throw 'Unable to fetch ' + first;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function postDomainsToWordpress($form, domains) {
|
30 |
+
$form.find('[name="domains"]').val(domains.join(','));
|
31 |
+
$form.submit();
|
32 |
+
}
|
33 |
+
|
34 |
+
function failureUI($form, $submitButton, originalText) {
|
35 |
+
var message = $('<div class="error">').text('Sorry, something went wrong when Authenticating with Unbounce. Please try again.');
|
36 |
+
$form.append(message);
|
37 |
+
$submitButton.attr('disabled', false).val(originalText);
|
38 |
+
}
|
39 |
+
|
40 |
+
function loadingUI($submitButton, text) {
|
41 |
+
$submitButton.attr('disabled', true).val(text);
|
42 |
+
}
|
43 |
+
|
44 |
+
$(document).ready(function(){
|
45 |
+
var $submitButton = $('#set-unbounce-domains');
|
46 |
+
|
47 |
+
if($submitButton[0]) {
|
48 |
+
var $form = $($submitButton[0].form),
|
49 |
+
originalText = $submitButton.val(),
|
50 |
+
loadingText = 'Authorizing...',
|
51 |
+
apiUrl = $submitButton.attr('data-api-url'),
|
52 |
+
redirectUri = $submitButton.attr('data-redirect-uri'),
|
53 |
+
apiClientId = $submitButton.attr('data-api-client-id'),
|
54 |
+
getTokenUrl = apiUrl + '/oauth/authorize?response_type=token&client_id=' + apiClientId + '&redirect_uri=' + redirectUri,
|
55 |
+
getAccountsUrl = apiUrl + '/accounts',
|
56 |
+
getSubAccountsUrl = apiUrl + '/accounts/{accountId}/sub_accounts',
|
57 |
+
getSubAccountUrl = apiUrl + '/sub_accounts/{subAccountId}',
|
58 |
+
getDomainsUrl = apiUrl + '/sub_accounts/{subAccountId}/domains',
|
59 |
+
setDomainsUrl = $form.attr('action'),
|
60 |
+
matches = location.hash.match(/access_token=([a-z0-9]+)/),
|
61 |
+
accessToken = matches && matches[1];
|
62 |
+
|
63 |
+
$submitButton.click(function(e) {
|
64 |
+
e.preventDefault();
|
65 |
+
|
66 |
+
document.location = getTokenUrl;
|
67 |
+
|
68 |
+
return false;
|
69 |
+
});
|
70 |
+
|
71 |
+
if(accessToken) {
|
72 |
+
loadingUI($submitButton, loadingText);
|
73 |
+
|
74 |
+
var source = apiGet(getAccountsUrl, accessToken)
|
75 |
+
.flatMap(function(accounts) {
|
76 |
+
return getApiResult('accounts', 'id', accounts);
|
77 |
+
})
|
78 |
+
.flatMap(function(accountId) {
|
79 |
+
return apiGet(getSubAccountsUrl.replace('{accountId}', accountId), accessToken);
|
80 |
+
})
|
81 |
+
.flatMap(function(subAccount) {
|
82 |
+
return getApiResult('sub_accounts', 'id', subAccount);
|
83 |
+
})
|
84 |
+
.flatMap(function (subAccountId) {
|
85 |
+
return apiGet(getDomainsUrl.replace('{subAccountId}', subAccountId), accessToken);
|
86 |
+
})
|
87 |
+
.flatMap(function(domains) {
|
88 |
+
return getApiResult('domains', 'name', domains);
|
89 |
+
}).toArray().publish(),
|
90 |
+
subscription = source.subscribe(
|
91 |
+
function (domains) {
|
92 |
+
postDomainsToWordpress($form, domains);
|
93 |
+
},
|
94 |
+
function (error) {
|
95 |
+
failureUI($form, $submitButton, originalText);
|
96 |
+
console.log('[ub-wordpress]', error);
|
97 |
+
},
|
98 |
+
function () {
|
99 |
+
// toArray will ensure that onNext is called only once. We'll consider that 'completed'
|
100 |
+
// as we'll also have access to the list of domains
|
101 |
+
});
|
102 |
+
|
103 |
+
source.connect();
|
104 |
+
}
|
105 |
+
}
|
106 |
+
});
|
107 |
+
})(jQuery);
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: unbouncewordpress
|
|
3 |
Tags: unbounce
|
4 |
Requires at least: 4.1.5
|
5 |
Tested up to: 4.2.2
|
6 |
-
Stable tag: 0.1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -43,7 +43,11 @@ Unbounce to that domain for them to be visible on your Wordpress site.
|
|
43 |
|
44 |
= Do I need to log in to Unbounce? =
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
|
48 |
= Does this plugin fetch any data from Unbounce? =
|
49 |
|
@@ -64,8 +68,13 @@ to help track down the issue.
|
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
-
= 0.1.
|
68 |
-
*
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
= 0.1.1 =
|
71 |
* Initial release
|
3 |
Tags: unbounce
|
4 |
Requires at least: 4.1.5
|
5 |
Tested up to: 4.2.2
|
6 |
+
Stable tag: 0.1.20
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
43 |
|
44 |
= Do I need to log in to Unbounce? =
|
45 |
|
46 |
+
Yes, after installing and activating this plugin, you will need to go "Unbounce Pages" in the admin
|
47 |
+
section and click "Authorize With Unbounce." You will then be sent to Unbounce where you need to
|
48 |
+
log in. You must log in as an Unbounce user that has access to the Client that has the current
|
49 |
+
domain in Unbounce, or you will need to authorize again as an authorized user before the plugin
|
50 |
+
will function.
|
51 |
|
52 |
= Does this plugin fetch any data from Unbounce? =
|
53 |
|
68 |
|
69 |
== Changelog ==
|
70 |
|
71 |
+
= 0.1.19 =
|
72 |
+
* This release introduces the requirement to authorize your installation with Unbounce. After installing
|
73 |
+
you will need to go "Unbounce Pages" in the admin section and click "Authorize With Unbounce." You
|
74 |
+
will then be sent to Unbounce where you need to log in. You must log in as an Unbounce user that
|
75 |
+
has access to the Client that has the current domain in Unbounce, or you will need to authorize
|
76 |
+
again as an authorized user before the plugin will function.
|
77 |
+
* Fixes compatibility issues with caching plugins such as ZenCache, W3 Total Cache, and WP Super Cache
|
78 |
|
79 |
= 0.1.1 =
|
80 |
* Initial release
|