зеркало из https://github.com/mozilla/gecko-dev.git
Make open/close folder work.
This commit is contained in:
Родитель
b8c237ee7f
Коммит
8635d6917a
|
@ -33,6 +33,69 @@ function Init()
|
|||
}
|
||||
|
||||
|
||||
function OnDblClick(event)
|
||||
{
|
||||
var item = event.target.parentNode.parentNode;
|
||||
var url = item.getAttribute('id');
|
||||
|
||||
var type = item.getAttribute('type');
|
||||
if (type == 'DIRECTORY') {
|
||||
// open inline
|
||||
dump('reading directory ' + url + '\n');
|
||||
ReadDirectory(url);
|
||||
}
|
||||
else {
|
||||
dump('navigating to ' + url + '\n');
|
||||
window.content.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ToggleTwisty(event)
|
||||
{
|
||||
var item = event.target.parentNode.parentNode.parentNode;
|
||||
if (item.getAttribute('open') == 'true') {
|
||||
item.removeAttribute('open');
|
||||
}
|
||||
else {
|
||||
var url = item.getAttribute('id');
|
||||
ReadDirectory(url);
|
||||
item.setAttribute('open', 'true');
|
||||
}
|
||||
|
||||
// XXX need to cancel the event here!!!
|
||||
}
|
||||
|
||||
|
||||
var Read = new Array();
|
||||
|
||||
function ReadDirectory(url)
|
||||
{
|
||||
if (Read[url]) {
|
||||
dump("directory already read\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var ios = Components.classes['component://netscape/network/net-service'].getService();
|
||||
ios = ios.QueryInterface(Components.interfaces.nsIIOService);
|
||||
dump("ios = " + ios + "\n");
|
||||
|
||||
var uri = ios.NewURI(url, null);
|
||||
dump("uri = " + uri + "\n");
|
||||
|
||||
var channel = ios.NewChannelFromURI('load', uri, null);
|
||||
dump("channel = " + channel + "\n");
|
||||
|
||||
var listener = HTTPIndex.CreateListener();
|
||||
dump("listener = " + listener + "\n");
|
||||
|
||||
channel.AsyncRead(0, -1, null, listener);
|
||||
|
||||
Read[url] = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// We need this hack because we've completely circumvented the onload() logic.
|
||||
function Boot()
|
||||
{
|
||||
|
@ -45,3 +108,5 @@ function Boot()
|
|||
}
|
||||
|
||||
setTimeout("Boot()", 0);
|
||||
|
||||
|
||||
|
|
|
@ -27,16 +27,23 @@
|
|||
title="&directoryWindowTitle.label;"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
align="vertical">
|
||||
align="vertical"
|
||||
ondblclick="OnDblClick(event);">
|
||||
|
||||
<html:script src="directory.js" />
|
||||
|
||||
<tree id="tree" datasources="rdf:null" flex="1">
|
||||
<template>
|
||||
<treechildren>
|
||||
<treeitem uri="...">
|
||||
<treeitem uri="..." type="rdf:urn:http-index-format:File-Type">
|
||||
<treerow>
|
||||
<treecell><text value="rdf:urn:http-index-format:Filename"/></treecell>
|
||||
<treecell class="Filename">
|
||||
<treeindentation/>
|
||||
<titledbutton class="twisty"
|
||||
treeallowevents="true"
|
||||
onclick="ToggleTwisty(event);"/>
|
||||
<text value="rdf:urn:http-index-format:Filename"/>
|
||||
</treecell>
|
||||
<treecell><text value="rdf:urn:http-index-format:Content-Length"/></treecell>
|
||||
<treecell><text value="rdf:urn:http-index-format:Last-Modified"/></treecell>
|
||||
</treerow>
|
||||
|
|
|
@ -21,3 +21,18 @@
|
|||
Style rules specific to the directory listing window.
|
||||
|
||||
*/
|
||||
|
||||
treecell > titledbutton {
|
||||
border: none;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
treeitem[type="FILE"] > treerow > treecell > titledbutton.twisty {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
treeitem[type="FILE"] > treerow > treecell.Filename:hover {
|
||||
color: #333366;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,69 @@ function Init()
|
|||
}
|
||||
|
||||
|
||||
function OnDblClick(event)
|
||||
{
|
||||
var item = event.target.parentNode.parentNode;
|
||||
var url = item.getAttribute('id');
|
||||
|
||||
var type = item.getAttribute('type');
|
||||
if (type == 'DIRECTORY') {
|
||||
// open inline
|
||||
dump('reading directory ' + url + '\n');
|
||||
ReadDirectory(url);
|
||||
}
|
||||
else {
|
||||
dump('navigating to ' + url + '\n');
|
||||
window.content.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ToggleTwisty(event)
|
||||
{
|
||||
var item = event.target.parentNode.parentNode.parentNode;
|
||||
if (item.getAttribute('open') == 'true') {
|
||||
item.removeAttribute('open');
|
||||
}
|
||||
else {
|
||||
var url = item.getAttribute('id');
|
||||
ReadDirectory(url);
|
||||
item.setAttribute('open', 'true');
|
||||
}
|
||||
|
||||
// XXX need to cancel the event here!!!
|
||||
}
|
||||
|
||||
|
||||
var Read = new Array();
|
||||
|
||||
function ReadDirectory(url)
|
||||
{
|
||||
if (Read[url]) {
|
||||
dump("directory already read\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var ios = Components.classes['component://netscape/network/net-service'].getService();
|
||||
ios = ios.QueryInterface(Components.interfaces.nsIIOService);
|
||||
dump("ios = " + ios + "\n");
|
||||
|
||||
var uri = ios.NewURI(url, null);
|
||||
dump("uri = " + uri + "\n");
|
||||
|
||||
var channel = ios.NewChannelFromURI('load', uri, null);
|
||||
dump("channel = " + channel + "\n");
|
||||
|
||||
var listener = HTTPIndex.CreateListener();
|
||||
dump("listener = " + listener + "\n");
|
||||
|
||||
channel.AsyncRead(0, -1, null, listener);
|
||||
|
||||
Read[url] = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// We need this hack because we've completely circumvented the onload() logic.
|
||||
function Boot()
|
||||
{
|
||||
|
@ -45,3 +108,5 @@ function Boot()
|
|||
}
|
||||
|
||||
setTimeout("Boot()", 0);
|
||||
|
||||
|
||||
|
|
|
@ -27,16 +27,23 @@
|
|||
title="&directoryWindowTitle.label;"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
align="vertical">
|
||||
align="vertical"
|
||||
ondblclick="OnDblClick(event);">
|
||||
|
||||
<html:script src="directory.js" />
|
||||
|
||||
<tree id="tree" datasources="rdf:null" flex="1">
|
||||
<template>
|
||||
<treechildren>
|
||||
<treeitem uri="...">
|
||||
<treeitem uri="..." type="rdf:urn:http-index-format:File-Type">
|
||||
<treerow>
|
||||
<treecell><text value="rdf:urn:http-index-format:Filename"/></treecell>
|
||||
<treecell class="Filename">
|
||||
<treeindentation/>
|
||||
<titledbutton class="twisty"
|
||||
treeallowevents="true"
|
||||
onclick="ToggleTwisty(event);"/>
|
||||
<text value="rdf:urn:http-index-format:Filename"/>
|
||||
</treecell>
|
||||
<treecell><text value="rdf:urn:http-index-format:Content-Length"/></treecell>
|
||||
<treecell><text value="rdf:urn:http-index-format:Last-Modified"/></treecell>
|
||||
</treerow>
|
||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
|||
// an OnStartRequest() notification
|
||||
nsIContentViewerContainer* mContainer; // [WEAK]
|
||||
|
||||
char* mBaseURL;
|
||||
nsCString mBaseURL;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mDataSource;
|
||||
|
||||
|
@ -539,6 +539,26 @@ nsHTTPIndexParser::ParseData(const char* aDataStr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Because the 'file:' protocol won't do this for us, we need to
|
||||
// make sure that the mDirectoryURI ends with a '/' before
|
||||
// concatenating.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> realbase;
|
||||
|
||||
{
|
||||
nsXPIDLCString orig;
|
||||
rv = mDirectoryURI->GetSpec(getter_Copies(orig));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString basestr(orig);
|
||||
if (basestr.Last() != '/')
|
||||
basestr.Append('/');
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(realbase), (const char*) basestr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
||||
// First, we'll iterate through the values and remember each (using
|
||||
// an array of autostrings allocated on the stack, if possible). We
|
||||
// have to do this, because we don't know up-front the filename for
|
||||
|
@ -552,7 +572,7 @@ nsHTTPIndexParser::ParseData(const char* aDataStr)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFResource> entry;
|
||||
|
||||
for (PRInt32 field = 0; field < mFormat.Count(); ++field) {
|
||||
|
@ -589,12 +609,8 @@ nsHTTPIndexParser::ParseData(const char* aDataStr)
|
|||
|
||||
if (mFormat.ElementAt(field) == kHTTPIndex_Filename) {
|
||||
// we found the filename; construct a resource for its entry
|
||||
nsXPIDLCString base;
|
||||
rv = mDirectory->GetValue(getter_Copies(base));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
nsAutoString entryuri;
|
||||
rv = NS_MakeAbsoluteURI(value, mDirectoryURI, entryuri);
|
||||
rv = NS_MakeAbsoluteURI(value, realbase, entryuri);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable make absolute URI");
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
|
@ -651,9 +667,12 @@ nsHTTPIndex::Init(nsIURI* aBaseURL)
|
|||
|
||||
nsresult rv;
|
||||
|
||||
rv = aBaseURL->GetSpec(&mBaseURL);
|
||||
nsXPIDLCString url;
|
||||
rv = aBaseURL->GetSpec(getter_Copies(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mBaseURL = url;
|
||||
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull,
|
||||
nsCOMTypeInfo<nsIRDFDataSource>::GetIID(),
|
||||
|
@ -684,8 +703,6 @@ nsHTTPIndex::Create(nsIURI* aBaseURL, nsIContentViewerContainer* aContainer, nsI
|
|||
|
||||
nsHTTPIndex::~nsHTTPIndex()
|
||||
{
|
||||
if (mBaseURL)
|
||||
nsAllocator::Free(mBaseURL);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTTPIndex);
|
||||
|
|
Загрузка…
Ссылка в новой задаче