diff --git a/oml/item/icons.py b/oml/item/icons.py index e87b724..7d96d39 100644 --- a/oml/item/icons.py +++ b/oml/item/icons.py @@ -105,7 +105,7 @@ class Icons(dict): c.close() conn.close() except: - logger.debug('failed to clear icon %s', prefix) + logger.debug('failed to clear icon %s', id) def vacuum(self, ids): conn = self.connect() diff --git a/static/js/annotation.js b/static/js/annotation.js index 2a4df4d..d0d26b1 100644 --- a/static/js/annotation.js +++ b/static/js/annotation.js @@ -1,34 +1,14 @@ 'use strict'; -oml.ui.annotation = function(annotation, $iframe) { +oml.ui.annotation = function(data, $iframe) { var $arrayEditable = Ox.ArrayEditable({ editing: true, - items: (annotation.comments || []).map(function(comment) { - comment.editable = true - return comment - }), type: 'textarea' }).css({ minHeight: '16px' - }).bindEvent({ - submit: function(data) { - var comment = Ox.getObjectById(annotation.comments, data.id) - if (comment) { - comment.value = data.value - comment.modified = (new Date).toISOString() - } else { - annotation.comments.push({ - created: data.created || (new Date).toISOString(), - modified: (new Date).toISOString(), - id: data.id, - value: data.value - }) - } - that.triggerEvent('change') - } }); var that = Ox.Element().attr({ - id: 'a-' + annotation.id + id: 'a-' + data.id }).addClass( 'OxSelectable' ).css({ @@ -41,10 +21,10 @@ oml.ui.annotation = function(annotation, $iframe) { fontSize: '14px', lineHeight: '21px', padding: '8px' - }).html(Ox.encodeHTMLEntities(annotation.text).replace(/\n/g, '
')).on({ + }).html(Ox.encodeHTMLEntities(data.text).replace(/\n/g, '
')).on({ click: function(event) { $iframe.postMessage('selectAnnotation', { - id: annotation.id + id: data.id }) } }) diff --git a/static/js/viewer.js b/static/js/viewer.js index 848364a..8cb4842 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -46,7 +46,6 @@ oml.ui.viewer = function() { function saveAnnotations(data) { if (data) { data.created = data.created || (new Date).toISOString(); - data.comments = data.comments || []; annotations.push(data); } localStorage[item + '.annotations'] = JSON.stringify(annotations) @@ -58,14 +57,6 @@ oml.ui.viewer = function() { saveAnnotations() } - var annotationEvents = { - change: function() { - console.log('change...') - console.log(annotations) - saveAnnotations() - } - } - that.updateElement = function() { item = ui.item; if (item && item.length) { @@ -84,7 +75,7 @@ oml.ui.viewer = function() { if (event == 'addAnnotation') { console.log('adding', data.id) saveAnnotations(data); - var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents) + var $annotation = oml.ui.annotation(data, $iframe) oml.$ui.annotationFolder.append($annotation); $annotation.annotate(); } else if (event == 'removeAnnotation') { @@ -102,7 +93,7 @@ oml.ui.viewer = function() { init: function() { loadAnnotations(function(annotations) { annotations.forEach(function(data) { - var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents) + var $annotation = oml.ui.annotation(data, $iframe) oml.$ui.annotationFolder.append($annotation); }) // fixme: trigger loaded event from reader instead? diff --git a/static/reader/pdf.js b/static/reader/pdf.js index 6e095f1..b4bbed3 100644 --- a/static/reader/pdf.js +++ b/static/reader/pdf.js @@ -144,7 +144,7 @@ function removeAnnotation(id) { annotations = annotations.filter(function(annotation) { return annotation.id != id }) - Ox.$parent.postMessage('removeAnnotation', {id: id}) + Ox.$parent.postMessage('removeAnnotation', {id: selected.dataset.id}) } function loadAnnotations(page) {