michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: Construct the HTML for the annotation list. michael@0: michael@0: Bind a function to click events on the link that send a message back to michael@0: the add-on code, so it can open the link in the main browser. michael@0: */ michael@0: michael@0: self.on("message", function onMessage(storedAnnotations) { michael@0: var annotationList = $('#annotation-list'); michael@0: annotationList.empty(); michael@0: storedAnnotations.forEach( michael@0: function(storedAnnotation) { michael@0: var annotationHtml = $('#template .annotation-details').clone(); michael@0: annotationHtml.find('.url').text(storedAnnotation.url) michael@0: .attr('href', storedAnnotation.url); michael@0: annotationHtml.find('.url').bind('click', function(event) { michael@0: event.stopPropagation(); michael@0: event.preventDefault(); michael@0: self.postMessage(storedAnnotation.url); michael@0: }); michael@0: annotationHtml.find('.selection-text') michael@0: .text(storedAnnotation.anchorText); michael@0: annotationHtml.find('.annotation-text') michael@0: .text(storedAnnotation.annotationText); michael@0: annotationList.append(annotationHtml); michael@0: }); michael@0: });