Skip to content

Commit

Permalink
Experiment with moving Helpfulness Prompt to bottom of the page (gith…
Browse files Browse the repository at this point in the history
…ub#16448)

* Experiment with moving Helpfulness Prompt to bottom of the page

* Update experiment.js

* Update experiment.js
  • Loading branch information
heiskr committed Nov 17, 2020
1 parent 08880d9 commit 5bd61aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
11 changes: 6 additions & 5 deletions includes/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ <h3 id="in-this-article" class="f5 mb-2"><a class="link-gray-dark" href="#in-thi
{{ 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>
34 changes: 18 additions & 16 deletions javascripts/experiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}

0 comments on commit 5bd61aa

Please sign in to comment.