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

Side by Side Diff: chrome/test/data/extensions/samples/bookmarks/bookmark_api.html

Issue 386023: Remove the last of the old samples. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/extensions/samples/bookmarks/bookmark_view.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <script>
3 var dump = function(obj, indent) {
4 if (indent === undefined)
5 indent = "";
6 if (typeof obj == "object") {
7 var ret = "{<br/>";
8 var child_indent = indent + " ";
9 for (var item in obj) {
10 var child = null;
11 try {
12 child = obj[item];
13 } catch (e) {
14 child = '<error>';
15 }
16 ret += child_indent + item + ": " + dump(child, indent + " ");
17 }
18 return ret + indent + "}" + "<br/>";
19 } else {
20 return obj.toString() + "<br/>";
21 }
22 }
23
24 var testMoveBookmarks = function(event) {
25 testMoveBookmarks2(event);
26 }
27
28 var testMoveBookmarks2 = function(event) {
29 console.log(testMoveBookmarks2.caller.name);
30 if (event.shiftKey) {
31 // TODO - it would be nice to have a mechanism to do this built-in to a
32 // context menu.
33 window.location.reload();
34 return;
35 }
36 console.log("testMoveBookmarks2");
37 chrome.bookmarks.getChildren('0', function(root_children) {
38 var bookmark_bar = root_children[0]; // bookmarks bar is always first
39 chrome.bookmarks.getChildren(bookmark_bar.id, function(bar_children) {
40 var folder_search = [];
41 bar_children.forEach(function(child) {
42 if (child.title == "folder" && child.url == undefined) {
43 folder_search.push(child);
44 }
45 });
46 if (folder_search.length == 1) {
47 console.log('moving children out of "folder"');
48 var folder = folder_search[0];
49 chrome.bookmarks.getChildren(folder_search[0].id,
50 function(folder_children) {
51 folder_children.forEach(function(child) {
52 chrome.bookmarks.move(child.id,
53 {'parentId': bookmark_bar.id});
54 });
55 });
56 chrome.bookmarks.remove(folder.id);
57 } else if (folder_search.length == 0) {
58 console.log('creating "folder" and moving children into it');
59 chrome.bookmarks.create({'parentId': bookmark_bar.id,
60 'title': 'folder'},
61 function(folder) {
62 chrome.bookmarks.search("oog", function(oog_search) {
63 oog_search.forEach(function(oog_match) {
64 chrome.bookmarks.move(oog_match.id,
65 {'parentId': folder.id})
66 });
67 });
68 });
69 } else {
70 console.log("my puny code wasn't written to handle this");
71 }
72 });
73 });
74 };
75
76 var dumpBookmarks = function(event) {
77 chrome.tabs.create({url:"bookmark_view.html"});
78 };
79 </script>
80 <body>
81 <div class="toolstrip-button" onclick="dumpBookmarks(window.event);">
82 <span>Dump Bookmarks</span>
83 </div>
84 <div class="toolstrip-button" onclick="testMoveBookmarks(window.event);">
85 <span>Test Move</span>
86 </div>
87 </body>
88 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/samples/bookmarks/bookmark_view.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698