addon-sdk/source/examples/annotator/data/list/annotation-list.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /*
     6 Construct the HTML for the annotation list.
     8 Bind a function to click events on the link that send a message back to
     9 the add-on code, so it can open the link in the main browser.
    10 */
    12 self.on("message", function onMessage(storedAnnotations) {
    13   var annotationList = $('#annotation-list');
    14   annotationList.empty();
    15   storedAnnotations.forEach(
    16     function(storedAnnotation) {
    17       var annotationHtml = $('#template .annotation-details').clone();
    18       annotationHtml.find('.url').text(storedAnnotation.url)
    19                                  .attr('href', storedAnnotation.url);
    20       annotationHtml.find('.url').bind('click', function(event) {
    21         event.stopPropagation();
    22         event.preventDefault();
    23         self.postMessage(storedAnnotation.url);
    24       });
    25       annotationHtml.find('.selection-text')
    26                     .text(storedAnnotation.anchorText);
    27       annotationHtml.find('.annotation-text')
    28                     .text(storedAnnotation.annotationText);
    29       annotationList.append(annotationHtml);
    30     });
    31 });

mercurial