Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: chrome/common/extensions/docs/examples/api/topsites/basic/popup.js

Issue 25389003: [DocServer] Updated Top Sites Sample Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
not at google - send to devlin 2013/10/01 15:04:36 it would be nice if this file were detected as a m
François Beaufort 2013/10/02 12:44:59 I've played as much as possible with "git cl uploa
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Event listener for clicks on links in a browser action popup.
6 // Open the link in a new tab of the current window.
7 function onAnchorClick(event) {
8 chrome.tabs.create({ url: event.srcElement.href });
9 return false;
10 }
11
12 // Given an array of URLs, build a DOM list of these URLs in the
13 // browser action popup.
14 function buildPopupDom(data) {
not at google - send to devlin 2013/10/01 15:04:36 s/data/historyItems/
François Beaufort 2013/10/02 12:44:59 Done.
15 var popupDiv = document.getElementById("mostVisited_div");
16
17 var ol = document.createElement('ol');
18 popupDiv.appendChild(ol);
19
20 for (var i = 0; i < data.length; i++) {
21 var a = document.createElement('a');
22 a.href = data[i].url;
23 a.appendChild(document.createTextNode(data[i].title));
24 a.addEventListener('click', onAnchorClick);
25
26 var li = document.createElement('li');
27 li.appendChild(a);
28
29 ol.appendChild(li);
not at google - send to devlin 2013/10/01 15:04:36 i'm gonna nitpick here for no other reason than DO
30 }
31 }
32
33 chrome.topSites.get(function(historyItems) {
34 buildPopupDom(historyItems);
35 });
not at google - send to devlin 2013/10/01 15:04:36 cleanup: chrome.topSites.get(buildPopupDom);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698