1
0
mirror of synced 2025-12-23 03:44:00 -05:00

Experiment with moving Helpfulness Prompt to bottom of the page (#16448)

* Experiment with moving Helpfulness Prompt to bottom of the page

* Update experiment.js

* Update experiment.js
This commit is contained in:
Kevin Heis
2020-11-17 14:10:03 -08:00
committed by GitHub
parent 08880d9ecb
commit 5bd61aa4b8
2 changed files with 24 additions and 21 deletions

View File

@@ -69,10 +69,11 @@
{{ renderedPage }}
</div>
</div>
<div class="d-block d-xl-none border-top border-gray-light mt-4 markdown-body">
{% assign helpId = 'sm' %}
{% include helpfulness %}
{% include contribution %}
</div>
</article>
<div class="d-block d-xl-none border-top border-gray-light mt-4 markdown-body">
{% assign helpId = 'sm' %}
{% include helpfulness %}
{% include contribution %}
</div>
</main>

View File

@@ -40,27 +40,29 @@ export default function () {
// const testName = '$test-name$'
// const xbucket = bucket(testName)
// if (xbucket === TREATMENT) { ... }
// x.addEventListener('click', evt => evt.preventDefault(); await sendSuccess(testName); evt())
// x.addEventListener('click', () => { sendSuccess(testName) })
const treatment = document.getElementById('quickstart-treatment')
if (!treatment) return
const testName = 'quickstart-hello'
const testName = 'helpfulness-prompt-to-bottom'
const xbucket = bucket(testName)
if (xbucket === TREATMENT) {
Array.from(
document.querySelectorAll('#article-contents > *')
).forEach(el => { el.hidden = true })
treatment.hidden = false
const bigHelpfulness = document.querySelector('#helpfulness-xl')
const smallHelpfulness = document.querySelector('#helpfulness-sm')
// Check that helpfulness prompt is present on this page
if (!(bigHelpfulness && smallHelpfulness)) {
return
}
// Remove the -xl prompts
bigHelpfulness.parentElement.parentElement.removeChild(bigHelpfulness.parentElement)
// Always show the -sm prompt
smallHelpfulness.parentElement.classList.remove('d-xl-none')
}
document.documentElement.addEventListener('copy', () => {
sendSuccess(testName)
const votes = Array.from(document.querySelectorAll('.js-helpfulness [type=radio]'))
votes.forEach(voteEl => {
voteEl.addEventListener('change', () => { sendSuccess(testName) })
})
// Hide sidebar navigation during test
Array.from(
document.querySelectorAll('.article-grid-toc-content > h3, .article-grid-toc-content ul')
).forEach(el => { el.hidden = true })
}