First time here? Check out the FAQ!

Ask Your Question
0

Auto Activating Sage Cell

asked 9 years ago

collabmath gravatar image

I'm trying to embed a small sage cell/program into my webpage. However, the cell only activates when the user presses a activation button. I would like the cell to show up automatically on the page so the user does not have to press the activate button and then enter the values in for the program. I don't know how I could do this. Is their any way to auto-press a button that is created by a script? Is their any way for just the cell to show up like in Mathematica interactives?

Here is the source code:

<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Sage Cell Server</title>
    <script src="https://sagecell.sagemath.org/static/jquery.min.js"></script>
    <script src="https://sagecell.sagemath.org/static/embedded_sagecell.js"></script>



    <script>$(function () {
    // Make the div with id 'mycell' a Sage cell
    sagecell.makeSagecell({inputLocation:  '#mycell',
                           template:       sagecell.templates.minimal,
                           evalButtonText: 'Activate'});
                           hide: ['evalButton']
    // Make *any* div with class 'compute' a Sage cell

    });
    </script>
  </head>
  <body>


  <h2>Factorial</h2>
  Click the “Activate” button below to calculate factorials.
    <div id="mycell">
@interact
def _(a=(1, 10)):
    print factorial(a)
 </script>
</div>


  </body>
</html>

Here is the html for the button generated:

<button type="button" class="sagecell_evalButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Activate</span></button>

Here is the page after the button has been pressed (with the cell):enter image description here

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

kcrisman gravatar image

I hope that this link answers all your questions about this! This is certainly part of the design and possibility of the Sage cell server.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 9 years ago

Seen: 614 times

Last updated: Aug 14 '15