Skip to content

Commit ddcd780

Browse files
committed
add style
1 parent 8aed994 commit ddcd780

2 files changed

Lines changed: 86 additions & 36 deletions

File tree

notebookjs/src/public/javascripts/index.js

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,30 @@ $("#div-1")
4141

4242

4343

44+
// function clear_cell() {
45+
// document.getElementById("log-container").style.display = "none"
46+
// $(`#log`).html("")
47+
48+
49+
// }
4450

4551
function exec_cell(c_id) {
52+
// document.getElementById("log-container").style.display = "block"
4653
let id = c_id.split("_")[1]
4754
let count = c_id.split("-")[1]
4855
window.current_cell = id;
49-
5056
$(`#out_${id}`).html("")
57+
// console.log(id);
58+
// logger(`log-${id.split("-")[1]}`, `log_container-${id.split("-")[1]}`, true)
59+
60+
61+
// let command = vars_in_scope[id].getValue()
62+
// console.log(command);
63+
// logger(`log-container-${id.split("-")[1]}`, `log-${id.split("-")[1]}`)
5164

5265
try {
5366
let output = ("global", eval)(vars_in_scope[id].getValue())
67+
5468
if (Array.isArray(output)) {
5569
output = print_val(output)
5670
} else if (typeof output === 'object' && output !== null) {
@@ -59,7 +73,7 @@ function exec_cell(c_id) {
5973
output = ""
6074
}
6175
} else if (console) {
62-
//retreive value from the console funcction
76+
// retreive value from the console funcction
6377
console.oldLog = console.log;
6478
console.log = function (value) {
6579
return value;
@@ -81,10 +95,11 @@ function exec_cell(c_id) {
8195

8296
// $(`#out_${id}`).empty()
8397
let command = vars_in_scope[id].getValue()
84-
if (command.includes("table") || command.includes("plot") || command.includes("console.log(")){
85-
// $(`#out_${id}`).html("")
86-
$(`#out_${id}`).html(output);
87-
}
98+
// console.log(command);
99+
if (command.includes("table") || command.includes("plot") || command.includes("console.log(")) {
100+
$(`#out_${id}`).html("")
101+
$(`#out_${id}`).html(output);
102+
}
88103
// document.getElementById("cell_spinner-1").style.display = "none"
89104
// document.getElementById("cell_num-1").style.display = "block"
90105

@@ -152,6 +167,9 @@ function add_new_code_cell(c_id, where) {
152167
</div>
153168
<div class="col-md-2"></div>
154169
<div class="col-md-1"></div>
170+
<div id="log_container-${new_id}" class="col-md-9 out-divs">
171+
<pre id="log-${new_id}"></pre>
172+
</div>
155173
<div id="out_div-${new_id}" class="col-md-9 out-divs">
156174
157175
</div>
@@ -381,13 +399,11 @@ function update_text_box_size() {
381399
$("#download").click(function () {
382400
let out = notebook_json(cells_order, vars_in_scope, md_texts);
383401

384-
let blob = new Blob([out], { "type": "application/json" });
385-
let url = (window.URL || window.webkitURL).createObjectURL(blob);
402+
var blob = new Blob([out], { "type": "application/json" });
403+
var url = (window.URL || window.webkitURL).createObjectURL(blob);
386404

387-
let link = document.createElement('a');
388-
let text = $("#notebookname").text()
389-
let name = text.length > 0 ? `${text}.json` : "Dnotebook.json"
390-
link.download = name;
405+
var link = document.createElement('a');
406+
link.download = 'danfo_notebook.json';
391407
link.href = url;
392408

393409
var link_pae = $(link);
@@ -438,22 +454,45 @@ $("#import-notebook-file").change(() => {
438454
// })
439455

440456

457+
// rewireLoggingToElement(
458+
// () => document.getElementById("log"),
459+
// () => document.getElementById("log-container"), true);
460+
461+
// function rewireLoggingToElement(eleLocator, eleOverflowLocator, autoScroll) {
462+
// fixLoggingFunc('log');
463+
// fixLoggingFunc('debug');
464+
// fixLoggingFunc('warn');
465+
// fixLoggingFunc('error');
466+
// fixLoggingFunc('info');
467+
468+
469+
// function fixLoggingFunc(name) {
470+
// console['old' + name] = console[name];
471+
// console[name] = function (...arguments) {
472+
// const output = produceOutput(name, arguments);
473+
// const eleLog = eleLocator();
474+
475+
// if (autoScroll) {
476+
// const eleContainerLog = eleOverflowLocator();
477+
// const isScrolledToBottom = eleContainerLog.scrollHeight - eleContainerLog.clientHeight <= eleContainerLog.scrollTop + 1;
478+
// eleLog.innerHTML += output + "<br>";
479+
// if (isScrolledToBottom) {
480+
// eleContainerLog.scrollTop = eleContainerLog.scrollHeight - eleContainerLog.clientHeight;
481+
// }
482+
// } else {
483+
// eleLog.innerHTML += output + "<br>";
484+
// }
485+
486+
// console['old' + name].apply(undefined, arguments);
487+
// };
488+
// }
441489

442-
async function load_data(path) {
443-
document.getElementById("cell-running").style.display = "block"
444-
let df = await dfd.read_csv(path)
445-
document.getElementById("cell-running").style.display = "none"
446-
return df
447-
448-
}
449-
450-
$("#closename").click(function(){
451-
452-
let textval = $("#namebook").val()
453-
454-
$("#notebookname").html(`<h2>${textval}</h2>`)
455-
});
456-
457-
458-
459-
490+
// function produceOutput(name, args) {
491+
// return args.reduce((output, arg) => {
492+
// return output +
493+
// "<span class=\"log-" + (typeof arg) + " log-" + name + "\">" +
494+
// (typeof arg === "object" && (JSON || {}).stringify ? JSON.stringify(arg) : arg) +
495+
// "</span>&nbsp;";
496+
// }, '');
497+
// }
498+
// }

notebookjs/src/public/stylesheets/style.css

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
/* body {
2-
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
3-
} */
1+
body {
2+
font: 8px
3+
}
44

55
a {
66
color: #00B7FF;
77
}
88

99
.container{
1010
padding: 20px;
11-
/* margin-left: 10px; */
12-
/* margin-right: 10px; */
11+
margin-left: 10px;
12+
margin-right: 10px;
1313
}
1414

1515
.out-divs{
@@ -70,4 +70,15 @@ table.df-table th, td {
7070

7171
table.df-table .float32, .int32 {
7272
text-align: right;
73-
}
73+
}
74+
75+
.ow-break-word {
76+
overflow-wrap: break-word;
77+
}
78+
79+
/* body {background: #333;} */
80+
.log-boolean,
81+
.log-undefined {color: magenta;}
82+
.log-object,
83+
.log-string {color: orange;}
84+
.log-number {color: cyan;}

0 commit comments

Comments
 (0)