|
| 1 | +document.addEventListener('DOMContentLoaded', function () { |
| 2 | + // Yelp dataset |
| 3 | + var yelpDatasetAgreementElement = document.getElementById('yelp-dataset-agreement') |
| 4 | + var yelpCreateSandboxLinkElement = document.getElementById('yelp-create-sandbox-link') |
| 5 | + |
| 6 | + if (yelpDatasetAgreementElement && yelpCreateSandboxLinkElement) { |
| 7 | + var neo4jYelpAgreement = '' |
| 8 | + if (typeof window.localStorage !== 'undefined' && typeof window.localStorage.getItem === 'function') { |
| 9 | + neo4jYelpAgreement = window.localStorage.getItem('neo4j.yelp-agreement') |
| 10 | + } |
| 11 | + if (neo4jYelpAgreement === 'read-agreed') { |
| 12 | + yelpDatasetAgreementElement.style.display = 'none' |
| 13 | + } else { |
| 14 | + var originalHref = yelpCreateSandboxLinkElement.getAttribute('href') |
| 15 | + yelpCreateSandboxLinkElement.setAttribute('href', 'javascript:void(0)') |
| 16 | + yelpCreateSandboxLinkElement.setAttribute('target', '_self') |
| 17 | + yelpCreateSandboxLinkElement.classList.remove('external') |
| 18 | + var focusAgreementElementEvent = function () { |
| 19 | + var top = yelpDatasetAgreementElement.getBoundingClientRect().top + window.pageYOffset - 140 |
| 20 | + window.scrollTo({ top: top, behavior: 'smooth' }) |
| 21 | + yelpDatasetAgreementElement.classList.add('has-focus') |
| 22 | + setTimeout(function () { |
| 23 | + yelpDatasetAgreementElement.classList.remove('has-focus') |
| 24 | + }, 2000) |
| 25 | + } |
| 26 | + yelpCreateSandboxLinkElement.addEventListener('click', focusAgreementElementEvent) |
| 27 | + // checkbox |
| 28 | + var yelpDatasetAgreementInputCheckboxElement = document.createElement('input') |
| 29 | + yelpDatasetAgreementInputCheckboxElement.type = 'checkbox' |
| 30 | + yelpDatasetAgreementInputCheckboxElement.id = 'yelp-dataset-agreement-check' |
| 31 | + // label |
| 32 | + var yelpDatasetAgreementLabelElement = document.createElement('label') |
| 33 | + yelpDatasetAgreementLabelElement.innerHTML = ' I have read and agree to the Dataset License' |
| 34 | + yelpDatasetAgreementLabelElement.setAttribute('for', 'yelp-dataset-agreement-check') |
| 35 | + // accept button |
| 36 | + var continueButtonElement = document.createElement('button') |
| 37 | + continueButtonElement.type = 'button' |
| 38 | + continueButtonElement.classList.add('button') |
| 39 | + continueButtonElement.innerText = 'Continue' |
| 40 | + continueButtonElement.addEventListener('click', function (_) { |
| 41 | + if (yelpDatasetAgreementInputCheckboxElement.checked) { |
| 42 | + if (typeof window.localStorage !== 'undefined' && typeof window.localStorage.setItem === 'function') { |
| 43 | + window.localStorage.setItem('neo4j.yelp-agreement', 'read-agreed') |
| 44 | + } |
| 45 | + yelpCreateSandboxLinkElement.removeEventListener('click', focusAgreementElementEvent) |
| 46 | + yelpCreateSandboxLinkElement.setAttribute('target', '_blank') |
| 47 | + yelpCreateSandboxLinkElement.setAttribute('href', originalHref) |
| 48 | + yelpCreateSandboxLinkElement.classList.add('external') |
| 49 | + yelpDatasetAgreementElement.style.display = 'none' |
| 50 | + } |
| 51 | + }) |
| 52 | + var paragraphElement = document.createElement('p') |
| 53 | + paragraphElement.appendChild(yelpDatasetAgreementInputCheckboxElement) |
| 54 | + paragraphElement.appendChild(yelpDatasetAgreementLabelElement) |
| 55 | + paragraphElement.appendChild(continueButtonElement) |
| 56 | + yelpDatasetAgreementElement.appendChild(paragraphElement) |
| 57 | + } |
| 58 | + } |
| 59 | +}) |
0 commit comments