rejetto forum
May 23, 2012, 06:59:42 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: in list,how to display the file if %item-name% is a jpg/gif?  (Read 3236 times)
0 Members and 1 Guest are viewing this topic.
vervethe
Occasional poster
*
Offline Offline

Posts: 6


View Profile
« on: October 18, 2005, 12:03:05 AM »

in list,how to display the file if file is a jpg/gif?
in Template,[file] section,default code is
Code:
[file]
<tr><td class=row>%new% <a href="%item-url%"><img align=top src="/~img_file"> %item-name%</a>%comment%<td class="row right">%item-size%<td class="row right">%item-modified%<td class="row right">%item-dl-count%
i want to check %item-name%,if the file is a jpg or gif,then display the file  instead of “/~img_file”.how to write the [file] section code?
Logged

rc.263.net----vervethe.*
qq12936867
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11826


View Profile
« Reply #1 on: October 19, 2005, 11:59:42 AM »

i think it can be done with javascript
will someone spend a little time doing it? Smiley
Logged
Anonymous
Guest
« Reply #2 on: January 10, 2006, 11:50:23 PM »

will someone do it?
Logged
Anonymous
Guest
« Reply #3 on: January 11, 2006, 11:27:00 AM »

Code:
<script language="jscript">

if (  '%item-name%'.match(/(\.jpg)|(\.gif)$/i)  )
document.write('<tr><td class=row>%new% <a href="%item-url%"><img align=top src="%item-url%"> %item-name%</a>%comment%<td class="row right">%item-size%<td class="row right">%item-modified%<td class="row right">%item-dl-count%');
else
document.write('<tr><td class=row>%new% <a href="%item-url%"><img align=top src="/~img_file"> %item-name%</a>%comment%<td class="row right">%item-size%<td class="row right">%item-modified%<td class="row right">%item-dl-count%');

</script>
Logged
vervethe
Occasional poster
*
Offline Offline

Posts: 6


View Profile
« Reply #4 on: January 12, 2006, 03:10:42 PM »

also:

Code:
[file]
<tr><td class=row>%new% <a href="%item-url%">
<script language="jscript">
if (  '%item-name%'.match(/\.(jpg)|(gif)|(png)$/i)  ) document.write('<img align=top src="%item-url%"> ');
else if (  '%item-name%'.match(/\.wav$/i)  ) document.write('<img align=top src="/imgs/sound.gif"> ');
else if (  '%item-name%'.match(/\.dll$/i)  ) document.write('<img align=top src="/imgs/dll_13[].gif"> ');
else if (  '%item-name%'.match(/\.m4a$/i)  ) document.write('<img align=top src="/imgs/leaf_G_13[].gif"> ');
else if (  '%item-name%'.match(/\.doc$/i)  ) document.write('<img align=top src="/imgs/paper_13[].gif"> ');
else if (  '%item-name%'.match(/\.lrc$/i)  ) document.write('<img align=top src="/imgs/Icon47_13[].gif"> ');
else if (  '%item-name%'.match(/\.txt$/i)  ) document.write('<img align=top src="/imgs/txt__13[].gif"> ');
else if (  '%item-name%'.match(/\.url$/i)  ) document.write('<img align=top src="/imgs/Pointer_or_url__13[].gif"> ');
else if (  '%item-name%'.match(/\.htm$/i)  ) document.write('<img align=top src="/imgs/net doc_13[].gif"> ');
else if (  '%item-name%'.match(/\.exe$/i)  ) document.write('<img align=top src="/imgs/runnerA_13[].gif"> ');
else if (  '%item-name%'.match(/\.(zip)|(rar)$/i)  ) document.write('<img align=top src="/imgs/ar_11_8_13[]_orange.gif"> ');
else if (  '%item-name%'.match(/\.ini$/i)  ) document.write('<img align=top src="/imgs/ini__13[].gif"> ');
else document.write('<img align=top src="/~img_file"> ');
</script>
%item-name%</a>%comment%<td class="row right">%item-size%<td class="row right">%item-modified%<td class="row right">%item-dl-count%
Logged

rc.263.net----vervethe.*
qq12936867
vervethe
Occasional poster
*
Offline Offline

Posts: 6


View Profile
« Reply #5 on: January 13, 2006, 03:55:55 AM »

but contructing regular express is slow.

this is better:
Code:
<tr><td class=row>%new% <a href="%item-url%">
<script language="jscript">
var c='%item-name%';
switch (  c.substr(  c.lastIndexOf('.')  ) .toLowerCase()  )
{
case '.txt' : document.write('<img align=top src="/imgs/txt__13[].gif"> ');break;
case '.htm' : case '.html' : document.write('<img align=top src="/imgs/net doc_13[].gif"> ');break;
case '.url' : case '.lnk' : document.write('<img align=top src="/imgs/Pointer_or_url__13[].gif"> ');break;
case '.exe' : case '.com' : document.write('<img align=top src="/imgs/runnerA_13[].gif"> ');break;
case '.dll' : document.write('<img align=top src="/imgs/dll_13[].gif"> ');break;
case '.zip' : case '.rar' : document.write('<img align=top src="/imgs/ar_11_8_13[]_orange.gif"> ');break;
case '.jpg' :case '.jpeg': case '.gif' : case '.png' :case '.ico':case '.bmp': document.write('<img align=top src="%item-url%"> ');break;
case '.wav':case '.aiff':case '.au':case '.cda':case '.ape': document.write('<img align=top src="/imgs/sound.gif"> ');break;
case '.m4a' : case '.mp4' : case '.aac' : document.write('<img align=top src="/imgs/leaf_G_13[].gif"> ');break;
case '.ogg':case '.wma':case '.mp3':case '.ra':case '.mpc': document.write('<img align=top src="/imgs/leaf.gif"> ');break;
case '.mid' : document.write('<img align=top src="/imgs/bowstr_13[].gif"> ');break;
case '.wmv':case '.rm':case '.rmvb':case '.avi':case '.dat': document.write('<img align=top src="/imgs/screen_9_6_13[].gif"> ');break;
case '.doc' : document.write('<img align=top src="/imgs/paper_13[].gif"> ');break;
case '.lrc' : document.write('<img align=top src="/imgs/Icon47_13[].gif"> ');break;
case '.ini' : case '.inf' : document.write('<img align=top src="/imgs/ini__13[].gif"> ');break;
case '.js':case '.vbs': document.write('<img align=top src="/imgs/winScript_13[].gif"> ');break;
case '.fnd': document.write('<img align=top src="/imgs/searCH.gif"> ');break;
case '.sf2':case '.akp':case '.exs':case '.fxp':case '.sxt':case '.nki': document.write('<img align=top src="/imgs/guitar_13[].gif"> ');break;
default : document.write('<img align=top src="/~img_file"> ');
}
</script>
%item-name%</a>%comment%<td class="row right">%item-size%<td class="row right">%item-modified%<td class="row right">%item-dl-count%
Logged

rc.263.net----vervethe.*
qq12936867
rejetto forum
« Reply #5 on: January 13, 2006, 03:55:55 AM »

Do you like this software? Consider even $2
 Logged
Anonymous
Guest
« Reply #6 on: January 21, 2006, 07:53:09 PM »

better use
<script language="javascript">

rather than
<script language="jscript">

works in mozilla based, then.
Thank you for this, real good work!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page May 07, 2012, 09:02:41 PM
anything