spell-check-body.jsp

来自「Jive Forums 论坛源码 v4.2.3」· JSP 代码 · 共 73 行

JSP
73
字号
<% response.setContentType("text/html; charset=" + JiveGlobals.getCharacterEncoding()); %>
<%@ page import="com.jivesoftware.util.*,
                 java.util.*,
                 com.jivesoftware.base.JiveGlobals" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
    String text = ParamUtils.getParameter(request, "content", false);
    SpellSession spellSession = SpellChecker.createSession(text);
    HashMap map = new HashMap();
    int result;
    if (text != null) {
        while ((result = spellSession.next()) != SpellSession.OK) {
            if (result == SpellSession.MISSPELLED_WORD) {
                String[] str = spellSession.getSuggestions();
                if (str.length > 0) {
                    String word = spellSession.getWord();
                    // if we haven't already seen this word
                    if (map.get(word) == null) {
                        String values = "";
                        String delim = "";
                        for (int i = 0; i < str.length; i++) {
                            String s = str[i];
                            values += delim;
                            values += s;
                            delim = ",";
                        }
                        map.put(word, values);
                    }
                }
            }
            spellSession.ignore();
        }
    }
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<%= JiveGlobals.getCharacterEncoding() %>" />
<link rel="stylesheet" type="text/css" media="all" href="spell-check-style.css" />
<link rel="stylesheet" type="text/css" media="all" href="../../../style.jsp" />
<script type="text/javascript">
  var suggested_words = {<%
      String delim = "";
      for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
          String key = (String) iterator.next();
          String values = (String) map.get(key);
      %>
  <%= delim %>"<%= key %>":"<%= values %>"<%
          delim = ",";
      } %>
  };
</script>
</head>
<body onload="window.parent.finishedSpellChecking();">
<%  String body = "";
    if (text != null) {
        spellSession = SpellChecker.createSession(text);
        spellSession.next();
        body = spellSession.getHighlightedText();
        body = StringUtils.replace(body, "<spellfirst>", "<span class=\"HA-spellcheck-error\">");
        body = StringUtils.replace(body, "</spellfirst>", "</span>");
        body = StringUtils.replace(body, "<spell>", "<span class=\"HA-spellcheck-error\">");
        body = StringUtils.replace(body, "</spell>", "</span>");
        body = StringUtils.replace(body, "</spell>", "</span>");

        // correct url's for emoticons
        body = StringUtils.replace(body, "\"images/emoticons/", "\"../../../images/emoticons/");


    }
%>
<%= body %>
</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?