Show More
@@ -71,12 +71,10 b' var IPython = (function (IPython) {' | |||||
71 | reader.readAsText(f); |
|
71 | reader.readAsText(f); | |
72 | var fname = f.name.split('.'); |
|
72 | var fname = f.name.split('.'); | |
73 | var nbname = fname.slice(0,-1).join('.'); |
|
73 | var nbname = fname.slice(0,-1).join('.'); | |
74 |
var |
|
74 | var file_ext = fname.slice(-1)[0]; | |
75 |
if ( |
|
75 | if (file_ext === 'ipynb') { | |
76 | if (nbformat === 'py' || nbformat === 'json') { |
|
|||
77 | var item = that.new_notebook_item(0); |
|
76 | var item = that.new_notebook_item(0); | |
78 | that.add_name_input(nbname, item); |
|
77 | that.add_name_input(nbname, item); | |
79 | item.data('nbformat', nbformat); |
|
|||
80 | // Store the notebook item in the reader so we can use it later |
|
78 | // Store the notebook item in the reader so we can use it later | |
81 | // to know which item it belongs to. |
|
79 | // to know which item it belongs to. | |
82 | $(reader).data('item', item); |
|
80 | $(reader).data('item', item); | |
@@ -85,6 +83,13 b' var IPython = (function (IPython) {' | |||||
85 | that.add_notebook_data(event.target.result, nbitem); |
|
83 | that.add_notebook_data(event.target.result, nbitem); | |
86 | that.add_upload_button(nbitem); |
|
84 | that.add_upload_button(nbitem); | |
87 | }; |
|
85 | }; | |
|
86 | } else { | |||
|
87 | var dialog = 'Uploaded notebooks must be .ipynb files'; | |||
|
88 | IPython.dialog.modal({ | |||
|
89 | title : 'Invalid file type', | |||
|
90 | body : dialog, | |||
|
91 | buttons : {'OK' : {'class' : 'btn-primary'}} | |||
|
92 | }); | |||
88 | } |
|
93 | } | |
89 | } |
|
94 | } | |
90 | return false; |
|
95 | return false; | |
@@ -313,14 +318,8 b' var IPython = (function (IPython) {' | |||||
313 | .addClass('btn btn-primary btn-mini upload_button') |
|
318 | .addClass('btn btn-primary btn-mini upload_button') | |
314 | .click(function (e) { |
|
319 | .click(function (e) { | |
315 | var nbname = item.find('.item_name > input').val(); |
|
320 | var nbname = item.find('.item_name > input').val(); | |
316 | var nbformat = item.data('nbformat'); |
|
|||
317 | var nbdata = item.data('nbdata'); |
|
321 | var nbdata = item.data('nbdata'); | |
318 | var content_type = 'application/json'; |
|
322 | var content_type = 'application/json'; | |
319 | if (nbformat === 'json') { |
|
|||
320 | // pass |
|
|||
321 | } else if (nbformat === 'py') { |
|
|||
322 | // TODO: re-enable non-ipynb upload |
|
|||
323 | } |
|
|||
324 | var model = { |
|
323 | var model = { | |
325 | content : JSON.parse(nbdata), |
|
324 | content : JSON.parse(nbdata), | |
326 | }; |
|
325 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now