list.jsp revision 138a7fea383af1a9084b7ec66d309d1cbc43d5f6
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinCDDL HEADER START
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThe contents of this file are subject to the terms of the
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCommon Development and Distribution License (the "License").
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonYou may not use this file except in compliance with the License.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinSee LICENSE.txt included in this distribution for the specific
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrewslanguage governing permissions and limitations under the License.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinWhen distributing Covered Code, include this CDDL HEADER in each
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrewsfile and include the License file at LICENSE.txt.
8a66318e41ed14c5a88130e8c362610e8faa2121Mark AndrewsIf applicable, add the following below this CDDL HEADER, with the
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrewsfields enclosed by brackets "[]" replaced with your own identifying
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrewsinformation: Portions Copyright [yyyy] [name of copyright owner]
75c0816e8295e180f4bc7f10db3d0d880383bc1cMark AndrewsCDDL HEADER END
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinCopyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein--%><%@ page import = "javax.servlet.*,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein%><%@include file="mast.jsp"%>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<% if (!isDir) { %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<script type="text/javascript">/* <![CDATA[ */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction lntoggle() {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein $("a").each(function() {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (this.className == 'l' || this.className == 'hl') {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein else if (this.className == 'l-hide' || this.className == 'hl-hide') {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein this.className=this.className.substr(0,this.className.indexOf('-'));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction get_sym_list_contents()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var contents = "";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein //contents += "<input id=\"input_highlight\" name=\"input_highlight\" class=\"q\"/>";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein //contents += " ";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein //contents += "<b><a href=\"#\" onclick=\"javascript:add_highlight();return false;\" title=\"Add highlight\">Highlight</a></b><br>";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein contents += "<a href=\"#\" onclick=\"javascript:lsttoggle();\">[Close]</a><br>"
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var symbol_classes = get_sym_list();
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein for (var i = 0; i < symbol_classes.length; i++) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (i > 0) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein contents += "<br/>";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var symbol_class = symbol_classes[i];
75c0816e8295e180f4bc7f10db3d0d880383bc1cMark Andrews contents += "<b>" + symbol_class[0] + "</b><br/>";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var class_name = symbol_class[1];
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var symbols = symbol_class[2];
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein for (var j = 0; j < symbols.length; j++) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var symbol = symbols[j][0];
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var line = symbols[j][1];
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein "<a href=\"#" + line + "\" class=\"" + class_name + "\">" +
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein escape_html(symbol) + "</a><br/>";
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson return contents;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafssonfunction escape_html(string) {
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson .replace("&", "&")
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson .replace("<", "<")
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson .replace(">", ">");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein// Initial value
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction get_sym_div_left()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div_left = $(window).width() - (document.sym_div_width + document.sym_div_left_margin);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction get_sym_div_height()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div_height = $(window).height() - document.sym_div_top - document.sym_div_height_margin;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (document.sym_div_height > document.sym_div_height_max)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div_height = document.sym_div_height_max;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction get_sym_div_top()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction get_sym_div_width()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction lsttoggle()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div = document.createElement("div");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.className = "sym_list_style";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.width = get_sym_div_width() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.height = get_sym_div_height() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.top = get_sym_div_top() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.left = get_sym_div_left() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.innerHTML = get_sym_list_contents();
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.className = "sym_list_style_hide";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.height = get_sym_div_height() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.width = get_sym_div_width() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.top = get_sym_div_top() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.left = get_sym_div_left() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.className = "sym_list_style";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein$(window).resize(
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.left = get_sym_div_left() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein document.sym_div.style.height = get_sym_div_height() + "px";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein// Highlighting
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein// This will replace link's href contents as well, be careful
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction HighlightKeywordsFullText(keywords)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var el = $("body");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein $(keywords).each(
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var pattern = new RegExp("("+this+")", ["gi"]);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var rs = "<span style='background-color:#FFFF00;font-weight: bold;'>$1</span>";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein//HighlightKeywordsFullText(["nfstcpsock"]);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein// This only changes matching tag's style
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction HighlightKeyword(keyword)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var high_colors=[
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var pattern = "a:contains('" + keyword + "')";
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein $(pattern).css({
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 'text-decoration' : 'underline',
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 'background-color' : high_colors[document.highlight_count % high_colors.length],
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 'font-weight' : 'bold'
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein//HighlightKeyword('timeval');
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfunction add_highlight()
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein var tbox = document.getElementById('input_highlight');
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein HighlightKeyword(tbox.value);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinString rev = null;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinif(!isDir && ef != null) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein } catch (IOException e) {
Project activeProject = Project.getProject(resourceFile);
//TODO: somehow integrate below with projects.jspf
Cookie[] cookies = request.getCookies();
if (cookie.getName().equals("OpenGrokProject")) {
for (String proj : cookie.getValue().split(",")) {
if (Project.getByDescription(proj) != null) {
project.add(proj);
if (activeProject.getDescription().equalsIgnoreCase(proj)) {
// set this in case there is no project selected or current cookie doesn't contain current project from the link, so the rest of search works 100% :)
StringBuffer sproject=new StringBuffer(activeProject.getDescription()+",");
Cookie cookie = new Cookie("OpenGrokProject", sproject.toString());
cookie.setPath(context + "/");
response.addCookie(cookie);
String[] files = resourceFile.list();
List<String> readMes = dl.listTo(resourceFile, out, path, files);
if(readMes != null && readMes.size() > 0) {
if (readmeFile.exists()) {
while((len = br.read(buf)) > 0) {
out.write(buf, 0, len);
br.close();
response.sendError(404, "Revision not found");
FileAnalyzerFactory a = AnalyzerGuru.find(basename);
Genre g = AnalyzerGuru.getGenre(a);
response.sendError(404, "Revision not found");
a = AnalyzerGuru.find(in);
g = AnalyzerGuru.getGenre(a);
%><div id="src">Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
if (g == Genre.PLAIN) {
Annotation annotation = annotate ? HistoryGuru.getInstance().annotate(resourceFile, rev) : null;
//annotation.writeTooltipMap(out); //not needed yet
} else if (g == Genre.IMAGE) {
%><img src="<%=context+Constants.rawP+path%>?r=<%=rev%>"/><%
} else if (g == Genre.HTML) {
while((len = br.read(buf)) > 0) {
out.write(buf, 0, len);
%> Click <a href="<%=context+Constants.rawP+path%>?r=<%=rev%>">download <%=basename%></a><%
%> <h3 class="error">IO Error</h3> <p> <%=e.getMessage() %> </p> <%
in.close();
} else if(g == Genre.IMAGE) {
%><div id="src"><img src="<%=context+Constants.rawP+path%>?r=<%=rev%>"/></div><%
%><div id="src"> Binary file [Click <a href="<%=context+Constants.rawP+path%>?r=<%=rev%>">here</a> to download] </div><%
if (environment.isCompressXref() ) {
if (xrefFile.exists()) {
if (xrefFile.exists()) {
while((len = br.read(buf)) > 0) {
out.write(buf, 0, len);
br.close();
FileAnalyzerFactory a = AnalyzerGuru.find(basename);
Genre g = AnalyzerGuru.getGenre(a);
a = AnalyzerGuru.find(bin);
g = AnalyzerGuru.getGenre(a);
if (g == Genre.IMAGE) {
%><div id="src"><img src="<%=context+Constants.rawP+path%>"/></div><%
} else if( g == Genre.HTML) {
while((len = br.read(buf)) > 0) {
out.write(buf, 0, len);
} else if(g == Genre.PLAIN) {
Definitions defs = IndexDatabase.getDefinitions(resourceFile);
Annotation annotation = annotate ? HistoryGuru.getInstance().annotate(resourceFile, rev) : null;
%> Click <a href="<%=context+Constants.rawP+path%>">download <%=basename%></a><%
bin.close();
%><%@include file="foot.jspf"%><%
ef.close();