Skip to content

Commit b6fdae9

Browse files
Merge pull request #30836 from vikram-redhat/addreferrer
added referrer for disclaimer
2 parents 6a71491 + f7d6451 commit b6fdae9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

_javascripts/page-loader.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ function selectVersion(currentVersion) {
5959
el.value = currentVersion;
6060
}
6161

62+
// check the docs referrer to add warning box based on whether we are coming from rosa docs or elsewhere
63+
addReferrer();
64+
6265
// the rest creates an suggest an edit element for h1 and h2 elements
6366

6467
// only enabled at the moment on the 3.11 docs
@@ -145,3 +148,33 @@ function selectVersion(currentVersion) {
145148
}
146149
}
147150
}
151+
152+
function addReferrer() {
153+
154+
// grab target element reference
155+
156+
// we want to add a notice to the top of the OCP docs page if the reader is coming from ROSA docs
157+
158+
// check the referrer
159+
// alert(document.referrer);
160+
161+
// var ref = "http://127.0.0.1/addreferrer";
162+
// var ref = "http://127.0.0.1/addreferrer/authentication/understanding-authentication.html";
163+
164+
var ref = "https://docs.openshift.com/rosa";
165+
166+
if(document.referrer && document.referrer.startsWith(ref) && !document.location.href.startsWith(ref)) {
167+
168+
// get the first section/header
169+
var elements = document.getElementsByClassName('sect1');
170+
var requiredElement = elements[0];
171+
172+
// the warning text
173+
var text = '<div class="admonitionblock important"><table><tbody><tr><td class="icon"><i class="fa icon-important" title="Important"></i></td><td class="content"><div class="paragraph"><p>This is the <b>OpenShift Container Platform</b> documentation. There may be some sections that don\'t apply to ROSA docs.</p><p>Click <a href="' + document.referrer + '">here</a> to go back to the page you came from or browse the full <a href="https://docs.openshift.com/rosa/welcome/index.html">ROSA documentation</a>.</p></div></td></tr></tbody></table></div>';
174+
175+
// insert the element before target element
176+
requiredElement.insertAdjacentHTML("beforebegin", text);
177+
}
178+
179+
180+
}

0 commit comments

Comments
 (0)