@@ -2,7 +2,7 @@ var placeholderUrls = {
2
2
oss : 'http://localhost:8086' ,
3
3
cloud : 'https://cloud2.influxdata.com' ,
4
4
serverless : 'https://cloud2.influxdata.com' ,
5
- dedicated : 'cluster-id.influxdb.io' ,
5
+ dedicated : 'cluster-id.a. influxdb.io' ,
6
6
clustered : 'cluster-host.com' ,
7
7
} ;
8
8
@@ -13,7 +13,7 @@ var placeholderUrls = {
13
13
var elementSelector = '.article--content pre:not(.preserve)' ;
14
14
15
15
// Return the page context (cloud, serverless, oss/enterprise, dedicated, clustered, other)
16
- function context ( ) {
16
+ function context ( ) {
17
17
if ( / \/ i n f l u x d b \/ c l o u d \/ / . test ( window . location . pathname ) ) {
18
18
return 'cloud' ;
19
19
} else if ( / \/ i n f l u x d b \/ c l o u d - s e r v e r l e s s / . test ( window . location . pathname ) ) {
@@ -37,12 +37,12 @@ function context () {
37
37
38
38
// Retrieve the user's InfluxDB preference (cloud or oss) from the influxdb_pref session cookie
39
39
// Default is cloud.
40
- function getURLPreference ( ) {
40
+ function getURLPreference ( ) {
41
41
return getPreference ( 'influxdb_url' ) ;
42
42
}
43
43
44
44
// Set the user's selected InfluxDB preference (cloud or oss)
45
- function setURLPreference ( preference ) {
45
+ function setURLPreference ( preference ) {
46
46
setPreference ( 'influxdb_url' , preference ) ;
47
47
}
48
48
@@ -61,7 +61,7 @@ function setURLPreference (preference) {
61
61
*/
62
62
63
63
// Store URLs in the urls session cookies
64
- function storeUrl ( context , newUrl , prevUrl ) {
64
+ function storeUrl ( context , newUrl , prevUrl ) {
65
65
urlsObj = { } ;
66
66
urlsObj [ 'prev_' + context ] = prevUrl ;
67
67
urlsObj [ context ] = newUrl ;
@@ -71,20 +71,20 @@ function storeUrl (context, newUrl, prevUrl) {
71
71
72
72
// Store custom URL in the url session cookie.
73
73
// Used to populate the custom URL field
74
- function storeCustomUrl ( customUrl ) {
74
+ function storeCustomUrl ( customUrl ) {
75
75
setInfluxDBUrls ( { custom : customUrl } ) ;
76
76
$ ( 'input#custom[type=radio]' ) . val ( customUrl ) ;
77
77
}
78
78
79
79
// Set a URL in the urls session cookie to an empty string
80
80
// Used to clear the form when custom url input is left empty
81
- function removeCustomUrl ( ) {
81
+ function removeCustomUrl ( ) {
82
82
removeInfluxDBUrl ( 'custom' ) ;
83
83
}
84
84
85
85
// Store a product URL in the urls session cookie
86
86
// Used to populate the custom URL field
87
- function storeProductUrl ( product , productUrl ) {
87
+ function storeProductUrl ( product , productUrl ) {
88
88
urlsObj = { } ;
89
89
urlsObj [ product ] = productUrl ;
90
90
@@ -94,7 +94,7 @@ function storeProductUrl (product, productUrl) {
94
94
95
95
// Set a product URL in the urls session cookie to an empty string
96
96
// Used to clear the form when dedicated url input is left empty
97
- function removeProductUrl ( product ) {
97
+ function removeProductUrl ( product ) {
98
98
removeInfluxDBUrl ( product ) ;
99
99
}
100
100
@@ -104,7 +104,7 @@ function removeProductUrl (product) {
104
104
105
105
// Preserve URLs in codeblocks that come just after or are inside a div
106
106
// with the class, .keep-url
107
- function addPreserve ( ) {
107
+ function addPreserve ( ) {
108
108
$ ( '.keep-url' ) . each ( function ( ) {
109
109
// For code blocks with no syntax highlighting
110
110
$ ( this ) . next ( 'pre' ) . addClass ( 'preserve' ) ;
@@ -119,7 +119,7 @@ function addPreserve () {
119
119
}
120
120
121
121
// Retrieve the currently selected URLs from the urls session cookie.
122
- function getUrls ( ) {
122
+ function getUrls ( ) {
123
123
var storedUrls = getInfluxDBUrls ( ) ;
124
124
var currentCloudUrl = storedUrls . cloud ;
125
125
var currentOSSUrl = storedUrls . oss ;
@@ -138,7 +138,7 @@ function getUrls () {
138
138
139
139
// Retrieve the previously selected URLs from the from the urls session cookie.
140
140
// This is used to update URLs whenever you switch between browser tabs.
141
- function getPrevUrls ( ) {
141
+ function getPrevUrls ( ) {
142
142
var storedUrls = getInfluxDBUrls ( ) ;
143
143
var prevCloudUrl = storedUrls . prev_cloud ;
144
144
var prevOSSUrl = storedUrls . prev_oss ;
@@ -156,7 +156,7 @@ function getPrevUrls () {
156
156
}
157
157
158
158
// Iterate through code blocks and update InfluxDB urls
159
- function updateUrls ( prevUrls , newUrls ) {
159
+ function updateUrls ( prevUrls , newUrls ) {
160
160
var preference = getURLPreference ( ) ;
161
161
var prevUrlsParsed = {
162
162
oss : { } ,
@@ -244,7 +244,7 @@ function updateUrls (prevUrls, newUrls) {
244
244
}
245
245
} ) ;
246
246
247
- function replaceWholename ( startStr , endStr , replacement ) {
247
+ function replaceWholename ( startStr , endStr , replacement ) {
248
248
var startsWithSeparator = new RegExp ( '[/.]' ) ;
249
249
var endsWithSeparator = new RegExp ( '[-.:]' ) ;
250
250
if (
@@ -278,7 +278,7 @@ function updateUrls (prevUrls, newUrls) {
278
278
}
279
279
280
280
// Append the URL selector button to each codeblock containing a placeholder URL
281
- function appendUrlSelector ( ) {
281
+ function appendUrlSelector ( ) {
282
282
var appendToUrls = [
283
283
placeholderUrls . oss ,
284
284
placeholderUrls . cloud ,
@@ -290,15 +290,15 @@ function appendUrlSelector () {
290
290
getBtnText = ( context ) => {
291
291
contextText = {
292
292
'oss/enterprise' : 'Change InfluxDB URL' ,
293
- ' cloud' : 'InfluxDB Cloud Region' ,
294
- ' serverless' : 'InfluxDB Cloud Region' ,
295
- ' dedicated' : 'Set Dedicated cluster URL' ,
296
- ' clustered' : 'Set InfluxDB cluster URL' ,
297
- ' other' : 'InfluxDB Cloud or OSS?'
298
- }
299
-
300
- return contextText [ context ]
301
- }
293
+ cloud : 'InfluxDB Cloud Region' ,
294
+ serverless : 'InfluxDB Cloud Region' ,
295
+ dedicated : 'Set Dedicated cluster URL' ,
296
+ clustered : 'Set InfluxDB cluster URL' ,
297
+ other : 'InfluxDB Cloud or OSS?' ,
298
+ } ;
299
+
300
+ return contextText [ context ] ;
301
+ } ;
302
302
303
303
appendToUrls . forEach ( function ( url ) {
304
304
$ ( elementSelector ) . each ( function ( ) {
@@ -344,7 +344,7 @@ $('.url-trigger').click(function (e) {
344
344
} ) ;
345
345
346
346
// Set the selected URL radio buttons to :checked
347
- function setRadioButtons ( ) {
347
+ function setRadioButtons ( ) {
348
348
currentUrls = getUrls ( ) ;
349
349
$ ( 'input[name="influxdb-cloud-url"][value="' + currentUrls . cloud + '"]' ) . prop (
350
350
'checked' ,
@@ -426,7 +426,7 @@ $('input[name="influxdb-clustered-url"]').change(function () {
426
426
} ) ;
427
427
428
428
// Toggle preference tabs
429
- function togglePrefBtns ( el ) {
429
+ function togglePrefBtns ( el ) {
430
430
preference = el . length ? el . attr ( 'id' ) . replace ( 'pref-' , '' ) : 'cloud' ;
431
431
prefUrls = $ ( '#' + preference + '-urls' ) ;
432
432
@@ -443,7 +443,7 @@ $('#pref-tabs .pref-tab').click(function () {
443
443
} ) ;
444
444
445
445
// Select preference tab from cookie
446
- function showPreference ( ) {
446
+ function showPreference ( ) {
447
447
var preference = getPreference ( 'influxdb_url' ) ;
448
448
prefTab = $ ( '#pref-' + preference ) ;
449
449
togglePrefBtns ( prefTab ) ;
@@ -457,7 +457,7 @@ showPreference();
457
457
////////////////////////////////////////////////////////////////////////////////
458
458
459
459
// Validate custom URLs
460
- function validateUrl ( url ) {
460
+ function validateUrl ( url ) {
461
461
/** validDomain = (Named host | IPv6 host | IPvFuture host)(:Port)? **/
462
462
var validDomain = new RegExp (
463
463
`([a-z0-9\-._~%]+` +
@@ -505,19 +505,19 @@ function validateUrl (url) {
505
505
}
506
506
507
507
// Show validation errors
508
- function showValidationMessage ( validation ) {
508
+ function showValidationMessage ( validation ) {
509
509
$ ( '#custom-url' ) . addClass ( 'error' ) ;
510
510
$ ( '#custom-url' ) . attr ( 'data-message' , validation . error ) ;
511
511
}
512
512
513
513
// Hide validation messages and replace the message attr with empty string
514
- function hideValidationMessage ( ) {
514
+ function hideValidationMessage ( ) {
515
515
$ ( '#custom-url' ) . removeClass ( 'error' ) . attr ( 'data-message' , '' ) ;
516
516
}
517
517
518
518
// Set the custom URL cookie and apply the change
519
519
// If the custom URL field is empty, it defaults to the OSS default
520
- function applyCustomUrl ( ) {
520
+ function applyCustomUrl ( ) {
521
521
var custUrl = $ ( '#custom-url-field' ) . val ( ) ;
522
522
let urlValidation = validateUrl ( custUrl ) ;
523
523
if ( custUrl . length > 0 ) {
@@ -540,7 +540,7 @@ function applyCustomUrl () {
540
540
541
541
// Set the product URL cookie and apply the change
542
542
// If the product URL field is empty, it defaults to the product default
543
- function applyProductUrl ( product ) {
543
+ function applyProductUrl ( product ) {
544
544
var productUrl = $ ( `#${ product } -url-field` ) . val ( ) ;
545
545
let urlValidation = validateUrl ( productUrl ) ;
546
546
if ( productUrl . length > 0 ) {
@@ -605,15 +605,15 @@ $(urlValueElements).blur(function () {
605
605
/** Delay execution of a function `fn` for a number of milliseconds `ms`
606
606
* e.g., delay a validation handler to avoid annoying the user.
607
607
*/
608
- function delay ( fn , ms ) {
608
+ function delay ( fn , ms ) {
609
609
let timer = 0 ;
610
610
return function ( ...args ) {
611
611
clearTimeout ( timer ) ;
612
612
timer = setTimeout ( fn . bind ( this , ...args ) , ms || 0 ) ;
613
613
} ;
614
614
}
615
615
616
- function handleUrlValidation ( ) {
616
+ function handleUrlValidation ( ) {
617
617
let url = $ ( urlValueElements ) . val ( ) ;
618
618
let urlValidation = validateUrl ( url ) ;
619
619
if ( urlValidation . valid ) {
@@ -658,3 +658,13 @@ if (cloudUrls.includes(referrerHost)) {
658
658
setURLPreference ( 'cloud' ) ;
659
659
showPreference ( ) ;
660
660
}
661
+
662
+ ////////////////////////////////////////////////////////////////////////////////
663
+ //////////////////////////// Dedicated URL Migration ///////////////////////////
664
+ ///////////////////////// REMOVE AFTER AUGUST 22, 2024 /////////////////////////
665
+ ////////////////////////////////////////////////////////////////////////////////
666
+
667
+ if ( getUrls ( ) . dedicated == 'cluster-id.influxdb.io' ) {
668
+ storeUrl ( 'dedicated' , 'cluster-id.a.influxdb.io' , getUrls ( ) . dedicated ) ;
669
+ updateUrls ( getPrevUrls ( ) , getUrls ( ) ) ;
670
+ }
0 commit comments