Ask Your Question
0

Auto Activating Sage Cell

asked 2015-08-01 00:02:28 +0100

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

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2015-08-14 16:00:24 +0100

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.

edit flag offensive delete link more

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: 2015-08-01 00:02:28 +0100

Seen: 566 times

Last updated: Aug 14 '15