Skip to content

Commit

Permalink
Remove old console button script
Browse files Browse the repository at this point in the history
Signed-off-by: mohin7 <[email protected]>
  • Loading branch information
mohin7 committed Feb 13, 2024
1 parent 855bcdd commit a0dbeea
Showing 1 changed file with 1 addition and 75 deletions.
76 changes: 1 addition & 75 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
</div>
</div>
</div>


<script type="text/javascript">
// for cookie
Expand Down Expand Up @@ -1123,81 +1124,6 @@ <h4>Legal</h4>
{{ end }}


<!-- console beta tag start -->
<script>
const acSignInButton = document.getElementById('ac-sign-in-button')

// define Beta tag
const betaSpan = document.createElement("span")
betaSpan.innerText = "BETA"
betaSpan.classList.add('tag')

// function to get cookie
function getCookie(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

// function to fetch user
async function fetchUser() {
try {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;

const apiDomain = protocol + "//api." + hostname + (port? ":3003" : "");
const consoleDomain = protocol + "//console." + hostname + (port? ":5990" : "");

acSignInButton?.classList.add('is-loading');

const response = await fetch(apiDomain + "/api/v1/user", {
method: "GET",
credentials: "include",
headers: {
"X-Csrf-Token": getCookie("_csrf"),
"X-Requested-With": "xmlhttprequest"
}
})

if(response.status === 200) {
// user is logged in
// show console link
acSignInButton?.firstElementChild.innerHTML = "CONSOLE"
acSignInButton?.href = consoleDomain
}
} catch(error) {
console.log("Failed to fetch user", error)
}
// remove the loader
acSignInButton?.classList.remove('is-loading');
// append beta tag
acSignInButton?.appendChild(betaSpan);
}

window.addEventListener('load', function() {
jQuery('a:contains("KubeDB")').click(function() {
gtag('event', 'conversion', {
'send_to': 'AW-10933819571/j5J-CL2sweQDELOx090o'
});
})


// fetch if user is logged in or not
fetchUser();
});
</script>
<!-- console beta tag end -->

</body>

</html>

0 comments on commit a0dbeea

Please sign in to comment.