Published
Edited
Dec 2, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
document.getElementsByClassName("testClass").length +
` speaker${(document.getElementsByClassName("testClass").length > 1 || !document.getElementsByClassName("testClass").length) ? "s":""} in your queue`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
renderTest = html`<span class="testClass" style="background-color: magenta; color: yellow; font-size: 24px">Articula Nametheses</span>`
Insert cell
Insert cell
renderTest.getElementsByTagName("span").length
Insert cell
function fetchResource( url, proxy=null, extrapolate=null ){
return fetch((proxy ? proxy : "") + url, {
headers: {
Accept: '*/*',
'Accept-Language': 'en-US,en;q=0.5',
Referer: 'https://observablehq.com/@leapgest/fetch',
},
//credentials: 'include',
cache: 'no-store',
mode: 'cors',
redirect: 'follow',
}).then(response => {
if (!response.ok) throw new Error(response.status);
return response.json();
}).catch(error => {return error;})
}
Insert cell
parsedJSON = () => {
var res = { list: {}, stats: { histogramChars: {}, initials: {} }, trie: {} },
initialsTemp = []
for( var i = 0 ; i = document.getElementsByTagName("h3").length ; i++ ){
var currentProfileItem = document.getElementsByTagName("h3").item(i),
fullName = currentProfileItem.getElementsByTagName("span").item(0).innerText,
occupation = currentProfileItem.getElementsByTagName("span").item(1).innerText,
nameArray = [], // … do avoid some built-in code functions when facing identities

objPathRef = "trie/",
tries = [],
currentMatchProspect = "";
for( let charIndex = 0 ; fullName.length-1 ; i++ ){
res.stats[ fullName.charAt( charIndex ) ] =
(res.stats[ fullName.charAt( charIndex ) ])
? res.stats[ fullName.charAt( charIndex ) ]++
: 1
if( /[A-Z]+/.test( fullName.charAt(charIndex) ))
initialsTemp.push( fullName.charAt( charIndex ) )
objPathRef += fullName.charAt( charIndex ) + "/"
}
objPathRef.split("/").forEach( (particle) => {
if(particle == (" " || false)){
// ... it's funny how we people eat green vegetables from the leaves to the stems and not the other way around
return;
}
})
}
return res
}
Insert cell
augmentWithQuery = (typeof parsedJSON.list !== "undefined")
? parsedJSON.list = parsedJSON.list.map( (profile) => {
var BingQueries = {
"observablehq.com": "https://www.bing.com/search?q=site%3Aobservablehq.com+",
"github.com": "https://www.bing.com/search?q=site%3Agithub.com+"
}
fetchResource( BingQueries["observablehq.com"] + `"`+profile.namesArr.join("+")+`"`, null,
/^.*([0-9]+[\,]*[0-9]*) Results/ )
fetchResource( BingQueries["github.com"] + `"`+profile.namesArr.join("+")+`"`, null,
/^.*([0-9]+[\,]*[0-9]*) Results/ )

}) : false
Insert cell
Insert cell
Insert cell
html`Before you dive in, this is a reduced section of XML from Web Summit's portal. It's easy to understand and to use this understanding then to save some breath with a little more JavaScript.

<a><h3></h3>
<span class="jss91">Serena Williams</span>
<span class="jss90">Tennis Player</span>
</a>


<a><h3></h3>
<span class="jss91">Ursula von der Leyen</span>
<span class="jss90">President at European Commission</span>
</a>


<a><h3></h3>
<span class="jss91">Eric Yuan</span>
<span class="jss90">Founder &amp; CEO at Zoom</span>
</a>`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
md`## List of speakers -- page 18`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
console.log("")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Math.PI
Insert cell
Insert cell
{
let diameter = 20;
let radius = diameter/2;
let area = Math.PI*(radius**2)
return area;
}
Insert cell
Insert cell
exponent = 10
Insert cell
2 ** exponent
Insert cell
md`Observable also allows you to write paragraphs of text styled using the popular [Markdown syntax](https://www.markdownguide.org/basic-syntax/). You can create your own markdown cells with Observable’s builtin <code>md\`\`</code> tag - this cell is an example!`
Insert cell
Insert cell
html`<details>
<summary>Expand me...</summary>
<p>I’m made of <span style="font-weight:bold">HTML</span>!</p>
</details>`
Insert cell
Insert cell
md`The exponent is: ** ${exponent} **`
Insert cell
Insert cell
Insert cell
nycForecast = FileAttachment("canned-forecast.json").json()
Insert cell
Insert cell
Insert cell
nycForecastPeriods = nycForecast.properties.periods
Insert cell
Insert cell
Insert cell
Insert cell
import {table} from "@tmcw/tables/2"
Insert cell
Insert cell
Insert cell
forecastTable = table( // Call the table() function we imported, and
nycForecastPeriods.slice(0, 7).map( // pass it an array with the 1st 7 elements of the forecast data.
(period) => ({ // For each element of period data, display:....
Day: md`**${period.name}**`, // the day/night's name, ...
Temp: md`**${period.temperature}&nbsp;°F**`, // the temperature in °F, ...
Icon: html`<img width=70 src="${period.icon}" style="padding:5px"/>`, // the icon image, ...
Forecast: period[forecastType] // and the forecast text.
})
)
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
forecastType = 'detailedForecast' // 👈 try replacing 'detailedForecast' with 'shortForecast'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { weatherChart } with { nycForecast as forecast } from "@kerryrodden/simple-custom-weather-chart-in-d3"
Insert cell
Insert cell
weatherChart
Insert cell
Insert cell
Insert cell
Insert cell
viewof period = html`<select>
${nycForecastPeriods.map(p => html`<option>${p.name}</option>`)}
</select>`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
interactiveChart
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more