-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
84 lines (68 loc) · 3.21 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
console.log("Checking Zeppelin Viewer...")
var finalPath = document.getElementsByClassName("final-path");
if(finalPath.length !=0 ) {
fileName = finalPath[0].innerText
console.log("File Name is: "+ fileName);
if(fileName == "note.json") {
var dataDiv = document.getElementsByClassName("data")[0];
var data = dataDiv.innerText;
// console.log(data);
var dataObj = JSON.parse(data);
console.log(dataObj);
var outerView = document.createElement("div");
// Add name
var nameDiv = document.createElement("div");
nameDiv.setAttribute('class','nbName');
var nameText = document.createTextNode(dataObj.name);
nameDiv.appendChild(nameText);
//Add paragraphs
var paragraphsDiv = document.createElement("div");
var paragraphs = dataObj.paragraphs
console.log(paragraphs);
for (i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
if(paragraph.hasOwnProperty('text')) {
var pElement = document.createElement("div");
pElement.setAttribute('id', 'p'+i);
// pElement.setAttribute('class','cellCard mdl-grid mdl-card mdl-shadow--4dp');
pElement.setAttribute('class','cellCard');
var codeElement = document.createElement("div");
codeElement.setAttribute('id', 'code'+i);
codeElement.setAttribute('class','codeText');
// console.log("text: "+paragraph.text);
codeElement.innerText = paragraph.text;
pElement.appendChild(codeElement);
var outputElement = document.createElement("div");
outputElement.setAttribute('id', 'out'+i);
// outputElement.setAttribute('class', 'codeOutput mdl-card__supporting-text mdl-card--border mdl-cell--12-col');
outputElement.setAttribute('class', 'codeOutput');
// console.log("text: "+paragraph.results.msg[0].data);
outputElement.innerText = paragraph.results.msg[0].data;
pElement.appendChild(outputElement);
// var statusElement = document.createElement("div");
// statusElement.setAttribute('id', 'status'+i);
// statusElement.setAttribute('class', 'mdl-cell mdl-cell--1-col');
// var statusSpan = document.createElement("span");
// statusSpan.setAttribute('class','statusChip mdl-chip');
// // console.log(paragraph.status);
// statusSpan.innerHTML = '<span class="mdl-chip__text">'+paragraph.status+'</span>';
// statusElement.appendChild(statusSpan);
// pElement.appendChild(statusElement);
var user = paragraph.user;
var dateStarted = paragraph.dateStarted;
var dateFinished = paragraph.dateFinished;
var executionTime = ((new Date(dateFinished)).getTime() - (new Date(dateStarted)).getTime())/1000
var timeSpan = document.createElement("span");
timeSpan.setAttribute('class','executionTime');
timeSpan.innerText = "Took "+executionTime+" seconds. Last updated by "+user+" at "+dateStarted;
pElement.appendChild(timeSpan);
paragraphsDiv.appendChild(pElement);
}
}
outerView.appendChild(nameDiv);
outerView.appendChild(paragraphsDiv);
$("div.data").html(outerView.innerHTML)
} else {
console.log("Desired file not found")
}
}