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

Unified Diff: chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.js

Issue 9358073: First version of the time slicing on the urls. Not ready for review yet. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added relative time to time slicing Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.js
diff --git a/chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.js b/chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.js
new file mode 100644
index 0000000000000000000000000000000000000000..c05ec7e42df560d35695c09a333c5d6123b3e2a2
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.js
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Event listner for clicks on links in a browser action popup.
+// Open the link in a new tab of the current window.
+function onAnchorClick(event) {
+ chrome.tabs.create({
+ selected: true,
+ url: event.srcElement.href
+ });
+ return false;
+}
+
+// Given an array of URLs, build a DOM list of those URLs in the
+// browser action popup.
+function buildPopupDom(divName, data) {
+ var popupDiv = document.getElementById(divName);
+
+ var ul = document.createElement('ul');
+ popupDiv.appendChild(ul);
+
+ for (var i = 0, ie = data.length; i < ie; ++i) {
+ var a = document.createElement('a');
+ a.href = data[i].url;
+ a.appendChild(document.createTextNode(data[i].title));
+ a.addEventListener('click', onAnchorClick);
+
+ var li = document.createElement('li');
+ li.appendChild(a);
+
+ ul.appendChild(li);
+ }
+}
+
+// Search history to find up to ten links that a user has visited during the
+// current time of the day +/- 1 hour.
+function buildTypedUrlList(divName) {
+ var millisecondsPerHour = 1000 * 60 * 60;
+ var startTime = (new Date).getTime() - millisecondsPerHour;
+ var endTime = (new Date).getTime() - millisecondsPerHour;
+ var maxResults = 10;
+
+ chrome.history.getMostVisited({
+ 'startTime' : startTime,
+ 'endTime' : endTime,
+ 'maxResults' : maxResults
+ },
+ function(historyItems) {
+ buildPopupDom(divName, historyItems);
+ });
+}
+
+document.addEventListener('DOMContentLoaded', function () {
+ buildTypedUrlList("filteredUrl_div");
+});
« no previous file with comments | « chrome/common/extensions/docs/examples/api/history/showTimeFilter/timeFilterUrls.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698