-/* $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
* - 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
*/
"\n");
for (i in index) {
f = index[i];
- if (f.t == 'DIR')
- fh.write('<a href="' + f.l +
- '/index.html">' + f.l +
- "/</a><br>\n");
+ if (f.t == 'DIR') {
+ var t;
+
+ if ((t = dir_findthumb(path +
+ '/' + f.l)) != null)
+ fh.write('<a href="' +
+ f.l +
+ '/index.html">' +
+ '<img src="' +
+ f.l + '/' + t +
+ '"></a>' + "\n");
+ else
+ fh.write(
+ '<br><a href="' +
+ f.l +
+ '/index.html">' +
+ f.l +
+ "/</a><br>\n");
+ }
}
for (i in index) {
f = index[i];
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);