Show More
@@ -70,11 +70,10 b' var IPython = (function (IPython) {' | |||||
70 | var reader = new FileReader(); |
|
70 | var reader = new FileReader(); | |
71 | reader.readAsText(f); |
|
71 | reader.readAsText(f); | |
72 | var name_and_ext = utils.splitext(f.name); |
|
72 | var name_and_ext = utils.splitext(f.name); | |
73 | var nbname = name_and_ext[0]; |
|
|||
74 | var file_ext = name_and_ext[1]; |
|
73 | var file_ext = name_and_ext[1]; | |
75 | if (file_ext === '.ipynb') { |
|
74 | if (file_ext === '.ipynb') { | |
76 | var item = that.new_notebook_item(0); |
|
75 | var item = that.new_notebook_item(0); | |
77 |
that.add_name_input( |
|
76 | that.add_name_input(f.name, item); | |
78 | // Store the notebook item in the reader so we can use it later |
|
77 | // Store the notebook item in the reader so we can use it later | |
79 | // to know which item it belongs to. |
|
78 | // to know which item it belongs to. | |
80 | $(reader).data('item', item); |
|
79 | $(reader).data('item', item); | |
@@ -171,10 +170,10 b' var IPython = (function (IPython) {' | |||||
171 | var len = data.length; |
|
170 | var len = data.length; | |
172 | this.clear_list(); |
|
171 | this.clear_list(); | |
173 | if (len === 0) { |
|
172 | if (len === 0) { | |
174 |
|
|
173 | item = this.new_notebook_item(0); | |
175 | var span12 = item.children().first(); |
|
174 | var span12 = item.children().first(); | |
176 | span12.empty(); |
|
175 | span12.empty(); | |
177 | span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message)) |
|
176 | span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message)); | |
178 | } |
|
177 | } | |
179 | var path = this.notebookPath(); |
|
178 | var path = this.notebookPath(); | |
180 | var offset = 0; |
|
179 | var offset = 0; | |
@@ -190,9 +189,8 b' var IPython = (function (IPython) {' | |||||
190 | this.add_dir(path, name, item); |
|
189 | this.add_dir(path, name, item); | |
191 | } else { |
|
190 | } else { | |
192 | var name = data[i].name; |
|
191 | var name = data[i].name; | |
193 | var nbname = utils.splitext(name)[0]; |
|
|||
194 | item = this.new_notebook_item(i+offset); |
|
192 | item = this.new_notebook_item(i+offset); | |
195 |
this.add_link(path, |
|
193 | this.add_link(path, name, item); | |
196 | name = utils.url_path_join(path, name); |
|
194 | name = utils.url_path_join(path, name); | |
197 | if(this.sessions[name] === undefined){ |
|
195 | if(this.sessions[name] === undefined){ | |
198 | this.add_delete_button(item); |
|
196 | this.add_delete_button(item); | |
@@ -247,7 +245,7 b' var IPython = (function (IPython) {' | |||||
247 | NotebookList.prototype.add_link = function (path, nbname, item) { |
|
245 | NotebookList.prototype.add_link = function (path, nbname, item) { | |
248 | item.data('nbname', nbname); |
|
246 | item.data('nbname', nbname); | |
249 | item.data('path', path); |
|
247 | item.data('path', path); | |
250 |
item.find(".item_name").text(nbname |
|
248 | item.find(".item_name").text(nbname); | |
251 | item.find(".item_icon").addClass('icon-book'); |
|
249 | item.find(".item_icon").addClass('icon-book'); | |
252 | item.find("a.item_link") |
|
250 | item.find("a.item_link") | |
253 | .attr('href', |
|
251 | .attr('href', | |
@@ -255,7 +253,7 b' var IPython = (function (IPython) {' | |||||
255 | this.baseProjectUrl(), |
|
253 | this.baseProjectUrl(), | |
256 | "notebooks", |
|
254 | "notebooks", | |
257 | path, |
|
255 | path, | |
258 |
nbname |
|
256 | nbname | |
259 | ) |
|
257 | ) | |
260 | ).attr('target','_blank'); |
|
258 | ).attr('target','_blank'); | |
261 | }; |
|
259 | }; | |
@@ -267,7 +265,7 b' var IPython = (function (IPython) {' | |||||
267 | item.find(".item_name").empty().append( |
|
265 | item.find(".item_name").empty().append( | |
268 | $('<input/>') |
|
266 | $('<input/>') | |
269 | .addClass("nbname_input") |
|
267 | .addClass("nbname_input") | |
270 | .attr('value', nbname) |
|
268 | .attr('value', utils.splitext(nbname)[0]) | |
271 | .attr('size', '30') |
|
269 | .attr('size', '30') | |
272 | .attr('type', 'text') |
|
270 | .attr('type', 'text') | |
273 | ); |
|
271 | ); | |
@@ -336,7 +334,7 b' var IPython = (function (IPython) {' | |||||
336 | notebooklist.baseProjectUrl(), |
|
334 | notebooklist.baseProjectUrl(), | |
337 | 'api/notebooks', |
|
335 | 'api/notebooks', | |
338 | notebooklist.notebookPath(), |
|
336 | notebooklist.notebookPath(), | |
339 |
nbname |
|
337 | nbname | |
340 | ); |
|
338 | ); | |
341 | $.ajax(url, settings); |
|
339 | $.ajax(url, settings); | |
342 | } |
|
340 | } | |
@@ -356,6 +354,9 b' var IPython = (function (IPython) {' | |||||
356 | .addClass('btn btn-primary btn-mini upload_button') |
|
354 | .addClass('btn btn-primary btn-mini upload_button') | |
357 | .click(function (e) { |
|
355 | .click(function (e) { | |
358 | var nbname = item.find('.item_name > input').val(); |
|
356 | var nbname = item.find('.item_name > input').val(); | |
|
357 | if (nbname.slice(nbname.length-6, nbname.length) != ".ipynb") { | |||
|
358 | nbname = nbname + ".ipynb"; | |||
|
359 | } | |||
359 | var path = that.notebookPath(); |
|
360 | var path = that.notebookPath(); | |
360 | var nbdata = item.data('nbdata'); |
|
361 | var nbdata = item.data('nbdata'); | |
361 | var content_type = 'application/json'; |
|
362 | var content_type = 'application/json'; | |
@@ -382,7 +383,7 b' var IPython = (function (IPython) {' | |||||
382 | that.baseProjectUrl(), |
|
383 | that.baseProjectUrl(), | |
383 | 'api/notebooks', |
|
384 | 'api/notebooks', | |
384 | that.notebookPath(), |
|
385 | that.notebookPath(), | |
385 |
nbname |
|
386 | nbname | |
386 | ); |
|
387 | ); | |
387 | $.ajax(url, settings); |
|
388 | $.ajax(url, settings); | |
388 | return false; |
|
389 | return false; |
General Comments 0
You need to be logged in to leave comments.
Login now