From: Matthew Mondor Date: Sun, 5 Nov 2006 13:27:16 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: pgsql-branch-merge~84 X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=4349094067446eb3cab5b61fe9b977f5aa60b7a9;p=mmondor.git *** empty log message *** --- diff --git a/mmsoftware/js/js-sh/app/thumb/thumb.js b/mmsoftware/js/js-sh/app/thumb/thumb.js index 381e40e..fff90ba 100644 --- a/mmsoftware/js/js-sh/app/thumb/thumb.js +++ b/mmsoftware/js/js-sh/app/thumb/thumb.js @@ -1,4 +1,4 @@ -/* $Id: thumb.js,v 1.4 2006/11/05 13:00:16 mmondor Exp $ */ +/* $Id: thumb.js,v 1.5 2006/11/05 13:27:16 mmondor Exp $ */ /* * Copyright (c) 2006, Matthew Mondor @@ -10,8 +10,6 @@ * - Implement getopt-like class and allow to provide command line arguments * - Generate multiple indexes with list of index links at top and bottom * for large directories - * - Instead of showing directory name link, show one of the thumbnails inside - * as clickable collection preview link * - Work on better presentation */ @@ -175,10 +173,25 @@ function thumbnail_dir(path, xmax, ymax) "\n"); for (i in index) { f = index[i]; - if (f.t == 'DIR') - fh.write('' + f.l + - "/
\n"); + if (f.t == 'DIR') { + var t; + + if ((t = dir_findthumb(path + + '/' + f.l)) != null) + fh.write('' + + '' + "\n"); + else + fh.write( + '
' + + f.l + + "/
\n"); + } } for (i in index) { f = index[i]; @@ -208,4 +221,32 @@ function thumbnail_dir(path, xmax, ymax) return ret; } +function dir_findthumb(path) +{ + var ret = null; + var dir, e, o, s = 0; + + for (;;) { + try { + dir = new Dir(path); + while ((e = dir.read()) != null) { + if (e.name.match(/_thumb/)) { + o = FS.stat(path + '/' + e.name); + if (o.st_size > s) + ret = e.name; + } + } + } catch (x) { + Syslog.log(Syslog.LOG_NOTICE, x.toString()); + break; + } + } + + try { + dir.close(); + } catch (x) {} + + return ret; +} + thumbnail_dir('/home/data/jshttpd/mmondor/testimg', 64, 64);