Skip to content

Commit 9acec48

Browse files
Merge pull request #101 from Mogztter/yelp-dataset-agreement
Add a Yelp Dataset Agreement component
2 parents 0a9b516 + ba3a647 commit 9acec48

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

Courses/AppliedGraphAlgorithms/adoc/01_Setup.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:experimental:
1616
:imagedir: ../img
1717
:manual: http://neo4j.com/docs/operations-manual/3.5
18+
:uri-yelp-dataset-agreement-pdf: https://s3-media3.fl.yelpcdn.com/assets/srv0/engineering_pages/bea5c1e92bf3/assets/vendor/yelp-dataset-agreement.pdf
1819

1920
To complete this course we will make use of the following tools:
2021

@@ -92,12 +93,16 @@ The rest of the course will follow this structure:
9293
* Learn how to execute the algorithm using Cypher in Neo4j Browser.
9394
* Use the Cypher and updated graph to improve the application in Code Sandbox.
9495

95-
9696
== Exercise
9797

9898
Your exercise for this module is to get all the tools up and running and talking to each other.
9999

100-
. Create a https://sandbox.neo4j.com/?usecase=yelp[Yelp Neo4j Sandbox instance^].
100+
[#yelp-dataset-agreement]
101+
--
102+
Before creating a Yelp Neo4j Sandbox instance, you need to read and agree to the {uri-yelp-dataset-agreement-pdf}[Yelp Dataset License^].
103+
--
104+
105+
. Create a https://sandbox.neo4j.com/?usecase=yelp[Yelp Neo4j Sandbox instance^,id=yelp-create-sandbox-link].
101106
*Note*: You must log in to the Neo4j Sandbox site. This may require you to register with Neo4j.
102107
. In Yelp Sandbox you just created, click the *Open Neo4j Browser* button to open a Neo4j Browser for the Yelp database. You will be using this Neo4j Browser window throughout this course.
103108
. In Neo4j Browser, complete the steps in the first Neo4j Browser Guide (:play applied_graph_algorithms), *Cypher Refresher*.

Courses/_lib/src/course.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,56 @@ document.addEventListener('DOMContentLoaded', function () {
273273
}
274274
})
275275
}
276+
277+
// Yelp dataset
278+
const yelpDatasetAgreementElement = document.getElementById('yelp-dataset-agreement')
279+
const yelpCreateSandboxLinkElement = document.getElementById('yelp-create-sandbox-link')
280+
281+
if (yelpDatasetAgreementElement && yelpCreateSandboxLinkElement) {
282+
const neo4jYelpAgreement = localStorage.getItem('neo4j.yelp-agreement')
283+
if (neo4jYelpAgreement === 'read-agreed') {
284+
yelpDatasetAgreementElement.style.display = 'none'
285+
} else {
286+
const originalHref = yelpCreateSandboxLinkElement.getAttribute('href')
287+
yelpCreateSandboxLinkElement.setAttribute('href', 'javascript:void(0)')
288+
yelpCreateSandboxLinkElement.setAttribute('target', '_self')
289+
const focusAgreementElementEvent = function () {
290+
const top = yelpDatasetAgreementElement.getBoundingClientRect().top + window.pageYOffset - 140
291+
window.scrollTo({ top: top, behavior: 'smooth' })
292+
yelpDatasetAgreementElement.classList.add('has-focus')
293+
setTimeout(function() {
294+
yelpDatasetAgreementElement.classList.remove('has-focus')
295+
}, 2000)
296+
}
297+
yelpCreateSandboxLinkElement.addEventListener('click', focusAgreementElementEvent)
298+
// checkbox
299+
const yelpDatasetAgreementInputCheckboxElement = document.createElement('input')
300+
yelpDatasetAgreementInputCheckboxElement.type = 'checkbox'
301+
yelpDatasetAgreementInputCheckboxElement.id = 'yelp-dataset-agreement-check'
302+
// label
303+
const yelpDatasetAgreementLabelElement = document.createElement('label')
304+
yelpDatasetAgreementLabelElement.innerHTML = ' I have read and agree to the Dataset License'
305+
yelpDatasetAgreementLabelElement.setAttribute('for', 'yelp-dataset-agreement-check')
306+
// accept button
307+
const continueButtonElement = document.createElement('button')
308+
continueButtonElement.type = 'button'
309+
continueButtonElement.innerText = 'Continue'
310+
continueButtonElement.addEventListener('click', function (_) {
311+
if (yelpDatasetAgreementInputCheckboxElement.checked) {
312+
localStorage.setItem('neo4j.yelp-agreement', 'read-agreed')
313+
yelpCreateSandboxLinkElement.removeEventListener('click', focusAgreementElementEvent)
314+
yelpCreateSandboxLinkElement.setAttribute('target', '_blank')
315+
yelpCreateSandboxLinkElement.setAttribute('href', originalHref)
316+
yelpDatasetAgreementElement.style.display = 'none'
317+
}
318+
})
319+
const paragraphElement = document.createElement('p')
320+
paragraphElement.appendChild(yelpDatasetAgreementInputCheckboxElement)
321+
paragraphElement.appendChild(yelpDatasetAgreementLabelElement)
322+
paragraphElement.appendChild(continueButtonElement)
323+
yelpDatasetAgreementElement.appendChild(paragraphElement)
324+
}
325+
}
276326
})
277327

278328
//
@@ -326,7 +376,7 @@ $(document).ready(function () {
326376
if (CodeMirror.colorize) {
327377
CodeMirror.colorize(document.body.getElementsByTagName("pre"), 'cypher');
328378
}
329-
Intercom('trackEvent', 'PAGE_VIEW', {course: window.trainingClassName, module: trainingPartIndex })
379+
Intercom('trackEvent', 'PAGE_VIEW', { course: window.trainingClassName, module: trainingPartIndex })
330380
})
331381

332382
// Intercom

Courses/_templates/course/document.html.erb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@
2929
display: none;
3030
}
3131
}
32+
#yelp-dataset-agreement {
33+
padding: 0.75em;
34+
border: 1px solid #E0E0E0;
35+
margin-bottom: 1em;
36+
margin-right: 1em;
37+
}
38+
#yelp-dataset-agreement p {
39+
padding: 0;
40+
margin: 0;
41+
}
42+
#yelp-dataset-agreement .paragraph {
43+
padding-bottom: 1em;
44+
}
45+
#yelp-dataset-agreement button {
46+
display: block;
47+
}
48+
#yelp-dataset-agreement.has-focus {
49+
background: white;
50+
animation: highlight 1.5s ease;
51+
}
52+
@keyframes highlight {
53+
0% { background: aliceblue; }
54+
100% { background: white; }
55+
}
3256
</style>
3357
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" type="text/javascript"></script>
3458
<link rel="shortcut icon" href="https://neo4j.com/wp-content/themes/neo4jweb/favicon.ico"></link>

0 commit comments

Comments
 (0)