Compare commits

...

2 Commits

Author SHA1 Message Date
rlx a71ffdb82f merge 2019-02-01 12:43:19 +05:30
rlx 99b88de8c4 position: in,out 2019-02-01 12:40:45 +05:30
1 changed files with 16 additions and 16 deletions

View File

@ -2,17 +2,7 @@ let txtjs = {}
Ox.load({UI: {loadCSS: false}}, function() {
Ox.$parent.bindMessage(function(data, event) {
if (event == 'selectAnnotation') {
txtjs.selectNote(data.id)
} else if (event == 'addAnnotations') {
data.annotations.forEach(function(note) {
txtjs.renderNote(note)
txtjs.notes.push(note)
})
} else if (event == 'removeAnnotation') {
txtjs.selectNote(data.id)
txtjs.removeNote()
}
txtjs.onMessage(data, event)
})
})
@ -134,7 +124,7 @@ txtjs.getNoteFromSelection = function() {
return
}
let position = txtjs.getPosition(range)
let pos = position.split(':').map(function(v) {
let pos = position.split(',').map(function(v) {
return parseInt(v)
})
let note = {
@ -180,7 +170,7 @@ txtjs.getPosition = function(range) {
while (' \n'.includes(txtjs.text.substr(end - 1, 1))) {
end--
}
return start + ':' + end
return start + ',' + end
}
txtjs.getRange = function(id, start, end) {
@ -227,8 +217,18 @@ txtjs.noteExists = function(note) {
})
}
txtjs.onMessage = function(action, data) {
txtjs.onMessage = function(data, event) {
if (event == 'selectAnnotation') {
txtjs.selectNote(data.id)
} else if (event == 'addAnnotations') {
data.annotations.forEach(function(note) {
txtjs.renderNote(note)
txtjs.notes.push(note)
})
} else if (event == 'removeAnnotation') {
txtjs.selectNote(data.id)
txtjs.removeNote()
}
}
txtjs.postMessage = function(action, data) {
@ -256,7 +256,7 @@ txtjs.removeNote = function() {
}
txtjs.renderNote = function(note) {
let pos = note.position.split(':').map(function(v) {
let pos = note.position.split(',').map(function(v) {
return parseInt(v)
})
let ids = ['txt', 'txt-scroll']