Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168742
Image: ubuntu2004
def pop_cell_setup(): html('''<script> var cell_delete_callback = function (status, response_text) { if (status == "failure") { return; } var X = response_text.split(SEP); if (X[0] == 'ignore') { return; /* do not delete, for some reason */ } var cell = get_element('cell_outer_' + X[1]); jQuery(cell).remove(); //var worksheet = get_element('worksheet_cell_list'); //worksheet.removeChild(cell); cell_id_list = delete_from_array(cell_id_list, X[1]); if (in_slide_mode) { current_cell = -1; slide_mode(); } } var pop_cell_js = function (id) { if (jQuery('#cell_placeholder_' + id).length) { return; } var curr = jQuery('#cell_outer_' + id); var wid = Math.floor(curr.width() * 0.9) + 'px'; var phdr = jQuery('<div id="cell_placeholder_' + id + '"></div>'); curr.before(phdr); curr.dialog({ buttons: { 'bars': function (ev) { var cont = jQuery(this).parents('.ui-dialog').children('.ui-dialog-container'); if (cont.css('overflow') === 'auto') { cont.css('overflow', 'hidden'); jQuery(ev.target).text('bars'); curr.trigger('resize'); } else { cont.css('overflow', 'auto'); jQuery(ev.target).text('no bars'); curr.trigger('resize'); } }, 'pin': function (ev) { var dial = jQuery(this).parents('.ui-dialog'); if (dial.hasClass('pinned')) { jQuery(window).unbind('scroll.pin'); dial.removeClass('pinned'); jQuery(ev.target).text('pin'); } else { jQuery(window).bind('scroll.pin', function () { var repos = function () { dial.css('top', jQuery(window).scrollTop() + 'px'); }; setTimeout(repos, 500); }); jQuery(window).trigger('scroll.pin'); dial.addClass('pinned'); jQuery(ev.target).text('unpin'); } }, 'close': function (ev) { var kids = jQuery(this).parents('.ui-dialog').children('.ui-dialog-container').children(':gt(0)'); curr.dialog('close'); curr.dialog('destroy'); phdr.before(kids); curr.css({display: '', height: '', minHeight: '', width: ''}); phdr.remove(); }}, height: '300px', width: wid, title: 'cell ' + id }); var dial = curr.parents('.ui-dialog'); dial.css({ backgroundColor: '#eef', padding: '0.5em', border: '1px solid #00f' }); jQuery('.ui-dialog-titlebar', dial).css({ cursor: 'move' }); jQuery('.ui-dialog-buttonpane', dial).css({ position: 'absolute', bottom: '', left: '', top: '0.5em', right: '1.5em' }); jQuery('.ui-dialog-titlebar-close', dial).css({ display: 'none' }); } </script>''') def pop_cell(): id = sage.server.notebook.interact.SAGE_CELL_ID html('<script>pop_cell_js(%d)</script>' % id) def update_interact_cell(id): html('''<script>jQuery('input[value="Update"]', '#cell_outer_%d').trigger('click')</script>''' % id) pop_cell_setup()
pop_cell()
pop_cell() factorial(42)
pop_cell() ordered_partitions(9,3)
pop_cell() warp = 1 @interact def _(a = slider(1, 4, default=2, label='Multiplier'), b = slider(0, 10, default=0, label='Phase Variable'), auto_update=False): show(plot(sin(a*(x^warp)+b), (x,0,6)), figsize=4)
warp = 2 update_interact_cell(5)