Skip to content

Commit 5ecc831

Browse files
authored
Merge pull request #69 from topcoder-platform/forums-issue-689
Universal nav integration updates
2 parents 75fe61a + 962e7c8 commit 5ecc831

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

views/partials/header.tpl

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,47 @@
11
<div id="headerNav"></div>
2-
{literal}
3-
<script>
4-
var UNI_NAV_PROD_URL = '//uni-nav.topcoder.com/v1/tc-universal-nav.js';
5-
var UNI_NAV_DEV_URL = '//uni-nav.topcoder-dev.com/v1/tc-universal-nav.js';
6-
7-
var TOPCODER_DOMAIN = 'topcoder.com'
8-
var isProdEnv = window.location.hostname && window.location.hostname.includes(TOPCODER_DOMAIN);
9-
var scriptURL = isProdEnv ? UNI_NAV_PROD_URL : UNI_NAV_DEV_URL;
102

3+
<script>
4+
const signInUrl = '{$SignInUrl}';
5+
const signUpUrl = '{$SignUpUrl}';
6+
const signOutUrl = '{$SignOutUrl}';
7+
{literal}
118
!function(n,t,e,a,c,i,o){n['TcUnivNavConfig']=c,n[c]=n[c]||function(){
129
(n[c].q=n[c].q??[]).push(arguments)},n[c].l=1*new Date();i=t.createElement(e),
1310
o=t.getElementsByTagName(e)[0];i.async=1;i.type="module";i.src=a;o.parentNode.insertBefore(i,o)
14-
}(window,document,"script",scriptURL,"tcUniNav");
15-
16-
var user;
17-
18-
if ('{/literal}{$User.SignedIn}{literal}') {
19-
var photoUrl = '{/literal}{$User.Photo}{literal}' != null ? '{/literal}{$User.Photo}{literal}' : undefined;
20-
var userId = null; // leaving it empty as it's currently not available
21-
var handle = '{/literal}{$User.Name|escape:'html'}{literal}';
22-
var initials = handle ? handle.substr(0, 2).toUpperCase() : '';
23-
24-
user = {
25-
photoUrl,
26-
userId,
27-
initials,
28-
handle
29-
};
30-
}
31-
11+
}(window,document,"script","{/literal}{$UniversalNavUrl}{literal}","tcUniNav");
12+
{/literal}
13+
{if $User.SignedIn}
14+
const handle = '{$User.Name|escape:'html'}';
15+
const initials = handle ? handle.substr(0, 2).toUpperCase() : '';
16+
const userId = {$User.TopcoderUserID};
17+
const photoURL = '{$User.TopcoderPhotoUrl}';
18+
const user = {
19+
photoURL: photoURL,
20+
userId: userId,
21+
initials: initials,
22+
handle: handle,
23+
};
24+
{else}
25+
const user = null;
26+
{/if}
27+
{literal}
3228
tcUniNav('init', 'headerNav', {
3329
type: 'tool',
3430
toolName: 'Discussion',
3531
user,
3632
signIn() {
37-
window.location.href = '/entry/signin?Source=forum';
33+
window.location.replace(signInUrl);
3834
},
3935
signOut() {
40-
var signOutUrl = '/entry/signout';
41-
if (window.gdn && window.gdn.meta && window.gdn.meta.TransientKey) {
42-
signOutUrl += '?TransientKey=' + window.gdn.meta.TransientKey;
43-
}
44-
window.location.href = signOutUrl;
36+
window.location.replace(signOutUrl);
4537
},
4638
signUp() {
47-
window.location.href = '/entry/register?Target=discussions';
39+
window.location.replace(signUpUrl);
4840
}
4941
});
5042
5143
tcUniNav('init', 'footerNav', {
5244
type: 'footer'
5345
});
54-
46+
{/literal}
5547
</script>
56-
{/literal}

0 commit comments

Comments
 (0)