|
|
|
@ -32,7 +32,7 @@ function appendData(div, data) {
|
|
|
|
newline = formatLine(lineBegin + lines[0]);
|
|
|
|
newline = formatLine(lineBegin + lines[0]);
|
|
|
|
line.parentNode.replaceChild(newline, line);
|
|
|
|
line.parentNode.replaceChild(newline, line);
|
|
|
|
let prevline = newline;
|
|
|
|
let prevline = newline;
|
|
|
|
for(let i=1; i<lines.length - 1; i++) {
|
|
|
|
for (let i = 1; i < lines.length - 1; i++) {
|
|
|
|
newline = formatLine(lines[i]);
|
|
|
|
newline = formatLine(lines[i]);
|
|
|
|
prevline.after(newline);
|
|
|
|
prevline.after(newline);
|
|
|
|
prevline = newline;
|
|
|
|
prevline = newline;
|
|
|
|
@ -62,7 +62,7 @@ function dpwidth(div) {
|
|
|
|
function save(textarea, div) {
|
|
|
|
function save(textarea, div) {
|
|
|
|
let lines = div.children;
|
|
|
|
let lines = div.children;
|
|
|
|
let text = '';
|
|
|
|
let text = '';
|
|
|
|
for (let i=0; i<lines.length; i++) {
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
|
|
if (lines[i].innerText != '\n') {
|
|
|
|
if (lines[i].innerText != '\n') {
|
|
|
|
text += lines[i].innerText.replace(emsp(), '\t');
|
|
|
|
text += lines[i].innerText.replace(emsp(), '\t');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -94,7 +94,21 @@ function onlink(e) {
|
|
|
|
if (link.host !== document.location.host) {
|
|
|
|
if (link.host !== document.location.host) {
|
|
|
|
open(link.href);
|
|
|
|
open(link.href);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
open(link.href, '_self');
|
|
|
|
//open(link.href, '_self');
|
|
|
|
|
|
|
|
fetch(link.href + "?data=").then((response) => {
|
|
|
|
|
|
|
|
let ta = document.getElementById('ta');
|
|
|
|
|
|
|
|
response.text().then((data) => {
|
|
|
|
|
|
|
|
let content = document.getElementById('content');
|
|
|
|
|
|
|
|
let left = content.scrollLeft;
|
|
|
|
|
|
|
|
let top = content.scrollTop;
|
|
|
|
|
|
|
|
window.history.replaceState({top: top, left: left}, "");
|
|
|
|
|
|
|
|
window.history.pushState({}, "", link.href);
|
|
|
|
|
|
|
|
ta.value = data;
|
|
|
|
|
|
|
|
load(document.getElementById('ta'), document.getElementById('cheezenotes'));
|
|
|
|
|
|
|
|
content.scrollTop = 0;
|
|
|
|
|
|
|
|
content.scrollLeft = 0;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).catch((error) => { alert(error); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -205,7 +219,7 @@ function formatLine(line) {
|
|
|
|
if (elem.getElementsByClassName('tablerow').length > 0) {
|
|
|
|
if (elem.getElementsByClassName('tablerow').length > 0) {
|
|
|
|
if (elem.childNodes[0].childNodes.length > 0) {
|
|
|
|
if (elem.childNodes[0].childNodes.length > 0) {
|
|
|
|
let child = elem.childNodes[0].childNodes[0];
|
|
|
|
let child = elem.childNodes[0].childNodes[0];
|
|
|
|
while(child != null) {
|
|
|
|
while (child != null) {
|
|
|
|
if (child.nodeType == 3) {
|
|
|
|
if (child.nodeType == 3) {
|
|
|
|
let newchild = document.createElement('span');
|
|
|
|
let newchild = document.createElement('span');
|
|
|
|
newchild.innerText = child.nodeValue;
|
|
|
|
newchild.innerText = child.nodeValue;
|
|
|
|
@ -219,7 +233,7 @@ function formatLine(line) {
|
|
|
|
elem.classList.add('tablerow');
|
|
|
|
elem.classList.add('tablerow');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let links = elem.getElementsByClassName('link');
|
|
|
|
let links = elem.getElementsByClassName('link');
|
|
|
|
for (let i=0; i<links.length; i++) {
|
|
|
|
for (let i = 0; i < links.length; i++) {
|
|
|
|
let link = links[i];
|
|
|
|
let link = links[i];
|
|
|
|
link.addEventListener('mouseover', onlinkin);
|
|
|
|
link.addEventListener('mouseover', onlinkin);
|
|
|
|
link.addEventListener('click', onlink);
|
|
|
|
link.addEventListener('click', onlink);
|
|
|
|
@ -243,7 +257,7 @@ function addTableLine(line) {
|
|
|
|
cpt++;
|
|
|
|
cpt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
matches = matches.reverse();
|
|
|
|
matches = matches.reverse();
|
|
|
|
for(let i=0; i<matches.length; i++) {
|
|
|
|
for (let i = 0; i < matches.length; i++) {
|
|
|
|
let match = matches[i];
|
|
|
|
let match = matches[i];
|
|
|
|
if (i == matches.length - 1) {
|
|
|
|
if (i == matches.length - 1) {
|
|
|
|
// premier |
|
|
|
|
// premier |
|
|
|
|
@ -295,13 +309,13 @@ function redrawTables(cheezenotes, dpwidth = 0) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let child = cheezenotes.childNodes[0];
|
|
|
|
let child = cheezenotes.childNodes[0];
|
|
|
|
let firsttableline = null;
|
|
|
|
let firsttableline = null;
|
|
|
|
while(child != null) {
|
|
|
|
while (child != null) {
|
|
|
|
if (firsttableline == null) {
|
|
|
|
if (firsttableline == null) {
|
|
|
|
if (child.classList.contains('tablerow')) {
|
|
|
|
if (child.classList.contains('tablerow')) {
|
|
|
|
firsttableline = child;
|
|
|
|
firsttableline = child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (! child.classList.contains('tablerow')) {
|
|
|
|
if (!child.classList.contains('tablerow')) {
|
|
|
|
formatTable(firsttableline, dpwidth);
|
|
|
|
formatTable(firsttableline, dpwidth);
|
|
|
|
firsttableline = null;
|
|
|
|
firsttableline = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -314,7 +328,7 @@ function redrawTables(cheezenotes, dpwidth = 0) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function formatTable(line, dpwidth = 0) {
|
|
|
|
function formatTable(line, dpwidth = 0) {
|
|
|
|
if (! line.classList.contains('tablerow')) {
|
|
|
|
if (!line.classList.contains('tablerow')) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -345,7 +359,7 @@ function resizeTableCols(firstline, lastline, dpwidth) {
|
|
|
|
let currentwidth = 0;
|
|
|
|
let currentwidth = 0;
|
|
|
|
let col = 0;
|
|
|
|
let col = 0;
|
|
|
|
let currentleft;
|
|
|
|
let currentleft;
|
|
|
|
for(let i=0; i<childNodes.length; i++) {
|
|
|
|
for (let i = 0; i < childNodes.length; i++) {
|
|
|
|
let child = childNodes[i];
|
|
|
|
let child = childNodes[i];
|
|
|
|
if (child.classList != null && child.classList.contains('lefttablespacer')) {
|
|
|
|
if (child.classList != null && child.classList.contains('lefttablespacer')) {
|
|
|
|
currentleft = child;
|
|
|
|
currentleft = child;
|
|
|
|
@ -377,7 +391,7 @@ function resizeTableCols(firstline, lastline, dpwidth) {
|
|
|
|
currentline = currentline.nextSibling;
|
|
|
|
currentline = currentline.nextSibling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (let i=0; i<colsmaxwidth.length; i++) {
|
|
|
|
for (let i = 0; i < colsmaxwidth.length; i++) {
|
|
|
|
if (colsjustif[i] == null) {
|
|
|
|
if (colsjustif[i] == null) {
|
|
|
|
colsjustif[i] = 'l';
|
|
|
|
colsjustif[i] = 'l';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -389,7 +403,7 @@ function resizeTableCols(firstline, lastline, dpwidth) {
|
|
|
|
let childNodes = tablerow.childNodes;
|
|
|
|
let childNodes = tablerow.childNodes;
|
|
|
|
let col = 0;
|
|
|
|
let col = 0;
|
|
|
|
let currentleft;
|
|
|
|
let currentleft;
|
|
|
|
for(let i=0; i<childNodes.length; i++) {
|
|
|
|
for (let i = 0; i < childNodes.length; i++) {
|
|
|
|
let child = childNodes[i];
|
|
|
|
let child = childNodes[i];
|
|
|
|
if (child.classList != null && child.classList.contains('lefttablespacer')) {
|
|
|
|
if (child.classList != null && child.classList.contains('lefttablespacer')) {
|
|
|
|
currentleft = child;
|
|
|
|
currentleft = child;
|
|
|
|
@ -418,7 +432,7 @@ function resizeTableCols(firstline, lastline, dpwidth) {
|
|
|
|
if (justif == 'c') {
|
|
|
|
if (justif == 'c') {
|
|
|
|
leftwidth = Math.round((colsmaxwidth[col] - child.dataWidth) / 2 + 10 + lplus);
|
|
|
|
leftwidth = Math.round((colsmaxwidth[col] - child.dataWidth) / 2 + 10 + lplus);
|
|
|
|
rightwidth = Math.round((colsmaxwidth[col] - child.dataWidth) / 2 + 10 + rplus);
|
|
|
|
rightwidth = Math.round((colsmaxwidth[col] - child.dataWidth) / 2 + 10 + rplus);
|
|
|
|
} else if(justif == 'r') {
|
|
|
|
} else if (justif == 'r') {
|
|
|
|
leftwidth = Math.round(colsmaxwidth[col] - child.dataWidth + 10 + lplus);
|
|
|
|
leftwidth = Math.round(colsmaxwidth[col] - child.dataWidth + 10 + lplus);
|
|
|
|
rightwidth = 10 + rplus;
|
|
|
|
rightwidth = 10 + rplus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -458,10 +472,10 @@ function addMono(line, listMono) {
|
|
|
|
cpt++;
|
|
|
|
cpt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
matches = matches.reverse();
|
|
|
|
matches = matches.reverse();
|
|
|
|
for(let i=0; i<matches.length; i++) {
|
|
|
|
for (let i = 0; i < matches.length; i++) {
|
|
|
|
let mono = listMono[i];
|
|
|
|
let mono = listMono[i];
|
|
|
|
mono = mono.substring(1, mono.length - 1);
|
|
|
|
mono = mono.substring(1, mono.length - 1);
|
|
|
|
line = line.substring(0, matches[i]) + '<span class="token">`</span><span class="mono">' + mono + '</span><span class="token">`</span>' + line.substring(matches[i]+2, line.length);
|
|
|
|
line = line.substring(0, matches[i]) + '<span class="token">`</span><span class="mono">' + mono + '</span><span class="token">`</span>' + line.substring(matches[i] + 2, line.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return line;
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -492,8 +506,8 @@ function addLink(line, listLink) {
|
|
|
|
cpt++;
|
|
|
|
cpt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
matches = matches.reverse();
|
|
|
|
matches = matches.reverse();
|
|
|
|
for(let i=0; i<matches.length; i++) {
|
|
|
|
for (let i = 0; i < matches.length; i++) {
|
|
|
|
line = line.substring(0, matches[i]) + formatLink(listLink[i]) + line.substring(matches[i]+4, line.length);
|
|
|
|
line = line.substring(0, matches[i]) + formatLink(listLink[i]) + line.substring(matches[i] + 4, line.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return line;
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|