Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs for updated perspective-viewer #1574

Merged
merged 7 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix docusaurus site
  • Loading branch information
texodus committed Oct 9, 2021
commit 5fb1cb14cf68a59d6d9f997d06e0800057c24c99
30 changes: 24 additions & 6 deletions docs/js/concepts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,29 @@ import perspective from "@finos/perspective";
const worker = perspective.shared_worker();

async function main() {
if (window.location.pathname === "/" || window.location.pathname === "/index.html") {
if (
window.location.pathname === "/" ||
window.location.pathname === "/index.html"
) {
return;
}

const arrow = await fetch("../../arrow/superstore.arrow");
const table = await worker.table(await arrow.arrayBuffer());

const viewers = document.querySelectorAll("perspective-viewer:not(.nosuperstore)");
const viewers = document.querySelectorAll(
"perspective-viewer:not(.nosuperstore)"
);
for (const viewer of viewers) {
viewer.load(table);
const token = {};
for (const attribute of viewer.attributes) {
if (attribute.name !== "settings") {
token[attribute.name] = JSON.parse(attribute.nodeValue);
}
}

viewer.restore(token);
viewer.toggleConfig();
}

Expand All @@ -24,11 +37,14 @@ async function main() {
if (code.classList.contains("language-html")) {
continue;
}
const name = code.classList.contains("language-javascript") ? "Javascript" : "Python";
const name = code.classList.contains("language-javascript")
? "Javascript"
: "Python";
const next = name === "Javascript" ? "Python" : "Javascript";

pre.innerHTML =
`<a class="toggle-language" href="#" title="Toggle to ${next}">${ICON} <span class="language">${name}</span> <span class="next">${ARROW_ICON} ${next}</span></a>` + pre.innerHTML;
`<a class="toggle-language" href="#" title="Toggle to ${next}">${ICON} <span class="language">${name}</span> <span class="next">${ARROW_ICON} ${next}</span></a>` +
pre.innerHTML;
if (name !== state) {
pre.style.display = "none";
} else {
Expand All @@ -37,7 +53,7 @@ async function main() {
}

for (const link of document.querySelectorAll("pre a")) {
link.addEventListener("click", event => {
link.addEventListener("click", (event) => {
event.preventDefault();
state = state === "Python" ? "Javascript" : "Python";
localStorage.setItem("lang_pref", state);
Expand All @@ -46,7 +62,9 @@ async function main() {
if (!code || code.classList.contains("language-html")) {
continue;
}
const name = code.classList.contains("language-javascript") ? "Javascript" : "Python";
const name = code.classList.contains("language-javascript")
? "Javascript"
: "Python";
if (name !== state) {
pre.style.display = "none";
} else if (name !== "html") {
Expand Down
3 changes: 3 additions & 0 deletions docs/js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import perspective from "@finos/perspective";

perspective.shared_worker();

import "@finos/perspective-viewer";
import "@finos/perspective-viewer-datagrid";
import "@finos/perspective-viewer-d3fc";
Expand Down
Loading