Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2007-03-13 19:53:10 -0400
committerChris Goldthorpe2007-03-13 19:53:10 -0400
commit221476c1902f1ac4d9cc9b0e0b0af62d706e4698 (patch)
treee91e6e3639f791189a80681b8ac9e31dd1113448
parentb98686684fdc257854122ffcb21c746e42a54f89 (diff)
downloadeclipse.platform.ua-221476c1902f1ac4d9cc9b0e0b0af62d706e4698.tar.gz
eclipse.platform.ua-221476c1902f1ac4d9cc9b0e0b0af62d706e4698.tar.xz
eclipse.platform.ua-221476c1902f1ac4d9cc9b0e0b0af62d706e4698.zip
Changes to Webapp Index view to handle the index attached to Bug153037. Special characters were causing problems.
-rw-r--r--org.eclipse.help.webapp/advanced/indexView.css7
-rw-r--r--org.eclipse.help.webapp/advanced/indexView.js49
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java4
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java95
4 files changed, 104 insertions, 51 deletions
diff --git a/org.eclipse.help.webapp/advanced/indexView.css b/org.eclipse.help.webapp/advanced/indexView.css
index a7a084a77..efe2781bc 100644
--- a/org.eclipse.help.webapp/advanced/indexView.css
+++ b/org.eclipse.help.webapp/advanced/indexView.css
@@ -113,7 +113,7 @@ INPUT {
}
DIV.root {
- font-weight:bold;
+ font-weight:normal;
}
DIV.visible, DIV.unopened {
@@ -149,6 +149,7 @@ IMG.expander, IMG.h {
A {
text-decoration:none;
padding-<%=isRTL?"left":"right"%>:2px;
+ color:WindowText;
/* this works in ie5.5, but not in ie5.0 */
white-space: nowrap;
}
@@ -166,10 +167,6 @@ A.active:hover{
text-decoration:underline;
}
-A.enabled, A:link, A:visited {
- color:blue;
-}
-
<%
if (requestData.isSafari()){
%>
diff --git a/org.eclipse.help.webapp/advanced/indexView.js b/org.eclipse.help.webapp/advanced/indexView.js
index c938b2e02..3dcf76b32 100644
--- a/org.eclipse.help.webapp/advanced/indexView.js
+++ b/org.eclipse.help.webapp/advanced/indexView.js
@@ -18,6 +18,8 @@ var shown = false;
var typeinPrevious = "";
var typein;
var lines = 30;
+var firstEntry;
+var lastEntry;
/**
* Set value of the typein input field.
@@ -107,7 +109,7 @@ function updateImage(imageNode, isExpanded) {
Remove any existing children and read new ones
*/
-function loadChildren(startCharacters, mode) {
+function loadChildren(startCharacters, mode, entry) {
var parameters = "";
var treeRoot = document.getElementById("tree_root");
if (treeRoot !== null) {
@@ -123,7 +125,7 @@ function loadChildren(startCharacters, mode) {
var separator = "?";
if (startCharacters) {
parameters += "?start=";
- parameters += startCharacters;
+ parameters += encodeURIComponent(startCharacters);
separator = "&";
}
if (lines) {
@@ -136,6 +138,12 @@ function loadChildren(startCharacters, mode) {
parameters += separator;
parameters += "mode=";
parameters += mode;
+ separator = "&";
+ }
+ if (entry) {
+ parameters += separator;
+ parameters += "entry=";
+ parameters += entry;
}
makeNodeRequest(parameters);
}
@@ -180,27 +188,34 @@ function makeNodeRequest(parameters) {
ajaxRequest(href, callback, errorCallback);
}
-function loadPreviousPage() {
- // Find the key of the first index entry
+// Cache the first and last so that if a request fails we don't lose our place
+function getFirstAndLast() {
var treeRoot = document.getElementById("tree_root");
if (treeRoot == null) return;
- var childDiv = findChild(treeRoot, "DIV");
- var anchor = findAnchor(childDiv);
- if (anchor && anchor.title) {
- loadChildren(anchor.title, "previous");
+ var firstDiv = findChild(treeRoot, "DIV");
+ if (firstDiv.nodeid) {
+ firstEntry = firstDiv.nodeid.substring(1);
+ }
+ var lastDiv = findLastChild(treeRoot, "DIV");
+
+ if (lastDiv.nodeid) {
+ lastEntry = lastDiv.nodeid.substring(1);
+ }
+}
+
+function loadPreviousPage() {
+ getFirstAndLast();
+ if (firstEntry) {
+ loadChildren("", "previous", firstEntry);
} else {
loadChildren("");
}
}
function loadNextPage() {
- // Find the key of the last index entry
- var treeRoot = document.getElementById("tree_root");
- if (treeRoot == null) return;
- var childDiv = findLastChild(treeRoot, "DIV");
- var anchor = findAnchor(childDiv);
- if (anchor && anchor.title) {
- loadChildren(anchor.title, "next");
+ getFirstAndLast();
+ if (lastEntry) {
+ loadChildren("", "next", lastEntry);
} else {
loadChildren("");
}
@@ -273,7 +288,3 @@ function typeinKeyDownHandler(e) {
function intervalHandler() {
typeinChanged();
}
-
-
-
-
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java
index 4df0952df..761181434 100644
--- a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java
@@ -65,7 +65,7 @@ public class EnabledTopicUtils {
for (int i=0;i<entries.length;++i) {
if (!isEnabled(entries[i])) {
List list = new ArrayList(entries.length);
- for (int j=0;j<entries.length;++i) {
+ for (int j=0;j<entries.length;++j) {
if (j < i || isEnabled(entries[j])) {
list.add(entries[j]);
}
@@ -85,7 +85,7 @@ public class EnabledTopicUtils {
for (int i=0;i<topics.length;++i) {
if (!isEnabled(topics[i])) {
List list = new ArrayList(topics.length);
- for (int j=0;j<topics.length;++i) {
+ for (int j=0;j<topics.length;++j) {
if (j < i || isEnabled(topics[j])) {
list.add(topics[j]);
}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java
index d1f642064..9e7520cdc 100644
--- a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java
@@ -45,23 +45,26 @@ public class IndexFragmentServlet extends HttpServlet {
private static Map locale2Response = new WeakHashMap();
private String startParameter;
private String sizeParameter;
+ private String entryParameter;
private String modeParameter;
private int size;
+ private int entry;
private static final String NEXT = "next"; //$NON-NLS-1$
private static final String PREVIOUS = "previous"; //$NON-NLS-1$
+ private static final String SIZE = "size"; //$NON-NLS-1$
+ private static final String MODE = "mode"; //$NON-NLS-1$
+ private static final String ENTRY = "entry"; //$NON-NLS-1$
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String locale = UrlUtil.getLocale(req, resp);
startParameter = req.getParameter("start"); //$NON-NLS-1$
- if (startParameter == null) {
- startParameter = ""; //$NON-NLS-1$
- } else {
+ if (startParameter != null) {
startParameter = startParameter.toLowerCase();
}
-
+
size = 30;
- sizeParameter = req.getParameter("size"); //$NON-NLS-1$
+ sizeParameter = req.getParameter(SIZE);
if (sizeParameter != null) {
try {
size = Integer.parseInt(sizeParameter);
@@ -69,7 +72,16 @@ public class IndexFragmentServlet extends HttpServlet {
}
}
- modeParameter = req.getParameter("mode"); //$NON-NLS-1$
+ entry = -1;
+ entryParameter = req.getParameter(ENTRY);
+ if (entryParameter != null) {
+ try {
+ entry = Integer.parseInt(entryParameter);
+ } catch (NumberFormatException n) {
+ }
+ }
+
+ modeParameter = req.getParameter(MODE);
req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
resp.setContentType("application/xml; charset=UTF-8"); //$NON-NLS-1$
@@ -132,7 +144,8 @@ public class IndexFragmentServlet extends HttpServlet {
}
}
for (Iterator iter = entryList.iterator(); iter.hasNext();) {
- generateEntry((IIndexEntry)iter.next(), 0);
+ Integer entryId = (Integer)iter.next();
+ generateEntry(entries[entryId.intValue()], 0, "e" + entryId.intValue()); //$NON-NLS-1$
}
}
String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tree_data enableNext = \"" //$NON-NLS-1$
@@ -140,21 +153,54 @@ public class IndexFragmentServlet extends HttpServlet {
buf.append("</tree_data>\n"); //$NON-NLS-1$
return header + buf.toString();
}
+
+ private int getCategory(String keyword) {
+ if (keyword != null && keyword.length() > 0) {
+ char c = keyword.charAt(0);
+ if (Character.isDigit(c)) {
+ return 2;
+ } else if (Character.isLetter(c)) {
+ return 3;
+ }
+ return 1;
+ }
+ return 4;
+ }
+
+ private int compare (String left, String right) {
+ int catLeft = getCategory(left);
+ int catRight = getCategory(right);
+ if (catLeft != catRight) {
+ return catLeft - catRight;
+ } else {
+ return left.compareTo(right);
+ }
+ }
private int findFirstEntry(IIndexEntry[] entries) {
+ if (NEXT.equals(modeParameter)) {
+ if (entry >= entries.length - 1) {
+ return entries.length - 1;
+ } else {
+ return entry + 1;
+ }
+ }
+ if (PREVIOUS.equals(modeParameter)) {
+ if (entry <= 0) {
+ return 0;
+ } else {
+ return entry - 1;
+ }
+ }
+ if (startParameter == null) {
+ return 0;
+ }
int nextEntry = 0;
while (nextEntry < entries.length) {
String keyword = entries[nextEntry].getKeyword().toLowerCase();
- if (keyword != null) {
- if (NEXT.equals(modeParameter)) {
- // Go past the startParameter if there is an exact match
- if (startParameter.compareTo(keyword) < 0) {
- break;
- }
- } else {
- if (startParameter.compareTo(keyword) <= 0) {
- break;
- }
+ if (keyword != null) {
+ if (compare(startParameter, keyword) <= 0) {
+ break;
}
}
nextEntry++;
@@ -166,7 +212,7 @@ public class IndexFragmentServlet extends HttpServlet {
while (nextEntry < entries.length) {
int entrySize = enabledEntryCount(entries[nextEntry]);
if (remaining == size || remaining > entrySize) {
- entryList.add(entries[nextEntry]);
+ entryList.add(new Integer(nextEntry));
setFlags(nextEntry);
remaining -= entrySize;
} else {
@@ -182,7 +228,7 @@ public class IndexFragmentServlet extends HttpServlet {
while (nextEntry >= 0) {
int entrySize = enabledEntryCount(entries[nextEntry]);
if (remaining == size || remaining > entrySize) {
- entryList.add(0, entries[nextEntry]);
+ entryList.add(0, new Integer(nextEntry));
setFlags(nextEntry);
remaining -= entrySize;
@@ -230,7 +276,7 @@ public class IndexFragmentServlet extends HttpServlet {
enablePrevious = false;
}
- private void generateEntry(IIndexEntry entry, int level) {
+ private void generateEntry(IIndexEntry entry, int level, String id) {
if (!EnabledTopicUtils.isEnabled(entry)) return;
if (entry.getKeyword() != null && entry.getKeyword().length() > 0) {
ITopic[] topics = EnabledTopicUtils.getEnabled(entry.getTopics());
@@ -243,14 +289,13 @@ public class IndexFragmentServlet extends HttpServlet {
buf.append('\n' + " title=\"" + XMLGenerator.xmlEscape(entry.getKeyword()) + '"'); //$NON-NLS-1$
}
- count++;
- buf.append('\n' + " id=\"i" + count + '"'); //$NON-NLS-1$
+ buf.append('\n' + " id=\"" + id + '"'); //$NON-NLS-1$
String href;
if (singleTopic) {
href = UrlUtil.getHelpURL((entry.getTopics()[0]).getHref());
buf.append('\n' + " href=\"" + //$NON-NLS-1$
- XMLGenerator.xmlEscape(UrlUtil.getHelpURL(href)) + "\""); //$NON-NLS-1$
+ XMLGenerator.xmlEscape(href) + "\""); //$NON-NLS-1$
}
buf.append(">\n"); //$NON-NLS-1$
@@ -266,7 +311,7 @@ public class IndexFragmentServlet extends HttpServlet {
private void generateSubentries(IIndexEntry entry, int level) {
IIndexEntry[] subentries = entry.getSubentries();
for (int i=0;i<subentries.length;++i) {
- generateEntry(subentries[i], level);
+ generateEntry(subentries[i], level, "s" + count++); //$NON-NLS-1$
}
}
@@ -292,7 +337,7 @@ public class IndexFragmentServlet extends HttpServlet {
buf.append('\n' + " id=\"i" + count + '"'); //$NON-NLS-1$
String href = UrlUtil.getHelpURL(topic.getHref());
buf.append('\n' + " href=\"" //$NON-NLS-1$
- + XMLGenerator.xmlEscape(UrlUtil.getHelpURL(href)) + "\""); //$NON-NLS-1$
+ + XMLGenerator.xmlEscape(href) + "\""); //$NON-NLS-1$
buf.append(">\n"); //$NON-NLS-1$
buf.append("</node>\n"); //$NON-NLS-1$

Back to the top