Add animation to directory viewer.

This commit is contained in:
waterson%netscape.com 1999-09-21 21:43:41 +00:00
parent 710eaa86d3
commit 095f7718ee
6 changed files with 41 additions and 14 deletions

View File

@ -109,7 +109,11 @@ function ToggleOpenState(treeitem)
if (treeitem.getAttribute('open') == 'true') {
var url = treeitem.getAttribute('id');
ReadDirectory(url);
if (!Read[url]) {
treeitem.setAttribute('loading', 'true');
ReadDirectory(url);
Read[url] = true;
}
}
}
@ -119,10 +123,6 @@ var Read = new Array();
function ReadDirectory(url)
{
// Check to make sure we haven't read the directory yet...
if (Read[url])
return;
debug('ReadDirectory(' + url + ')\n');
var ios = Components.classes['component://netscape/network/net-service'].getService();
@ -136,7 +136,6 @@ function ReadDirectory(url)
// ...so that we can pipe it into a new HTTPIndex listener to
// parse the directory's contents.
channel.AsyncRead(0, -1, null, HTTPIndex.CreateListener());
Read[url] = true;
}

View File

@ -41,7 +41,9 @@
template engine. We need to hack it this way because,
if we don't, the tree control will assume that the item
shouldn't have a twisty next to it -->
<treeitem uri="..." type="rdf:urn:http-index-format:File-Type" container="true">
<treeitem uri="..." type="rdf:urn:http-index-format:File-Type"
loading="rdf:urn:http-index-format:Loading"
container="true">
<treerow>
<treecell class="filename" indent="true"
value="rdf:urn:http-index-format:Filename"/>

View File

@ -31,6 +31,11 @@ treeitem[type="FILE"] > treerow > treecell > .tree-icon > .twisty {
list-style-image: none;
}
/* Show an animated icon when a directory is loading */
treeitem[type="DIRECTORY"][loading="true"] > treerow > treecell > .tree-icon > .twisty {
list-style-image: url("resource:/res/rdf/loading.gif");
}
/* Make a file look like a link */
treeitem[type="FILE"] > treerow > treecell.filename {
color: #666699;

View File

@ -109,7 +109,11 @@ function ToggleOpenState(treeitem)
if (treeitem.getAttribute('open') == 'true') {
var url = treeitem.getAttribute('id');
ReadDirectory(url);
if (!Read[url]) {
treeitem.setAttribute('loading', 'true');
ReadDirectory(url);
Read[url] = true;
}
}
}
@ -119,10 +123,6 @@ var Read = new Array();
function ReadDirectory(url)
{
// Check to make sure we haven't read the directory yet...
if (Read[url])
return;
debug('ReadDirectory(' + url + ')\n');
var ios = Components.classes['component://netscape/network/net-service'].getService();
@ -136,7 +136,6 @@ function ReadDirectory(url)
// ...so that we can pipe it into a new HTTPIndex listener to
// parse the directory's contents.
channel.AsyncRead(0, -1, null, HTTPIndex.CreateListener());
Read[url] = true;
}

View File

@ -41,7 +41,9 @@
template engine. We need to hack it this way because,
if we don't, the tree control will assume that the item
shouldn't have a twisty next to it -->
<treeitem uri="..." type="rdf:urn:http-index-format:File-Type" container="true">
<treeitem uri="..." type="rdf:urn:http-index-format:File-Type"
loading="rdf:urn:http-index-format:Loading"
container="true">
<treerow>
<treecell class="filename" indent="true"
value="rdf:urn:http-index-format:Filename"/>

View File

@ -115,6 +115,8 @@ protected:
static nsIRDFService* gRDF;
static nsIRDFResource* kHTTPIndex_Comment;
static nsIRDFResource* kHTTPIndex_Filename;
static nsIRDFResource* kHTTPIndex_Loading;
static nsIRDFLiteral* kTrueLiteral;
static nsresult ParseLiteral(const nsString& aValue, nsIRDFNode** aResult);
static nsresult ParseDate(const nsString& aValue, nsIRDFNode** aResult);
@ -171,6 +173,8 @@ nsrefcnt nsHTTPIndexParser::gRefCnt = 0;
nsIRDFService* nsHTTPIndexParser::gRDF;
nsIRDFResource* nsHTTPIndexParser::kHTTPIndex_Comment;
nsIRDFResource* nsHTTPIndexParser::kHTTPIndex_Filename;
nsIRDFResource* nsHTTPIndexParser::kHTTPIndex_Loading;
nsIRDFLiteral* nsHTTPIndexParser::kTrueLiteral;
nsHTTPIndexParser::Field
nsHTTPIndexParser::gFieldTable[] = {
@ -218,6 +222,12 @@ nsHTTPIndexParser::Init()
rv = gRDF->GetResource(HTTPINDEX_NAMESPACE_URI "Filename", &kHTTPIndex_Filename);
if (NS_FAILED(rv)) return rv;
rv = gRDF->GetResource(HTTPINDEX_NAMESPACE_URI "Loading", &kHTTPIndex_Loading);
if (NS_FAILED(rv)) return rv;
rv = gRDF->GetLiteral(nsAutoString("true").GetUnicode(), &kTrueLiteral);
if (NS_FAILED(rv)) return rv;
for (Field* field = gFieldTable; field->mName; ++field) {
nsCAutoString str;
str += HTTPINDEX_NAMESPACE_URI;
@ -235,6 +245,8 @@ nsHTTPIndexParser::~nsHTTPIndexParser()
if (--gRefCnt == 0) {
NS_IF_RELEASE(kHTTPIndex_Comment);
NS_IF_RELEASE(kHTTPIndex_Filename);
NS_IF_RELEASE(kHTTPIndex_Loading);
NS_IF_RELEASE(kTrueLiteral);
for (Field* field = gFieldTable; field->mName; ++field) {
NS_IF_RELEASE(field->mProperty);
@ -372,6 +384,10 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext)
rv = rdfc->MakeSeq(mDataSource, mDirectory, getter_AddRefs(mDirectoryContainer));
if (NS_FAILED(rv)) return rv;
// Mark the directory as "loading"
rv = mDataSource->Assert(mDirectory, kHTTPIndex_Loading, kTrueLiteral, PR_TRUE);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
@ -401,6 +417,10 @@ nsHTTPIndexParser::OnStopRequest(nsIChannel* aChannel,
rv = mDataSource->Assert(mDirectory, kHTTPIndex_Comment, comment, PR_TRUE);
if (NS_FAILED(rv)) return rv;
// Remove the 'loading' annotation.
rv = mDataSource->Unassert(mDirectory, kHTTPIndex_Loading, kTrueLiteral);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}