Sha256: baf1dcb67966fedd18ad4b62350d0ff864a5ef51a7c54fb548d44cee575159fa

Contents?: true

Size: 1.37 KB

Versions: 12

Compression:

Stored size: 1.37 KB

Contents

<%@ page
	import="java.io.File,java.io.FilenameFilter,java.util.Arrays"%>
<%
/**
  * jQuery File Tree JSP Connector
  * Version 1.0
  * Copyright 2008 Joshua Gould
  * 21 April 2008
*/	
    String dir = request.getParameter("dir");
    if (dir == null) {
    	return;
    }
	
	if (dir.charAt(dir.length()-1) == '\\') {
    	dir = dir.substring(0, dir.length()-1) + "/";
	} else if (dir.charAt(dir.length()-1) != '/') {
	    dir += "/";
	}
	
	dir = java.net.URLDecoder.decode(dir, "UTF-8");	
	
    if (new File(dir).exists()) {
		String[] files = new File(dir).list(new FilenameFilter() {
		    public boolean accept(File dir, String name) {
				return name.charAt(0) != '.';
		    }
		});
		Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
		out.print("<ul class=\"jqueryFileTree\" style=\"display: none;\">");
		// All dirs
		for (String file : files) {
		    if (new File(dir, file).isDirectory()) {
				out.print("<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + dir + file + "/\">"
					+ file + "</a></li>");
		    }
		}
		// All files
		for (String file : files) {
		    if (!new File(dir, file).isDirectory()) {
				int dotIndex = file.lastIndexOf('.');
				String ext = dotIndex > 0 ? file.substring(dotIndex + 1) : "";
				out.print("<li class=\"file ext_" + ext + "\"><a href=\"#\" rel=\"" + dir + file + "\">"
					+ file + "</a></li>");
		    	}
		}
		out.print("</ul>");
    }
%>

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
milksteak-0.0.15 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.13 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.12 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.11 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.10 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.9 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.8 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.7 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.6 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.4 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.3 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp
milksteak-0.0.2 lib/public/milksteak/jqueryFileTree/connectors/jqueryFileTree.jsp