-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patha1.js
26 lines (26 loc) · 857 Bytes
/
a1.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
function line(content,id) {
var content,id;
this.representative=document.createElement('line');
this.representative.setAttribute('contenteditable','');
this.representative.setAttribute('spellcheck','false');
this.representative.appendChild(document.createTextNode(content||''));
this.representative.oninput=()=>{
var val=this.representative.innerHTML;
if (/<div><br><\/div>/.test(val)) {
this.representative.innerHTML=val.replace(/<div><br><\/div>/,'');
let messyshtuff=new line('',id+1);
}
};
if (!id) {
id=lines.length;
lines.push(this);
} else {
lines.splice(id,0,this);
}
document.querySelector('#editor').insertBefore(this.representative,document.querySelector('#editor > line:nth-child('+id+')'));
}
var lines=[];
(function () {
var shep=new line('test'),
purple=new line('teehee');
})();