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

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: Added new icon 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
« no previous file with comments | « chrome/common/extensions/docs/examples/api/topsites/basic/popup.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
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(mostVisitedURLs) {
15 var popupDiv = document.getElementById('mostVisited_div');
16 var ol = popupDiv.appendChild(document.createElement('ol'));
17
18 for (var i = 0; i < mostVisitedURLs.length; i++) {
19 var li = ol.appendChild(document.createElement('li'));
20 var a = li.appendChild(document.createElement('a'));
21 a.href = mostVisitedURLs[i].url;
22 a.appendChild(document.createTextNode(mostVisitedURLs[i].title));
23 a.addEventListener('click', onAnchorClick);
24 }
25 }
26
27 chrome.topSites.get(buildPopupDom);
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/examples/api/topsites/basic/popup.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698