зеркало из https://github.com/mozilla/pjs.git
Add support for importing/exporting bookmarks.
This commit is contained in:
Родитель
a13b94e0fc
Коммит
93307427b0
|
@ -734,6 +734,10 @@ function fillContextMenu(name)
|
|||
|
||||
|
||||
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
|
||||
|
||||
|
||||
function doContextCmd(cmdName)
|
||||
{
|
||||
debug("doContextCmd start: cmd='" + cmdName + "'");
|
||||
|
@ -776,6 +780,54 @@ function doContextCmd(cmdName)
|
|||
var promptStr = bundle.GetStringFromName("DeleteItems");
|
||||
if (!confirm(promptStr)) return(false);
|
||||
}
|
||||
else if (cmdName == "http://home.netscape.com/NC-rdf#command?cmd=import")
|
||||
{
|
||||
try
|
||||
{
|
||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
||||
if (filePicker) filePicker = filePicker.QueryInterface(Components.interfaces.nsIFileSpecWithUI);
|
||||
if (!filePicker) return(false);
|
||||
|
||||
var promptStr = bundle.GetStringFromName("SelectImport");
|
||||
|
||||
filePicker.chooseInputFile(promptStr, 2, "", ""); // 2 = html filter
|
||||
var filespec = filePicker.QueryInterface(Components.interfaces.nsIFileSpec);
|
||||
if (!filespec) return(false);
|
||||
var filename = filespec.URLString;
|
||||
if ((!filename) || (filename == "")) return(false);
|
||||
|
||||
debug("Import: '" + filename + "'\n");
|
||||
urlVal = filename;
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else if (cmdName == "http://home.netscape.com/NC-rdf#command?cmd=export")
|
||||
{
|
||||
try
|
||||
{
|
||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
||||
if (filePicker) filePicker = filePicker.QueryInterface(Components.interfaces.nsIFileSpecWithUI);
|
||||
if (!filePicker) return(false);
|
||||
|
||||
var promptStr = bundle.GetStringFromName("EnterExport");
|
||||
|
||||
filePicker.chooseOutputFile(promptStr, "bookmarks.html", 2); // 2 = html filter
|
||||
var filespec = filePicker.QueryInterface(Components.interfaces.nsIFileSpec);
|
||||
if (!filespec) return(false);
|
||||
var filename = filespec.URLString;
|
||||
if ((!filename) || (filename == "")) return(false);
|
||||
|
||||
debug("Export: '" + filename + "'\n");
|
||||
urlVal = filename;
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
var treeNode = document.getElementById("bookmarksTree");
|
||||
if (!treeNode) return(false);
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
<!ENTITY menuitem.newBookmark.label "New Bookmark">
|
||||
<!ENTITY menuitem.newFolder.label "New Folder">
|
||||
<!ENTITY menuitem.newSeparator.label "New Separator">
|
||||
<!ENTITY menuitem.import.label "Import...">
|
||||
<!ENTITY menuitem.export.label "Export...">
|
||||
<!ENTITY menuitem.close.label "Close">
|
||||
|
||||
<!ENTITY menu.edit.label "Edit">
|
||||
<!ENTITY menuitem.undo.label "Undo">
|
||||
<!ENTITY menuitem.redo.label "Redo">
|
||||
|
@ -37,6 +40,12 @@
|
|||
<!ENTITY menuitem.selectAll.label "Select All">
|
||||
<!ENTITY menuitem.find.label "Search in Bookmarks...">
|
||||
<!ENTITY menuitem.properties.label "Properties...">
|
||||
|
||||
<!ENTITY menu.view.label "View">
|
||||
<!ENTITY menuitem.newbookmarkfolder.label "Set as New Bookmark Folder">
|
||||
<!ENTITY menuitem.newinternetsearchfolder.label "Set as New Internet Search Folder">
|
||||
<!ENTITY menuitem.personaltoolbarfolder.label "Set as Personal Toolbar Folder">
|
||||
|
||||
<!ENTITY tree.header.name.label "Name">
|
||||
<!-- LOCALIZATION NOTE (tree.header.url.label) : DONT_TRANSLATE -->
|
||||
<!ENTITY tree.header.url.label "URL">
|
||||
|
|
Загрузка…
Ссылка в новой задаче