⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spell-check-body.jsp

📁 Jive Forums 论坛源码 v4.2.3
💻 JSP
字号:
<% 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">
<%!
    static final Object obj = new Object();
%>
<%
    String text = ParamUtils.getParameter(request, "content", false);
    SpellSession spellSession = SpellChecker.createSession(text);
    HashMap suggestionMap = new HashMap();
    LongHashMap duplicatedWords = new LongHashMap();
    int result;
    int c = 0;
    if (text != null) {
        while ((result = spellSession.next()) != SpellSession.OK) {
            if (result == SpellSession.DOUBLED_WORD) {
                duplicatedWords.put(c, spellSession.getWord());
            }
            else 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 (suggestionMap.get(word) == null) {
                        String values = "";
                        String delim = "";
                        for (int i = 0; i < str.length; i++) {
                            String s = str[i];
                            values += delim;
                            values += s;
                            delim = ",";
                        }
                        suggestionMap.put(word, values);
                    }
                }

                duplicatedWords.put(c, obj);
            }

            spellSession.ignore();
            c++;
        }
    }
%>
<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 = suggestionMap.keySet().iterator(); iterator.hasNext();) {
          String key = (String) iterator.next();
          String values = (String) suggestionMap.get(key);
      %>
  <%= delim %>"<%= key %>":"<%= values %>"<%
          delim = ",";
      } %>
  };
  var duplicated_words = {<%
        delim = "";
        long[] keys = duplicatedWords.keys();
        for(int i = 0; i < keys.length; i++) {
            long key = keys[i];
            if (!duplicatedWords.get(key).equals(obj)) {

        %>
  <%= delim %>"key<%= key %>":"<%= "true" %>"<%
                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>");

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


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

⌨️ 快捷键说明

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