aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.12/examples/library-detector/data/widget.html
blob: 4ca5b50327d0af8bc1325da76c0f7f5f764249e5 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<html>
<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <title>Library detector</title>
  <style type="text/css" media="all">
    img {
      display: inline;
      width: 16px;
      height: 16px;
    }
  </style>
  <script type="text/javascript">
    var icons = {
      'jQuery' : 'jquery.ico',
      'jQuery UI' : 'jquery_ui.ico',
      'MooTools' : 'mootools.png',
      'YUI' : 'yui.ico',
      'Closure' : 'closure.ico',
      'Modernizr': 'modernizr.ico',
    };

    // Listen for mouse events over icons, in order to send a message up to
    // the panel and update its content with library name and version
    window.addEventListener('mouseover', function (event) {
      if (event.target.tagName == 'IMG') {
        addon.port.emit('setLibraryInfo', event.target.title);
      }
    }, false);

    addon.port.on('update', function (libraries) {
      // Cleanup previous content
      document.body.innerHTML = '';

      // Create new updated list of icons
      libraries.forEach(function(library) {
        var img = document.createElement('img');
        img.setAttribute('src', 'icons/' + icons[library.name]);
        img.setAttribute('title', library.name + "<br>Version: " +
                                  library.version);
        document.body.appendChild(img);
      });
    });
  </script>
</head>
<body></body>
</html>