Git Product home page Git Product logo

Comments (1)

hpssjellis avatar hpssjellis commented on July 30, 2024

Found the answer at https://reference.wolfram.com/language/WolframNotebookEmbedder/examples/

This issue can close.

Here is my working code saved as demo.html

<script crossorigin src="https://unpkg.com/[email protected]"></script>

<p>
    Enter the URL of a cloud object:
    <input id="path" style="width:300px" value="https://www.wolframcloud.com/obj/jpoeschko/Public/Example.nb" />
    <button onclick="embedNotebook()">Embed Notebook</button>
</p>
<p>
    If the notebook's last cell contains a <code>Manipulate</code> with a variable <code>x</code>, this will reset it to 0:
    <button onclick="resetX()">Reset <code>x</code></button>
</p>
<div id="container"></div>

<script>
let embedding = null;

function embedNotebook() {
    const url = document.getElementById('path').value;
    embedding = WolframNotebookEmbedder.embed(url, document.getElementById('container'), {allowInteract: true});
}

function resetX() {
    if (embedding) {
        embedding.then(nb => {
            nb.getCells().then(({cells}) => {
                if (cells) {
                    const lastCell = cells[cells.length - 1];
                    return nb.setDynamicModuleVariable({
                        cellId: lastCell.id,
                        name: 'x$$',
                        value: 0
                    });
                }
            })
        })
    }
}
</script>

from wolfram-notebook-embedder.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.