<NME> definition.jsp
<BEF> <%--
  ~ APDPlat - Application Product Development Platform
  ~ Copyright (c) 2013, 杨尚川, yang-shangchuan@qq.com
  ~
  ~  This program is free software: you can redistribute it and/or modify
  ~  it under the terms of the GNU General Public License as published by
  ~  the Free Software Foundation, either version 3 of the License, or
  ~  (at your option) any later version.
  ~
  ~  This program is distributed in the hope that it will be useful,
  ~  but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~  GNU General Public License for more details.
  ~
  ~  You should have received a copy of the GNU General Public License
  ~  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  --%>

<%@ page import="org.apdplat.superword.tools.WordLinker.Dictionary" %>
<%@ page import="org.apdplat.superword.tools.WordLinker" %>
<%@ page import="java.util.UUID" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="java.nio.file.Files" %>
<%@ page import="java.nio.file.Paths" %>
    if(word == null){
        word = "fantastic";
    }
    StringBuilder definitionHtmls = new StringBuilder();
    definitionHtmls.append("<table>")
                   .append("<tr><td>序号</td><td>词典</td><td>单词</td></tr>");
    int i=1;
    for(Dictionary dictionary : Dictionary.values()){
        String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();
        String definitionHtml = "<a href=\"#"+ UUID.randomUUID()+"\" onclick=\"viewDefinition('"+definitionURL+"', '"+word+"');\">"+word+"</a>";
        definitionHtmls.append("<tr><td>").append(i++).append("</td><td>").append(dictionary.getDes()).append("</td><td>").append(definitionHtml).append("</td></tr>");
    }
    definitionHtmls.append("</table>");
%>

<html>
    if(Files.exists(Paths.get(file))){
        data.put("hasOxfordAudio", true);
        oxfordAudios.add(word.toLowerCase());
        int i=2;
        while(Files.exists(Paths.get(application.getRealPath("/audio/oxford/"+word.toLowerCase()+"_"+i+".mp3")))){
            oxfordAudios.add(word.toLowerCase()+"_"+i++);
        }
        data.put("oxfordAudios", oxfordAudios);
    }else{
        data.put("hasOxfordAudio", false);
    }

    file = application.getRealPath("/audio/webster/"+word.toLowerCase()+".mp3");
    List<String> websterAudios = new ArrayList();
    if(Files.exists(Paths.get(file))){
        data.put("hasWebsterAudio", true);
        websterAudios.add(word.toLowerCase());
        int i=2;
        while(Files.exists(Paths.get(application.getRealPath("/audio/webster/"+word.toLowerCase()+"_"+i+".mp3")))){
            websterAudios.add(word.toLowerCase()+"_"+i++);
        }
        data.put("websterAudios", websterAudios);
    }else{
        data.put("hasWebsterAudio", false);
    }

    StringBuilder otherDictionary = new StringBuilder();
    for(Dictionary dictionary : Dictionary.values()){
        if(dictionary == Dictionary.ICIBA
                || dictionary == Dictionary.YOUDAO
                || dictionary == Dictionary.OXFORD
                || dictionary == Dictionary.WEBSTER){
            continue;
        }
        String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();
        String definitionHtml = "<a href=\"#"+ UUID.randomUUID()+"\" onclick=\"openWindow('"+definitionURL+"', '"+word+"');\">"+dictionary.getDes()+"</a>";
        otherDictionary.append(definitionHtml).append(" | ");
    }
    otherDictionary.setLength(otherDictionary.length() - 3);

    String icibaLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.ICIBA);
    String icibaDefinitionURL = icibaLinkPrefix+word+"&word="+word+"&dict="+Dictionary.ICIBA.name();
    String icibaDefinitionHtml = "<a href=\"#"+ UUID.randomUUID()+"\" onclick=\"openWindow('"+icibaDefinitionURL+"', '"+word+"');\">iCIBA definition</a>";

    String youdaoLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.YOUDAO);
    String youdaoDefinitionURL = youdaoLinkPrefix+word+"&word="+word+"&dict="+Dictionary.YOUDAO.name();
    String youdaoDefinitionHtml = "<a href=\"#" + UUID.randomUUID()+"\" onclick=\"openWindow('"+youdaoDefinitionURL+"', '"+word+"');\">Youdao definition</a>";

    String oxfordLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.OXFORD);
    String oxfordDefinitionURL = oxfordLinkPrefix+word+"&word="+word+"&dict="+Dictionary.OXFORD.name();
    String oxfordDefinitionHtml = "<a href=\"#" + UUID.randomUUID()+"\" onclick=\"openWindow('"+oxfordDefinitionURL+"', '"+word+"');\">Oxford definition</a>";

    String websterLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.WEBSTER);
    String websterDefinitionURL = websterLinkPrefix+word+"&word="+word+"&dict="+Dictionary.WEBSTER.name();
    String websterDefinitionHtml = "<a href=\"#" + UUID.randomUUID()+"\" onclick=\"openWindow('"+websterDefinitionURL+"', '"+word+"');\">Webster's definition</a>";

    data.put("icibaDefinitionHtml", icibaDefinitionHtml);
    data.put("youdaoDefinitionHtml", youdaoDefinitionHtml);
    data.put("icibaPronunciation", Pronunciation.getPronunciationString(Dictionary.ICIBA, word, " <font color=\"red\">|</font> "));
    data.put("icibaDefinition", Definition.getDefinitionString(Dictionary.ICIBA, word, "<br/>"));
    data.put("youdaoPronunciation", Pronunciation.getPronunciationString(Dictionary.YOUDAO, word, " <font color=\"red\">|</font> "));
    data.put("youdaoDefinition", Definition.getDefinitionString(Dictionary.YOUDAO, word, "<br/>"));
    data.put("oxfordDefinitionHtml", oxfordDefinitionHtml);
    data.put("websterDefinitionHtml", websterDefinitionHtml);
    data.put("oxfordPronunciation", Pronunciation.getPronunciationString(Dictionary.OXFORD, word, " <font color=\"red\">|</font> "));
    data.put("oxfordDefinition", OxfordPOS.highlight(Definition.getDefinitionString(Dictionary.OXFORD, word, "<br/>")));
    data.put("websterPronunciation", Pronunciation.getPronunciationString(Dictionary.WEBSTER, word, " <font color=\"red\">|</font> "));
    data.put("websterDefinition", WebsterPOS.highlight(Definition.getDefinitionString(Dictionary.WEBSTER, word, "<br/>")));
    data.put("otherDictionary", otherDictionary.toString());
    if(user != null && MySQLUtils.isMyNewWord(user.getUserName(), word)){
        data.put("isMyNewWord", true);
    }else{
        data.put("isMyNewWord", false);
    }
    data.put("wordLevels", WordSources.getLevels(word).toString());

    String html = TemplateUtils.getWordDefinition(data);
%>

<html>
<head>
    <title>word definition</title>
    <link href="<%=request.getContextPath()%>/css/superword.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/superword.js"></script>
    <script type="text/javascript">
        var lock = false;
        function query() {
            var word = document.getElementById("word").value;
            if (word == "") {
                document.getElementById("tip").innerText = "Please input the word which you want to query.";
                return;
            }
            if (lock) {
                return;
            }
            lock = true;
            location.href = "definition.jsp?word="+word;
        }
        document.onkeypress=function(e){
            var e = window.event || e ;
            if(e.charCode == 13){
                query();
            }
        }
        var loc = false;
        function addToMyNewWordsBook(word){
            if (loc) {
                return;
            }
            loc = true;
            $.ajax({
                url: "definition.jsp?new_word="+word, 
                success: function(result){
                    if(result.trim() == "need_login"){
                        location.href = "system/login.jsp";
                    }else {
                        $("#action_add_to_my_new_words").html(result);
                    }
                }
            });
        }
        function instant(prefix){
            $.ajax({
                url: "word.instant?prefix="+prefix,
                success: function(result){
                    $("#instant_tip").html(result);
                }
            });
        }
    </script>
</head>
<body id="top">
    <jsp:include page="common/head.jsp"/>
    <%=html%>
    <jsp:include page="common/bottom.jsp"/>
</body>
</html>

<MSG> 重构单词定义页面

<DFF> @@ -19,6 +19,7 @@
 <%@ page import="org.apdplat.superword.tools.WordLinker.Dictionary" %>
 <%@ page import="org.apdplat.superword.tools.WordLinker" %>
 <%@ page import="java.util.UUID" %>
+<%@ page import="org.apdplat.superword.tools.Definition" %>
 
 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
 
@@ -27,16 +28,40 @@
     if(word == null){
         word = "fantastic";
     }
+    word = word.trim();
     StringBuilder definitionHtmls = new StringBuilder();
-    definitionHtmls.append("<table>")
-                   .append("<tr><td>序号</td><td>词典</td><td>单词</td></tr>");
-    int i=1;
+    definitionHtmls.append("英文词典解释: ");
+
+    StringBuilder otherDictionary = new StringBuilder();
     for(Dictionary dictionary : Dictionary.values()){
+        if(dictionary == Dictionary.ICIBA || dictionary == Dictionary.YOUDAO){
+            continue;
+        }
         String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();
-        String definitionHtml = "<a href=\"#"+ UUID.randomUUID()+"\" onclick=\"viewDefinition('"+definitionURL+"', '"+word+"');\">"+word+"</a>";
-        definitionHtmls.append("<tr><td>").append(i++).append("</td><td>").append(dictionary.getDes()).append("</td><td>").append(definitionHtml).append("</td></tr>");
+        String definitionHtml = "<a href=\"#"+ UUID.randomUUID()+"\" onclick=\"viewDefinition('"+definitionURL+"', '"+word+"');\">"+dictionary.getDes()+"</a>";
+        otherDictionary.append(definitionHtml).append(" | ");
     }
-    definitionHtmls.append("</table>");
+    otherDictionary.setLength(otherDictionary.length() - 3);
+
+    definitionHtmls.append(otherDictionary.toString())
+            .append("<br/><br/>");
+
+    String icibaDefinitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.ICIBA)+word+"&word="+word+"&dict="+Dictionary.ICIBA.name();
+    String icibaDefinitionHtml = "<a href=\"#"+ UUID.randomUUID()+"\" onclick=\"viewDefinition('"+icibaDefinitionURL+"', '"+word+"');\">爱词霸解释</a>";
+    String youdaoDefinitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.YOUDAO)+word+"&word="+word+"&dict="+Dictionary.YOUDAO.name();
+    String youdaoDefinitionHtml = "<a href=\"#" + UUID.randomUUID()+"\" onclick=\"viewDefinition('"+youdaoDefinitionURL+"', '"+word+"');\">有道解释</a>";
+    definitionHtmls.append("<table border=\"1\">")
+            .append("<tr><td>")
+            .append(icibaDefinitionHtml)
+            .append("</td><td>")
+            .append(youdaoDefinitionHtml)
+            .append("</td></tr>")
+            .append("<tr><td>")
+            .append(Definition.getDefinitionString(Dictionary.ICIBA, word, "<br/>"))
+            .append("</td><td>")
+            .append(Definition.getDefinitionString(Dictionary.YOUDAO, word, "<br/>"))
+            .append("</td></tr>")
+            .append("</table>");
 %>
 
 <html>

{'commit': 'diff --git a/src/main/webapp/definition.jsp b/src/main/webapp/definition.jsp\nindex cb2a173..2c2200d 100644\n--- a/src/main/webapp/definition.jsp\n+++ b/src/main/webapp/definition.jsp\n@@ -19,6 +19,7 @@\n <%@ page import="org.apdplat.superword.tools.WordLinker.Dictionary" %>\n <%@ page import="org.apdplat.superword.tools.WordLinker" %>\n <%@ page import="java.util.UUID" %>\n+<%@ page import="org.apdplat.superword.tools.Definition" %>\n \n <%@ page contentType="text/html;charset=UTF-8" language="java" %>\n \n@@ -27,16 +28,40 @@\n     if(word == null){\n         word = "fantastic";\n     }\n+    word = word.trim();\n     StringBuilder definitionHtmls = new StringBuilder();\n-    definitionHtmls.append("<table>")\n-                   .append("<tr><td>序号</td><td>词典</td><td>单词</td></tr>");\n-    int i=1;\n+    definitionHtmls.append("英文词典解释: ");\n+\n+    StringBuilder otherDictionary = new StringBuilder();\n     for(Dictionary dictionary : Dictionary.values()){\n+        if(dictionary == Dictionary.ICIBA || dictionary == Dictionary.YOUDAO){\n+            continue;\n+        }\n         String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();\n-        String definitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+definitionURL+"\', \'"+word+"\');\\">"+word+"</a>";\n-        definitionHtmls.append("<tr><td>").append(i++).append("</td><td>").append(dictionary.getDes()).append("</td><td>").append(definitionHtml).append("</td></tr>");\n+        String definitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+definitionURL+"\', \'"+word+"\');\\">"+dictionary.getDes()+"</a>";\n+        otherDictionary.append(definitionHtml).append(" | ");\n     }\n-    definitionHtmls.append("</table>");\n+    otherDictionary.setLength(otherDictionary.length() - 3);\n+\n+    definitionHtmls.append(otherDictionary.toString())\n+            .append("<br/><br/>");\n+\n+    String icibaDefinitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.ICIBA)+word+"&word="+word+"&dict="+Dictionary.ICIBA.name();\n+    String icibaDefinitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+icibaDefinitionURL+"\', \'"+word+"\');\\">爱词霸解释</a>";\n+    String youdaoDefinitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.YOUDAO)+word+"&word="+word+"&dict="+Dictionary.YOUDAO.name();\n+    String youdaoDefinitionHtml = "<a href=\\"#" + UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+youdaoDefinitionURL+"\', \'"+word+"\');\\">有道解释</a>";\n+    definitionHtmls.append("<table border=\\"1\\">")\n+            .append("<tr><td>")\n+            .append(icibaDefinitionHtml)\n+            .append("</td><td>")\n+            .append(youdaoDefinitionHtml)\n+            .append("</td></tr>")\n+            .append("<tr><td>")\n+            .append(Definition.getDefinitionString(Dictionary.ICIBA, word, "<br/>"))\n+            .append("</td><td>")\n+            .append(Definition.getDefinitionString(Dictionary.YOUDAO, word, "<br/>"))\n+            .append("</td></tr>")\n+            .append("</table>");\n %>\n \n <html>\n', 'commit_subject': '重构单词定义页面', 'repo_name': 'ysc/superword', 'committer': {'name': 'ysc', 'email': '8b37f6ec54bd5377666ecc39fb98741165624e5f@qq.com', 'time_sec': '1449023436', 'tz_offset': '480', 'date': {'seconds': '1449023436'}}, 'commit_tree': '11aef73af8035408920acbfc26ed1cc779b34080', 'commit_message': '重构单词定义页面\n', 'language_name': 'Shell', 'license': 'apache-2.0', 'hunks': '@@ -19,6 +19,7 @@\n <%@ page import="org.apdplat.superword.tools.WordLinker.Dictionary" %>\n <%@ page import="org.apdplat.superword.tools.WordLinker" %>\n <%@ page import="java.util.UUID" %>\n+<%@ page import="org.apdplat.superword.tools.Definition" %>\n \n <%@ page contentType="text/html;charset=UTF-8" language="java" %>\n \n@@ -27,16 +28,40 @@\n     if(word == null){\n         word = "fantastic";\n     }\n+    word = word.trim();\n     StringBuilder definitionHtmls = new StringBuilder();\n-    definitionHtmls.append("<table>")\n-                   .append("<tr><td>序号</td><td>词典</td><td>单词</td></tr>");\n-    int i=1;\n+    definitionHtmls.append("英文词典解释: ");\n+\n+    StringBuilder otherDictionary = new StringBuilder();\n     for(Dictionary dictionary : Dictionary.values()){\n+        if(dictionary == Dictionary.ICIBA || dictionary == Dictionary.YOUDAO){\n+            continue;\n+        }\n         String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();\n-        String definitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+definitionURL+"\', \'"+word+"\');\\">"+word+"</a>";\n-        definitionHtmls.append("<tr><td>").append(i++).append("</td><td>").append(dictionary.getDes()).append("</td><td>").append(definitionHtml).append("</td></tr>");\n+        String definitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+definitionURL+"\', \'"+word+"\');\\">"+dictionary.getDes()+"</a>";\n+        otherDictionary.append(definitionHtml).append(" | ");\n     }\n-    definitionHtmls.append("</table>");\n+    otherDictionary.setLength(otherDictionary.length() - 3);\n+\n+    definitionHtmls.append(otherDictionary.toString())\n+            .append("<br/><br/>");\n+\n+    String icibaDefinitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.ICIBA)+word+"&word="+word+"&dict="+Dictionary.ICIBA.name();\n+    String icibaDefinitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+icibaDefinitionURL+"\', \'"+word+"\');\\">爱词霸解释</a>";\n+    String youdaoDefinitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.YOUDAO)+word+"&word="+word+"&dict="+Dictionary.YOUDAO.name();\n+    String youdaoDefinitionHtml = "<a href=\\"#" + UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+youdaoDefinitionURL+"\', \'"+word+"\');\\">有道解释</a>";\n+    definitionHtmls.append("<table border=\\"1\\">")\n+            .append("<tr><td>")\n+            .append(icibaDefinitionHtml)\n+            .append("</td><td>")\n+            .append(youdaoDefinitionHtml)\n+            .append("</td></tr>")\n+            .append("<tr><td>")\n+            .append(Definition.getDefinitionString(Dictionary.ICIBA, word, "<br/>"))\n+            .append("</td><td>")\n+            .append(Definition.getDefinitionString(Dictionary.YOUDAO, word, "<br/>"))\n+            .append("</td></tr>")\n+            .append("</table>");\n %>\n \n <html>\n', 'addition_count': 31, 'deletion_count': 6, 'src_file': 'a/src/main/webapp/definition.jsp', 'tgt_file': 'b/src/main/webapp/definition.jsp', 'file_extension': '.jsp', 'before_file': '<%--\n  ~ APDPlat - Application Product Development Platform\n  ~ Copyright (c) 2013, 杨尚川, yang-shangchuan@qq.com\n  ~\n  ~  This program is free software: you can redistribute it and/or modify\n  ~  it under the terms of the GNU General Public License as published by\n  ~  the Free Software Foundation, either version 3 of the License, or\n  ~  (at your option) any later version.\n  ~\n  ~  This program is distributed in the hope that it will be useful,\n  ~  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  ~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  ~  GNU General Public License for more details.\n  ~\n  ~  You should have received a copy of the GNU General Public License\n  ~  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n  --%>\n\n<%@ page import="org.apdplat.superword.tools.WordLinker.Dictionary" %>\n<%@ page import="org.apdplat.superword.tools.WordLinker" %>\n<%@ page import="java.util.UUID" %>\n\n<%@ page contentType="text/html;charset=UTF-8" language="java" %>\n\n<%@ page import="java.nio.file.Files" %>\n<%@ page import="java.nio.file.Paths" %>\n    if(word == null){\n        word = "fantastic";\n    }\n    StringBuilder definitionHtmls = new StringBuilder();\n    definitionHtmls.append("<table>")\n                   .append("<tr><td>序号</td><td>词典</td><td>单词</td></tr>");\n    int i=1;\n    for(Dictionary dictionary : Dictionary.values()){\n        String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();\n        String definitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"viewDefinition(\'"+definitionURL+"\', \'"+word+"\');\\">"+word+"</a>";\n        definitionHtmls.append("<tr><td>").append(i++).append("</td><td>").append(dictionary.getDes()).append("</td><td>").append(definitionHtml).append("</td></tr>");\n    }\n    definitionHtmls.append("</table>");\n%>\n\n<html>\n    if(Files.exists(Paths.get(file))){\n        data.put("hasOxfordAudio", true);\n        oxfordAudios.add(word.toLowerCase());\n        int i=2;\n        while(Files.exists(Paths.get(application.getRealPath("/audio/oxford/"+word.toLowerCase()+"_"+i+".mp3")))){\n            oxfordAudios.add(word.toLowerCase()+"_"+i++);\n        }\n        data.put("oxfordAudios", oxfordAudios);\n    }else{\n        data.put("hasOxfordAudio", false);\n    }\n\n    file = application.getRealPath("/audio/webster/"+word.toLowerCase()+".mp3");\n    List<String> websterAudios = new ArrayList();\n    if(Files.exists(Paths.get(file))){\n        data.put("hasWebsterAudio", true);\n        websterAudios.add(word.toLowerCase());\n        int i=2;\n        while(Files.exists(Paths.get(application.getRealPath("/audio/webster/"+word.toLowerCase()+"_"+i+".mp3")))){\n            websterAudios.add(word.toLowerCase()+"_"+i++);\n        }\n        data.put("websterAudios", websterAudios);\n    }else{\n        data.put("hasWebsterAudio", false);\n    }\n\n    StringBuilder otherDictionary = new StringBuilder();\n    for(Dictionary dictionary : Dictionary.values()){\n        if(dictionary == Dictionary.ICIBA\n                || dictionary == Dictionary.YOUDAO\n                || dictionary == Dictionary.OXFORD\n                || dictionary == Dictionary.WEBSTER){\n            continue;\n        }\n        String definitionURL = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(dictionary)+word+"&word="+word+"&dict="+dictionary.name();\n        String definitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"openWindow(\'"+definitionURL+"\', \'"+word+"\');\\">"+dictionary.getDes()+"</a>";\n        otherDictionary.append(definitionHtml).append(" | ");\n    }\n    otherDictionary.setLength(otherDictionary.length() - 3);\n\n    String icibaLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.ICIBA);\n    String icibaDefinitionURL = icibaLinkPrefix+word+"&word="+word+"&dict="+Dictionary.ICIBA.name();\n    String icibaDefinitionHtml = "<a href=\\"#"+ UUID.randomUUID()+"\\" onclick=\\"openWindow(\'"+icibaDefinitionURL+"\', \'"+word+"\');\\">iCIBA definition</a>";\n\n    String youdaoLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.YOUDAO);\n    String youdaoDefinitionURL = youdaoLinkPrefix+word+"&word="+word+"&dict="+Dictionary.YOUDAO.name();\n    String youdaoDefinitionHtml = "<a href=\\"#" + UUID.randomUUID()+"\\" onclick=\\"openWindow(\'"+youdaoDefinitionURL+"\', \'"+word+"\');\\">Youdao definition</a>";\n\n    String oxfordLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.OXFORD);\n    String oxfordDefinitionURL = oxfordLinkPrefix+word+"&word="+word+"&dict="+Dictionary.OXFORD.name();\n    String oxfordDefinitionHtml = "<a href=\\"#" + UUID.randomUUID()+"\\" onclick=\\"openWindow(\'"+oxfordDefinitionURL+"\', \'"+word+"\');\\">Oxford definition</a>";\n\n    String websterLinkPrefix = WordLinker.serverRedirect+"?url="+WordLinker.getLinkPrefix(Dictionary.WEBSTER);\n    String websterDefinitionURL = websterLinkPrefix+word+"&word="+word+"&dict="+Dictionary.WEBSTER.name();\n    String websterDefinitionHtml = "<a href=\\"#" + UUID.randomUUID()+"\\" onclick=\\"openWindow(\'"+websterDefinitionURL+"\', \'"+word+"\');\\">Webster\'s definition</a>";\n\n    data.put("icibaDefinitionHtml", icibaDefinitionHtml);\n    data.put("youdaoDefinitionHtml", youdaoDefinitionHtml);\n    data.put("icibaPronunciation", Pronunciation.getPronunciationString(Dictionary.ICIBA, word, " <font color=\\"red\\">|</font> "));\n    data.put("icibaDefinition", Definition.getDefinitionString(Dictionary.ICIBA, word, "<br/>"));\n    data.put("youdaoPronunciation", Pronunciation.getPronunciationString(Dictionary.YOUDAO, word, " <font color=\\"red\\">|</font> "));\n    data.put("youdaoDefinition", Definition.getDefinitionString(Dictionary.YOUDAO, word, "<br/>"));\n    data.put("oxfordDefinitionHtml", oxfordDefinitionHtml);\n    data.put("websterDefinitionHtml", websterDefinitionHtml);\n    data.put("oxfordPronunciation", Pronunciation.getPronunciationString(Dictionary.OXFORD, word, " <font color=\\"red\\">|</font> "));\n    data.put("oxfordDefinition", OxfordPOS.highlight(Definition.getDefinitionString(Dictionary.OXFORD, word, "<br/>")));\n    data.put("websterPronunciation", Pronunciation.getPronunciationString(Dictionary.WEBSTER, word, " <font color=\\"red\\">|</font> "));\n    data.put("websterDefinition", WebsterPOS.highlight(Definition.getDefinitionString(Dictionary.WEBSTER, word, "<br/>")));\n    data.put("otherDictionary", otherDictionary.toString());\n    if(user != null && MySQLUtils.isMyNewWord(user.getUserName(), word)){\n        data.put("isMyNewWord", true);\n    }else{\n        data.put("isMyNewWord", false);\n    }\n    data.put("wordLevels", WordSources.getLevels(word).toString());\n\n    String html = TemplateUtils.getWordDefinition(data);\n%>\n\n<html>\n<head>\n    <title>word definition</title>\n    <link href="<%=request.getContextPath()%>/css/superword.css" rel="stylesheet" type="text/css"/>\n    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-2.1.4.min.js"></script>\n    <script type="text/javascript" src="<%=request.getContextPath()%>/js/superword.js"></script>\n    <script type="text/javascript">\n        var lock = false;\n        function query() {\n            var word = document.getElementById("word").value;\n            if (word == "") {\n                document.getElementById("tip").innerText = "Please input the word which you want to query.";\n                return;\n            }\n            if (lock) {\n                return;\n            }\n            lock = true;\n            location.href = "definition.jsp?word="+word;\n        }\n        document.onkeypress=function(e){\n            var e = window.event || e ;\n            if(e.charCode == 13){\n                query();\n            }\n        }\n        var loc = false;\n        function addToMyNewWordsBook(word){\n            if (loc) {\n                return;\n            }\n            loc = true;\n            $.ajax({\n                url: "definition.jsp?new_word="+word, \n                success: function(result){\n                    if(result.trim() == "need_login"){\n                        location.href = "system/login.jsp";\n                    }else {\n                        $("#action_add_to_my_new_words").html(result);\n                    }\n                }\n            });\n        }\n        function instant(prefix){\n            $.ajax({\n                url: "word.instant?prefix="+prefix,\n                success: function(result){\n                    $("#instant_tip").html(result);\n                }\n            });\n        }\n    </script>\n</head>\n<body id="top">\n    <jsp:include page="common/head.jsp"/>\n    <%=html%>\n    <jsp:include page="common/bottom.jsp"/>\n</body>\n</html>\n', 'message': '重构单词定义页面\n', 'author_name': 'ysc', 'lang': 'jsp'}