Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0a8584

Browse files
committed
changed logic to change segment to base on local storage
1 parentd1e270a commitc0a8584

File tree

4 files changed

+40
-94
lines changed

4 files changed

+40
-94
lines changed

‎_includes/argohub-docs-navbar.html‎

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
<divclass="divider-vertical mt-1"></div>
1919

2020
<divclass="custom-select">
21-
<divclass="select-display"onclick="toggleDropdown()">GitOps Cloud</div>
21+
<divclass="select-display"onclick="toggleSegmentDropdown()">GitOps Cloud</div>
2222
<ulclass="options">
23-
<liclass="option selected"onclick="selectOption(this, 'gitops')">GitOps Cloud</li>
24-
<liclass="option"onclick="selectOption(this, 'enterprise')">Pipelines & GitOps</li>
23+
<liclass="option selected"onclick="selectSegmentOption(this, 'gitops')">GitOps Cloud</li>
24+
<liclass="option"onclick="selectSegmentOption(this, 'enterprise')">Pipelines & GitOps</li>
2525
</ul>
2626
</div>
2727
</div>
@@ -63,46 +63,3 @@
6363
{% endif %}
6464
</div>
6565
</header>
66-
67-
<script>
68-
functiontoggleDropdown(){
69-
constselect=document.querySelector('.custom-select');
70-
select.classList.toggle('open');
71-
}
72-
73-
functionselectOption(option,selectedValue){
74-
constselectDisplay=document.querySelector('.select-display');
75-
constoptions=document.querySelectorAll('.option');
76-
77-
// Update the display text
78-
selectDisplay.textContent=option.textContent;
79-
80-
// change cookie
81-
if(selectedValue==='enterprise'){
82-
setEnterpriseDocumentationCookie();
83-
location.href=`${SITE_BASE_URL}/`
84-
}elseif(selectedValue==='gitops'){
85-
console.log('here 3')
86-
removeEnterpriseDocumentationCookie();
87-
location.href=SITE_GITOPS_COLLECTION
88-
}
89-
}
90-
91-
functionsetEnterpriseDocumentationCookie(){
92-
constenterpriseDocumentationCookieName=`cfdoctype=enterprise`
93-
document.cookie=`${enterpriseDocumentationCookieName}; SameSite=Strict; Secure; Max-age=2592000; Path=/`
94-
}
95-
96-
functionremoveEnterpriseDocumentationCookie(){
97-
constenterpriseDocumentationCookieName=`cfdoctype=enterprise`
98-
document.cookie=`${enterpriseDocumentationCookieName}; SameSite=Strict; Secure; Max-age=0; Path=/`
99-
}
100-
101-
// Close dropdown when clicking outside
102-
document.addEventListener('click',(e)=>{
103-
constselect=document.querySelector('.custom-select');
104-
if(!select.contains(e.target)){
105-
select.classList.remove('open');
106-
}
107-
});
108-
</script>

‎_includes/docs-navbar.html‎

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</a>
99
<divclass="divider-vertical mt-1"></div>
1010
<divclass="custom-select">
11-
<divclass="select-display"onclick="toggleDropdown()">Pipelines & GitOps</div>
11+
<divclass="select-display"onclick="toggleSegmentDropdown()">Pipelines & GitOps</div>
1212
<ulclass="options">
13-
<liclass="option"onclick="selectOption(this, 'gitops')">GitOps Cloud</li>
14-
<liclass="option selected"onclick="selectOption(this, 'enterprise')">Pipelines & GitOps</li>
13+
<liclass="option"onclick="selectSegmentOption(this, 'gitops')">GitOps Cloud</li>
14+
<liclass="option selected"onclick="selectSegmentOption(this, 'enterprise')">Pipelines & GitOps</li>
1515
</ul>
1616
</div>
1717
</div>
@@ -123,46 +123,3 @@
123123
</button>
124124
{% endif %}
125125
</header>
126-
127-
<script>
128-
functiontoggleDropdown(){
129-
constselect=document.querySelector('.custom-select');
130-
select.classList.toggle('open');
131-
}
132-
133-
functionselectOption(option,selectedValue){
134-
constselectDisplay=document.querySelector('.select-display');
135-
constoptions=document.querySelectorAll('.option');
136-
137-
// Update the display text
138-
selectDisplay.textContent=option.textContent;
139-
140-
// change cookie
141-
if(selectedValue==='enterprise'){
142-
setEnterpriseDocumentationCookie();
143-
location.href=`${SITE_BASE_URL}/`
144-
}elseif(selectedValue==='gitops'){
145-
console.log('here 3')
146-
removeEnterpriseDocumentationCookie();
147-
location.href=SITE_GITOPS_COLLECTION
148-
}
149-
}
150-
151-
functionsetEnterpriseDocumentationCookie(){
152-
constenterpriseDocumentationCookieName=`cfdoctype=enterprise`
153-
document.cookie=`${enterpriseDocumentationCookieName}; SameSite=Strict; Secure; Domain=.codefresh.io; Max-age=2592000; Path=/`
154-
}
155-
156-
functionremoveEnterpriseDocumentationCookie(){
157-
constenterpriseDocumentationCookieName=`cfdoctype=enterprise`
158-
document.cookie=`${enterpriseDocumentationCookieName}; SameSite=Strict; Secure; Domain=.codefresh.io; Max-age=0; Path=/`
159-
}
160-
161-
// Close dropdown when clicking outside
162-
document.addEventListener('click',(e)=>{
163-
constselect=document.querySelector('.custom-select');
164-
if(!select.contains(e.target)){
165-
select.classList.remove('open');
166-
}
167-
});
168-
</script>

‎_includes/scripts.html‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,35 @@
8282
});
8383
</script>
8484

85+
<script>
86+
window.toggleSegmentDropdown=function(){
87+
constselect=document.querySelector('.custom-select');
88+
console.log(select)
89+
select.classList.toggle('open');
90+
};
91+
92+
window.selectSegmentOption=function(option,selectedValue){
93+
constselectDisplay=document.querySelector('.select-display');
94+
constoptions=document.querySelectorAll('.option');
95+
96+
// Update the display text
97+
selectDisplay.textContent=option.textContent;
98+
99+
if(selectedValue==='enterprise'){
100+
localStorage.setItem(enterpriseDocTypeLockKey,'true');
101+
location.href=`${SITE_BASE_URL}/`;
102+
}elseif(selectedValue==='gitops'){
103+
localStorage.setItem(enterpriseDocTypeLockKey,'false');
104+
location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`;
105+
}
106+
};
107+
108+
// Close dropdown when clicking outside
109+
document.addEventListener('click',(e)=>{
110+
constselect=document.querySelector('.custom-select');
111+
if(!select.contains(e.target)){
112+
select.classList.remove('open');
113+
}
114+
});
115+
</script>
116+

‎assets/js/src/argohub-redirect.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ function handleEnterpriseDocTypeLock() {
4747
constqueryParams=newURLSearchParams(location.search);
4848
if(!queryParams.has('ent'))return;
4949

50-
sessionStorage.setItem(enterpriseDocTypeLockKey,'true');
50+
localStorage.setItem(enterpriseDocTypeLockKey,'true');
5151
}
5252

5353

5454
functionisEnterpriseLockPresent(){
55-
constenterpriseDocTypeLock=sessionStorage.getItem(enterpriseDocTypeLockKey)
55+
constenterpriseDocTypeLock=localStorage.getItem(enterpriseDocTypeLockKey)
5656
return!!enterpriseDocTypeLock
5757

5858
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp