Skip to content

Commit 5bd61aa

Browse files
authored
Experiment with moving Helpfulness Prompt to bottom of the page (github#16448)
* Experiment with moving Helpfulness Prompt to bottom of the page * Update experiment.js * Update experiment.js
1 parent 08880d9 commit 5bd61aa

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

includes/article.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ <h3 id="in-this-article" class="f5 mb-2"><a class="link-gray-dark" href="#in-thi
6969
{{ renderedPage }}
7070
</div>
7171
</div>
72+
73+
<div class="d-block d-xl-none border-top border-gray-light mt-4 markdown-body">
74+
{% assign helpId = 'sm' %}
75+
{% include helpfulness %}
76+
{% include contribution %}
77+
</div>
7278
</article>
73-
<div class="d-block d-xl-none border-top border-gray-light mt-4 markdown-body">
74-
{% assign helpId = 'sm' %}
75-
{% include helpfulness %}
76-
{% include contribution %}
77-
</div>
7879
</main>

javascripts/experiment.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,29 @@ export default function () {
4040
// const testName = '$test-name$'
4141
// const xbucket = bucket(testName)
4242
// if (xbucket === TREATMENT) { ... }
43-
// x.addEventListener('click', evt => evt.preventDefault(); await sendSuccess(testName); evt())
43+
// x.addEventListener('click', () => { sendSuccess(testName) })
4444

45-
const treatment = document.getElementById('quickstart-treatment')
46-
if (!treatment) return
47-
48-
const testName = 'quickstart-hello'
45+
const testName = 'helpfulness-prompt-to-bottom'
4946
const xbucket = bucket(testName)
5047

5148
if (xbucket === TREATMENT) {
52-
Array.from(
53-
document.querySelectorAll('#article-contents > *')
54-
).forEach(el => { el.hidden = true })
55-
treatment.hidden = false
49+
const bigHelpfulness = document.querySelector('#helpfulness-xl')
50+
const smallHelpfulness = document.querySelector('#helpfulness-sm')
51+
52+
// Check that helpfulness prompt is present on this page
53+
if (!(bigHelpfulness && smallHelpfulness)) {
54+
return
55+
}
56+
57+
// Remove the -xl prompts
58+
bigHelpfulness.parentElement.parentElement.removeChild(bigHelpfulness.parentElement)
59+
60+
// Always show the -sm prompt
61+
smallHelpfulness.parentElement.classList.remove('d-xl-none')
5662
}
5763

58-
document.documentElement.addEventListener('copy', () => {
59-
sendSuccess(testName)
64+
const votes = Array.from(document.querySelectorAll('.js-helpfulness [type=radio]'))
65+
votes.forEach(voteEl => {
66+
voteEl.addEventListener('change', () => { sendSuccess(testName) })
6067
})
61-
62-
// Hide sidebar navigation during test
63-
Array.from(
64-
document.querySelectorAll('.article-grid-toc-content > h3, .article-grid-toc-content ul')
65-
).forEach(el => { el.hidden = true })
6668
}

0 commit comments

Comments
 (0)