/* * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Mozilla Communicator client code, released * March 31, 1998. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998-1999 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * Ben Goodger */ /* Script for the file properties window */ function FileProperties() { var tree = document.getElementById('fileTree'); if (tree.selectedItems.length >= 1) { // don't bother showing properties on bookmark separators var type = tree.selectedItems[0].getAttribute('type'); if (type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") { var props = window.open("chrome://bookmarks/content/bm-props.xul", "BookmarkProperties", "chrome,menubar,resizable"); props.BookmarkURL = tree.selectedItems[0].getAttribute("id"); } } else { dump("nothing selected!\n"); } } function OpenSearch(tabName) { window.openDialog("resource:/res/samples/search.xul", "SearchWindow", "dialog=no,close,chrome,resizable", tabName); } function OpenURL(event, node) { // clear any single-click/edit timeouts if (timerID != null) { gEditNode = null; clearTimeout(timerID); timerID = null; } if (node.getAttribute('container') == "true") { return(false); } var url = node.getAttribute('id'); // Ignore "NC:" urls. if (url.substring(0, 3) == "NC:") { return(false); } try { // add support for IE favorites under Win32, and NetPositive URLs under BeOS if (url.indexOf("file://") == 0) { var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService(); if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService); if (rdf) { var fileSys = rdf.GetDataSource("rdf:files"); if (fileSys) { var src = rdf.GetResource(url, true); var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true); var target = fileSys.GetTarget(src, prop, true); if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral); if (target) target = target.Value; if (target) url = target; } } } } catch(ex) { } if(top.isEditor != undefined) { if(top.editorShell) { var ext = getFileExtension(url); // look at the extension of the file to see what should be done // with it. Note that this is a typically windowsey approach. will // rdf:files hold a reference to the actual file type? (Mac?) switch(ext) { // XXX Crude, but it will do for now. case "gif": case "jpeg": case "jpg": case "png": // just insert the image EditorAutoInsertImage(url); break; case "htm": case "html": case "xul": toEditor(url); break; case "js": EditorInsertJSFile(url); break; case "css": EditorInsertCSSFile(url); break; default: // load the file in the editor dump("Editor Message: Weirdo File Format\n"); toEditor(url); break; } } } else { window.open(url,'bookmarks'); } dump("OpenURL(" + url + ")\n"); return(true); } // returns the extension of a specified file URL function getFileExtension(url) { return url.substring(url.lastIndexOf(".")+1,url.length).toLowerCase(); } var htmlInput = null; var saveNode = null; var newValue = ""; var timerID = null; var gEditNode = null; function DoSingleClick(event, node) { var type = node.parentNode.parentNode.getAttribute('type'); var selected = node.parentNode.parentNode.getAttribute('selected'); if (gEditNode == node) { // Only start an inline edit if it is the second consecutive click // on the same node that is not already editing or a separator. if (!htmlInput && type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") { // Edit node if we don't get a double-click in less than 1/2 second timerID = setTimeout("OpenEditNode()", 500); } } else { if (htmlInput) { // Clicked during an edit // Save the changes and move on CloseEditNode(true); } gEditNode = node; } return false; } function OpenEditNode() { dump("OpenEditNode entered.\n"); // clear any single-click/edit timeouts if (timerID != null) { clearTimeout(timerID); timerID = null; } // XXX uncomment the following line to replace the whole input row we do this // (and, therefore, only allow editing on the name column) until we can // arbitrarily change the content model (bugs prevent this at the moment) gEditNode = gEditNode.parentNode; var name = gEditNode.parentNode.getAttribute("Name"); dump("Single click on '" + name + "'\n"); var theParent = gEditNode.parentNode; dump("Parent node is a " + theParent.nodeName + "\n\n"); saveNode = gEditNode; // unselect all nodes! var select_list = document.getElementsByAttribute("selected", "true"); dump("# of Nodes selected: " + select_list.length + "\n\n"); for (var nodeIndex=0; nodeIndex