##// END OF EJS Templates
holy crap, semicolons
MinRK -
Show More
@@ -145,7 +145,7 b' var IPython = (function (IPython) {'
145 145 };
146 146
147 147 this.element.bind('collapse_pager', function (event, extrap) {
148 var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
148 var time = (extrap !== undefined) ? ((extrap.duration !== undefined ) ? extrap.duration : 'fast') : 'fast';
149 149 collapse_time(time);
150 150 });
151 151
@@ -158,7 +158,7 b' var IPython = (function (IPython) {'
158 158 };
159 159
160 160 this.element.bind('expand_pager', function (event, extrap) {
161 var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
161 var time = (extrap !== undefined) ? ((extrap.duration !== undefined ) ? extrap.duration : 'fast') : 'fast';
162 162 expand_time(time);
163 163 });
164 164
@@ -187,7 +187,7 b' var IPython = (function (IPython) {'
187 187 } else {
188 188 return "Unsaved changes will be lost.";
189 189 }
190 };
190 }
191 191 // Null is the *only* return value that will make the browser not
192 192 // pop up the "don't leave" dialog.
193 193 return null;
@@ -219,7 +219,7 b' var IPython = (function (IPython) {'
219 219 */
220 220 Notebook.prototype.scroll_to_cell = function (cell_number, time) {
221 221 var cells = this.get_cells();
222 var time = time || 0;
222 time = time || 0;
223 223 cell_number = Math.min(cells.length-1,cell_number);
224 224 cell_number = Math.max(0 ,cell_number);
225 225 var scroll_value = cells[cell_number].element.position().top-cells[0].element.position().top ;
@@ -331,7 +331,7 b' var IPython = (function (IPython) {'
331 331 result = ce.data('cell');
332 332 }
333 333 return result;
334 }
334 };
335 335
336 336 /**
337 337 * Get the cell below a given cell.
@@ -347,7 +347,7 b' var IPython = (function (IPython) {'
347 347 result = this.get_cell(index+1);
348 348 }
349 349 return result;
350 }
350 };
351 351
352 352 /**
353 353 * Get the cell above a given cell.
@@ -365,7 +365,7 b' var IPython = (function (IPython) {'
365 365 result = this.get_cell(index-1);
366 366 }
367 367 return result;
368 }
368 };
369 369
370 370 /**
371 371 * Get the numeric index of a given cell.
@@ -379,7 +379,7 b' var IPython = (function (IPython) {'
379 379 this.get_cell_elements().filter(function (index) {
380 380 if ($(this).data("cell") === cell) {
381 381 result = index;
382 };
382 }
383 383 });
384 384 return result;
385 385 };
@@ -426,8 +426,8 b' var IPython = (function (IPython) {'
426 426 return true;
427 427 } else {
428 428 return false;
429 };
430 429 }
430 };
431 431
432 432 /**
433 433 * Get the index of the currently selected cell.
@@ -440,7 +440,7 b' var IPython = (function (IPython) {'
440 440 this.get_cell_elements().filter(function (index) {
441 441 if ($(this).data("cell").selected === true) {
442 442 result = index;
443 };
443 }
444 444 });
445 445 return result;
446 446 };
@@ -457,11 +457,11 b' var IPython = (function (IPython) {'
457 457 */
458 458 Notebook.prototype.select = function (index) {
459 459 if (this.is_valid_cell_index(index)) {
460 var sindex = this.get_selected_index()
460 var sindex = this.get_selected_index();
461 461 if (sindex !== null && index !== sindex) {
462 462 this.command_mode();
463 463 this.get_cell(sindex).unselect();
464 };
464 }
465 465 var cell = this.get_cell(index);
466 466 cell.select();
467 467 if (cell.cell_type === 'heading') {
@@ -472,8 +472,8 b' var IPython = (function (IPython) {'
472 472 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
473 473 {'cell_type':cell.cell_type}
474 474 );
475 };
476 };
475 }
476 }
477 477 return this;
478 478 };
479 479
@@ -509,7 +509,7 b' var IPython = (function (IPython) {'
509 509 this.get_cell_elements().filter(function (index) {
510 510 if ($(this).data("cell").mode === 'edit') {
511 511 result = index;
512 };
512 }
513 513 });
514 514 return result;
515 515 };
@@ -521,10 +521,10 b' var IPython = (function (IPython) {'
521 521 var cell = this.get_cell(index);
522 522 if (cell) {
523 523 cell.command_mode();
524 };
524 }
525 525 this.mode = 'command';
526 526 IPython.keyboard_manager.command_mode();
527 };
527 }
528 528 };
529 529
530 530 Notebook.prototype.edit_mode = function () {
@@ -537,7 +537,7 b' var IPython = (function (IPython) {'
537 537 this.mode = 'edit';
538 538 IPython.keyboard_manager.edit_mode();
539 539 cell.edit_mode();
540 };
540 }
541 541 };
542 542
543 543 Notebook.prototype.focus_cell = function () {
@@ -566,9 +566,9 b' var IPython = (function (IPython) {'
566 566 this.select(i-1);
567 567 var cell = this.get_selected_cell();
568 568 cell.focus_cell();
569 };
569 }
570 570 this.set_dirty(true);
571 };
571 }
572 572 return this;
573 573 };
574 574
@@ -591,8 +591,8 b' var IPython = (function (IPython) {'
591 591 this.select(i+1);
592 592 var cell = this.get_selected_cell();
593 593 cell.focus_cell();
594 };
595 };
594 }
595 }
596 596 this.set_dirty();
597 597 return this;
598 598 };
@@ -632,10 +632,10 b' var IPython = (function (IPython) {'
632 632 this.select(i);
633 633 this.undelete_index = i;
634 634 this.undelete_below = false;
635 };
635 }
636 636 $([IPython.events]).trigger('delete.Cell', {'cell': cell, 'index': i});
637 637 this.set_dirty(true);
638 };
638 }
639 639 return this;
640 640 };
641 641
@@ -673,7 +673,7 b' var IPython = (function (IPython) {'
673 673 this.undelete_index = null;
674 674 }
675 675 $('#undelete_cell').addClass('disabled');
676 }
676 };
677 677
678 678 /**
679 679 * Insert a cell so that after insertion the cell is at given index.
@@ -691,7 +691,7 b' var IPython = (function (IPython) {'
691 691 Notebook.prototype.insert_cell_at_index = function(type, index){
692 692
693 693 var ncells = this.ncells();
694 var index = Math.min(index,ncells);
694 index = Math.min(index,ncells);
695 695 index = Math.max(index,0);
696 696 var cell = null;
697 697
@@ -832,8 +832,8 b' var IPython = (function (IPython) {'
832 832 source_element.remove();
833 833 this.select(i);
834 834 this.set_dirty(true);
835 };
836 };
835 }
836 }
837 837 };
838 838
839 839 /**
@@ -852,7 +852,7 b' var IPython = (function (IPython) {'
852 852 var text = source_cell.get_text();
853 853 if (text === source_cell.placeholder) {
854 854 text = '';
855 };
855 }
856 856 // We must show the editor before setting its contents
857 857 target_cell.unrender();
858 858 target_cell.set_text(text);
@@ -865,8 +865,8 b' var IPython = (function (IPython) {'
865 865 target_cell.render();
866 866 }
867 867 this.set_dirty(true);
868 };
869 };
868 }
869 }
870 870 };
871 871
872 872 /**
@@ -886,7 +886,7 b' var IPython = (function (IPython) {'
886 886 var text = source_cell.get_text();
887 887 if (text === source_cell.placeholder) {
888 888 text = '';
889 };
889 }
890 890 // We must show the editor before setting its contents
891 891 target_cell.unrender();
892 892 target_cell.set_text(text);
@@ -896,8 +896,8 b' var IPython = (function (IPython) {'
896 896 source_element.remove();
897 897 this.select(i);
898 898 this.set_dirty(true);
899 };
900 };
899 }
900 }
901 901 };
902 902
903 903 /**
@@ -921,7 +921,7 b' var IPython = (function (IPython) {'
921 921 var text = source_cell.get_text();
922 922 if (text === source_cell.placeholder) {
923 923 text = '';
924 };
924 }
925 925 // We must show the editor before setting its contents
926 926 target_cell.set_level(level);
927 927 target_cell.unrender();
@@ -934,12 +934,12 b' var IPython = (function (IPython) {'
934 934 if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) {
935 935 target_cell.render();
936 936 }
937 };
937 }
938 938 this.set_dirty(true);
939 939 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
940 940 {'cell_type':'heading',level:level}
941 941 );
942 };
942 }
943 943 };
944 944
945 945
@@ -960,7 +960,7 b' var IPython = (function (IPython) {'
960 960 $('#paste_cell_below').removeClass('disabled')
961 961 .on('click', function () {that.paste_cell_below();});
962 962 this.paste_enabled = true;
963 };
963 }
964 964 };
965 965
966 966 /**
@@ -974,7 +974,7 b' var IPython = (function (IPython) {'
974 974 $('#paste_cell_above').addClass('disabled').off('click');
975 975 $('#paste_cell_below').addClass('disabled').off('click');
976 976 this.paste_enabled = false;
977 };
977 }
978 978 };
979 979
980 980 /**
@@ -985,7 +985,7 b' var IPython = (function (IPython) {'
985 985 Notebook.prototype.cut_cell = function () {
986 986 this.copy_cell();
987 987 this.delete_cell();
988 }
988 };
989 989
990 990 /**
991 991 * Copy a cell.
@@ -1011,7 +1011,7 b' var IPython = (function (IPython) {'
1011 1011 var old_cell = this.get_next_cell(new_cell);
1012 1012 this.delete_cell(this.find_cell_index(old_cell));
1013 1013 this.select(this.find_cell_index(new_cell));
1014 };
1014 }
1015 1015 };
1016 1016
1017 1017 /**
@@ -1025,7 +1025,7 b' var IPython = (function (IPython) {'
1025 1025 var new_cell = this.insert_cell_above(cell_data.cell_type);
1026 1026 new_cell.fromJSON(cell_data);
1027 1027 new_cell.focus_cell();
1028 };
1028 }
1029 1029 };
1030 1030
1031 1031 /**
@@ -1039,7 +1039,7 b' var IPython = (function (IPython) {'
1039 1039 var new_cell = this.insert_cell_below(cell_data.cell_type);
1040 1040 new_cell.fromJSON(cell_data);
1041 1041 new_cell.focus_cell();
1042 };
1042 }
1043 1043 };
1044 1044
1045 1045 // Split/merge
@@ -1070,7 +1070,7 b' var IPython = (function (IPython) {'
1070 1070 new_cell.unrender();
1071 1071 new_cell.set_text(texta);
1072 1072 }
1073 };
1073 }
1074 1074 };
1075 1075
1076 1076 /**
@@ -1104,10 +1104,10 b' var IPython = (function (IPython) {'
1104 1104 // that of the original selected cell;
1105 1105 cell.render();
1106 1106 }
1107 };
1107 }
1108 1108 this.delete_cell(index-1);
1109 1109 this.select(this.find_cell_index(cell));
1110 };
1110 }
1111 1111 };
1112 1112
1113 1113 /**
@@ -1141,10 +1141,10 b' var IPython = (function (IPython) {'
1141 1141 // that of the original selected cell;
1142 1142 cell.render();
1143 1143 }
1144 };
1144 }
1145 1145 this.delete_cell(index+1);
1146 1146 this.select(this.find_cell_index(cell));
1147 };
1147 }
1148 1148 };
1149 1149
1150 1150
@@ -1364,8 +1364,8 b' var IPython = (function (IPython) {'
1364 1364 var cell = this.get_cell(i);
1365 1365 if (cell instanceof IPython.CodeCell) {
1366 1366 cell.set_kernel(this.session.kernel);
1367 };
1368 };
1367 }
1368 }
1369 1369 };
1370 1370
1371 1371 /**
@@ -1406,7 +1406,7 b' var IPython = (function (IPython) {'
1406 1406 this.command_mode();
1407 1407 cell.focus_cell();
1408 1408 this.set_dirty(true);
1409 }
1409 };
1410 1410
1411 1411 /**
1412 1412 * Execute or render cell outputs and insert a new cell below.
@@ -1502,7 +1502,7 b' var IPython = (function (IPython) {'
1502 1502 for (var i=start; i<end; i++) {
1503 1503 this.select(i);
1504 1504 this.execute_cell();
1505 };
1505 }
1506 1506 };
1507 1507
1508 1508 // Persistance and loading
@@ -1537,11 +1537,11 b' var IPython = (function (IPython) {'
1537 1537 */
1538 1538 Notebook.prototype.test_notebook_name = function (nbname) {
1539 1539 nbname = nbname || '';
1540 if (this.notebook_name_blacklist_re.test(nbname) == false && nbname.length>0) {
1540 if (nbname.length>0 && !this.notebook_name_blacklist_re.test(nbname)) {
1541 1541 return true;
1542 1542 } else {
1543 1543 return false;
1544 };
1544 }
1545 1545 };
1546 1546
1547 1547 /**
@@ -1559,7 +1559,7 b' var IPython = (function (IPython) {'
1559 1559 for (i=0; i<ncells; i++) {
1560 1560 // Always delete cell 0 as they get renumbered as they are deleted.
1561 1561 this.delete_cell(0);
1562 };
1562 }
1563 1563 // Save the metadata and name.
1564 1564 this.metadata = content.metadata;
1565 1565 this.notebook_name = data.name;
@@ -1583,8 +1583,8 b' var IPython = (function (IPython) {'
1583 1583
1584 1584 new_cell = this.insert_cell_at_index(cell_data.cell_type, i);
1585 1585 new_cell.fromJSON(cell_data);
1586 };
1587 };
1586 }
1587 }
1588 1588 if (content.worksheets.length > 1) {
1589 1589 IPython.dialog.modal({
1590 1590 title : "Multiple worksheets",
@@ -1612,7 +1612,7 b' var IPython = (function (IPython) {'
1612 1612 var cell_array = new Array(ncells);
1613 1613 for (var i=0; i<ncells; i++) {
1614 1614 cell_array[i] = cells[i].toJSON();
1615 };
1615 }
1616 1616 var data = {
1617 1617 // Only handle 1 worksheet for now.
1618 1618 worksheets : [{
@@ -1648,7 +1648,7 b' var IPython = (function (IPython) {'
1648 1648 } else {
1649 1649 this.autosave_timer = null;
1650 1650 $([IPython.events]).trigger("autosave_disabled.Notebook");
1651 };
1651 }
1652 1652 };
1653 1653
1654 1654 /**
@@ -1707,7 +1707,7 b' var IPython = (function (IPython) {'
1707 1707 if (this._checkpoint_after_save) {
1708 1708 this.create_checkpoint();
1709 1709 this._checkpoint_after_save = false;
1710 };
1710 }
1711 1711 };
1712 1712
1713 1713 /**
@@ -1842,19 +1842,18 b' var IPython = (function (IPython) {'
1842 1842
1843 1843
1844 1844 Notebook.prototype.rename_success = function (json, status, xhr) {
1845 this.notebook_name = json.name;
1846 var name = this.notebook_name;
1845 var name = this.notebook_name = json.name;
1847 1846 var path = json.path;
1848 1847 this.session.rename_notebook(name, path);
1849 1848 $([IPython.events]).trigger('notebook_renamed.Notebook', json);
1850 }
1849 };
1851 1850
1852 1851 Notebook.prototype.rename_error = function (xhr, status, error) {
1853 1852 var that = this;
1854 1853 var dialog = $('<div/>').append(
1855 1854 $("<p/>").addClass("rename-message")
1856 1855 .text('This notebook name already exists.')
1857 )
1856 );
1858 1857 $([IPython.events]).trigger('notebook_rename_failed.Notebook', [xhr, status, error]);
1859 1858 IPython.dialog.modal({
1860 1859 title: "Notebook Rename Error!",
@@ -1878,7 +1877,7 b' var IPython = (function (IPython) {'
1878 1877 that.find('input[type="text"]').focus();
1879 1878 }
1880 1879 });
1881 }
1880 };
1882 1881
1883 1882 /**
1884 1883 * Request a notebook's data from the server.
@@ -1928,7 +1927,7 b' var IPython = (function (IPython) {'
1928 1927 } else {
1929 1928 this.select(0);
1930 1929 this.command_mode();
1931 };
1930 }
1932 1931 this.set_dirty(false);
1933 1932 this.scroll_to_top();
1934 1933 if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) {
@@ -1953,7 +1952,7 b' var IPython = (function (IPython) {'
1953 1952 var this_vs = 'v' + data.nbformat + '.' + this.nbformat_minor;
1954 1953 var msg = "This notebook is version " + orig_vs + ", but we only fully support up to " +
1955 1954 this_vs + ". You can still work with this notebook, but some features " +
1956 "introduced in later notebook versions may not be available."
1955 "introduced in later notebook versions may not be available.";
1957 1956
1958 1957 IPython.dialog.modal({
1959 1958 title : "Newer Notebook",
@@ -1969,7 +1968,7 b' var IPython = (function (IPython) {'
1969 1968
1970 1969 // Create the session after the notebook is completely loaded to prevent
1971 1970 // code execution upon loading, which is a security risk.
1972 if (this.session == null) {
1971 if (this.session === null) {
1973 1972 this.start_session();
1974 1973 }
1975 1974 // load our checkpoint list
@@ -1994,10 +1993,11 b' var IPython = (function (IPython) {'
1994 1993 */
1995 1994 Notebook.prototype.load_notebook_error = function (xhr, status, error) {
1996 1995 $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]);
1996 var msg;
1997 1997 if (xhr.status === 400) {
1998 var msg = error;
1998 msg = error;
1999 1999 } else if (xhr.status === 500) {
2000 var msg = "An unknown error occurred while loading this notebook. " +
2000 msg = "An unknown error occurred while loading this notebook. " +
2001 2001 "This version can load notebook formats " +
2002 2002 "v" + this.nbformat + " or earlier.";
2003 2003 }
@@ -2008,7 +2008,7 b' var IPython = (function (IPython) {'
2008 2008 "OK": {}
2009 2009 }
2010 2010 });
2011 }
2011 };
2012 2012
2013 2013 /********************* checkpoint-related *********************/
2014 2014
@@ -2073,7 +2073,7 b' var IPython = (function (IPython) {'
2073 2073 * @param {jqXHR} xhr jQuery Ajax object
2074 2074 */
2075 2075 Notebook.prototype.list_checkpoints_success = function (data, status, xhr) {
2076 var data = $.parseJSON(data);
2076 data = $.parseJSON(data);
2077 2077 this.checkpoints = data;
2078 2078 if (data.length) {
2079 2079 this.last_checkpoint = data[data.length - 1];
@@ -2124,7 +2124,7 b' var IPython = (function (IPython) {'
2124 2124 * @param {jqXHR} xhr jQuery Ajax object
2125 2125 */
2126 2126 Notebook.prototype.create_checkpoint_success = function (data, status, xhr) {
2127 var data = $.parseJSON(data);
2127 data = $.parseJSON(data);
2128 2128 this.add_checkpoint(data);
2129 2129 $([IPython.events]).trigger('checkpoint_created.Notebook', data);
2130 2130 };
@@ -2143,7 +2143,7 b' var IPython = (function (IPython) {'
2143 2143
2144 2144 Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) {
2145 2145 var that = this;
2146 var checkpoint = checkpoint || this.last_checkpoint;
2146 checkpoint = checkpoint || this.last_checkpoint;
2147 2147 if ( ! checkpoint ) {
2148 2148 console.log("restore dialog, but no checkpoint to restore to!");
2149 2149 return;
@@ -2178,7 +2178,7 b' var IPython = (function (IPython) {'
2178 2178 Cancel : {}
2179 2179 }
2180 2180 });
2181 }
2181 };
2182 2182
2183 2183 /**
2184 2184 * Restore the notebook to a checkpoint state.
General Comments 0
You need to be logged in to leave comments. Login now