Skip to content

Commit 9fb166b

Browse files
committed
requested changes
1 parent d5a7a22 commit 9fb166b

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

assets/js/communities-of-practice.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,51 @@ document.addEventListener("DOMContentLoaded", function() {
8585
}
8686

8787
// Set up the Slack channel button event listeners
88-
setupSlackChannelButtons();
88+
setupSlackChannelButtons();
89+
90+
// Function to get the saved Slack channel URL from localStorage and update the button
91+
function loadSlackChannelButton() {
92+
const savedSlackUrl = localStorage.getItem('selectedSlackChannel');
93+
const savedCommunityName = localStorage.getItem('selectedCommunityName');
94+
95+
const slackButton = document.querySelector('.slack-channel-link');
96+
97+
if (savedSlackUrl && slackButton) {
98+
// Update the button with the saved Slack URL
99+
slackButton.href = savedSlackUrl;
100+
101+
// Update the title attribute if we have the community name
102+
if (savedCommunityName) {
103+
slackButton.title = `${savedCommunityName} Slack channel`;
104+
}
105+
106+
// Add click event to clear localStorage after successful redirect
107+
slackButton.addEventListener('click', function() {
108+
// Clear the stored values after user clicks to join
109+
localStorage.removeItem('selectedSlackChannel');
110+
localStorage.removeItem('selectedCommunityName');
111+
});
112+
} else {
113+
// If no URL was saved, redirect back to communities page or show error
114+
console.error('No Slack channel URL found in localStorage');
115+
116+
// Option 1: Redirect back to communities page
117+
// window.location.href = '/communities-of-practice';
118+
119+
// Option 2: Update button to show error state
120+
if (slackButton) {
121+
slackButton.href = '/communities-of-practice';
122+
slackButton.innerHTML = `
123+
<svg version="1.1" viewBox="0 0 90 90" xmlns="http://www.w3.org/2000/svg" width="20" height="20">
124+
<path d="..." fill="currentColor"/>
125+
</svg>
126+
Return to Communities
127+
`;
128+
slackButton.title = 'Return to Communities of Practice page';
129+
}
130+
}
131+
}
132+
133+
// Load the Slack channel button when page loads
134+
loadSlackChannelButton();
89135
});

pages/join-slack-channel.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h1 class="title1">Join Slack Channel</h1>
1212
</p>
1313

1414
<div class="align-center link-buttons">
15-
<a href="#" class="btn btn-primary btn-md btn--default cop-btn slack-link" target="_blank" title="Community Slack channel" rel="noopener noreferrer">
15+
<a href="#" class="btn btn-primary btn-md btn--default cop-btn slack-channel-link" target="_blank" title="Community Slack channel" rel="noopener noreferrer">
1616
{% include svg/icon-slack.svg %}
1717
Join Slack Channel
1818
</a>
@@ -27,4 +27,4 @@ <h1 class="title1">Join Slack Channel</h1>
2727
</div>
2828
</div>
2929

30-
<script type="module" src="assets/js/join-slack-channel.js"></script>
30+
<script type="module" src="assets/js/communities-of-practice.js"></script>

0 commit comments

Comments
 (0)