Skip to content

Commit c2b5aa9

Browse files
committed
Deleting all snippets works in Chrome 30 now as well.
Improve presentation of alert information for the two use cases: To inspect localStorage To import/export devtools source snippets
1 parent 9e845f9 commit c2b5aa9

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

snippets/devtools_import_export.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
wa.document.body.appendChild(confirmerDivPopup);
171171
} else {
172172
document.body.appendChild(confirmerDiv);
173-
window.alert(" To inspect localStorage of\n " + location.origin + '\n\nOpen ' + title + '\n\n To import/export devtools source snippets:\n\n1. Cancel\n2. Undock Chrome Developer Tools into separate window\n3. Press Ctrl+Shift+I to inspect it.\n4. Run this snippet from there.');
173+
window.alert("To inspect localStorage of\n" + location.origin + '\n\n* Open ' + title + '\n\nTo import/export devtools source snippets:\n\n* Cancel\n* Undock Developer Tools into separate window\n* Press Ctrl+Shift+I to inspect it.\n* Run this snippet from there.');
174174
}
175175
var removeConfirmer = function(confirmerDiv) {
176176
document.body.removeChild(confirmerDiv);
@@ -251,13 +251,24 @@
251251
localStorageDownloadButton.click();
252252
if (window.confirm("I have verified localStorage download completed successfully and would like to delete all snippets from Chrome now.\n\n(This cannot be undone when localStorage data has not been downloaded.)")) {
253253
p = WebInspector.scriptSnippetModel.project();
254-
var paths = p.uiSourceCodes().map(function(sc) {
255-
return sc.path();
256-
});
257-
paths.forEach(function(path) {
258-
p.deleteFile(path);
259-
console.log("snippet " + path + " has been deleted.");
260-
});
254+
var scs = p.uiSourceCodes();
255+
// TODO Please note Chrome 30 deleteFile takes a uiSourceCode argument.
256+
if (p.deleteFile.toString().match(/function\s*\(uiSourceCode\)/)) {
257+
// TODO Please note Chrome 30 misses entries when counting up.
258+
for (var i = scs.length - 1; i >= 0; i--) {
259+
console.log("deleting snippet " + scs[i].path());
260+
p.deleteFile(scs[i]);
261+
}
262+
} else {
263+
// TODO Please note Chrome 32 deleteFile takes a path argument.
264+
var paths = scs.map(function(sc) {
265+
return sc.path();
266+
});
267+
paths.forEach(function(path) {
268+
p.deleteFile(path);
269+
console.log("snippet " + path + " has been deleted.");
270+
});
271+
}
261272
p.refresh();
262273
}
263274
}, false);

0 commit comments

Comments
 (0)