1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2 <%
3 String path = request.getContextPath();
4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
5 %>
6
7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8 <html>
9 <head>
10 <base href="<%=basePath%>">
11
12 <title>My JSP 'index.jsp' starting page</title>
13 <meta http-equiv="pragma" content="no-cache">
14 <meta http-equiv="cache-control" content="no-cache">
15 <meta http-equiv="expires" content="0">
16 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
17 <meta http-equiv="description" content="This is my page">
18 <!--
19 <link rel="stylesheet" type="text/css" href="styles.css">
20 -->
21 <script type="text/javascript" src="<%=path %>/ckeditor/jquery.js"></script>
22 <script type="text/javascript" src="<%=path %>/ckeditor/ckeditor.js"></script>
23 <script type="text/javascript" src="<%=path %>/ckeditor/adapters/jquery.js"></script>
24 <script type="text/javascript" src="<%=path %>/ckeditor/config.js"></script>
25 <script type="text/javascript" src="<%=path %>/ckeditor/plugins/syntaxhighlight/scripts/shCore.js"></script>
26 <script type="text/javascript" src="<%=path %>/ckeditor/plugins/syntaxhighlight/scripts/shBrushJScript.js"></script>
27 <script type="text/javascript" src="<%=path %>/ckeditor/plugins/syntaxhighlight/scripts/shBrushes.js"></script>
28 <link type="text/css" rel="stylesheet" href="<%=path %>/ckeditor/plugins/syntaxhighlight/styles/shCoreDefault.css"/>
29 <link type="text/css" rel="stylesheet" href="<%=path %>/ckeditor/plugins/syntaxhighlight/styles/shThemeDefault.css"/>
30 <script type="text/javascript">
31 //<![CDATA[
32 SyntaxHighlighter.config.clipboardSwf = '<%=path %>/ckeditor/plugins/syntaxhighlight/scripts/clipboard.swf';
33 SyntaxHighlighter.all();
34 $(function(){
35 $('.content').ckeditor(config);
36 $('.preSee').click(function(){
37 $('#editorcontents').html($('.content').val());
38 });
39 });
40
41 //]]>
42 </script>
43 <link rel="stylesheet" type="text/css" href="<%=path %>/ckeditor/css/myCkeditor.css">
44 </head>
45
46 <body>
47 <%=path %>
48 <textarea class='content' cols="80" id="content" name="content" rows="10">
49 这里是内容
50 </textarea>
51 <div id="contents">
52 <p>Edited Contents:</p>
53 <input type='button' value='preSee' class='preSee'/>
54 <div id="editorcontents"/>
55 </div>
56
57 <pre class="brush: js;">
58 function helloSyntaxHighlighter()
59 {
60 return "hi!";
61 }
62 </pre>
63
64 <div style="border:1px solid #f9b704;padding:20px">
65 <pre class="brush:js;toolbar:true;first-line:1;pad-line-numbers:false;highlight:null;collapse:true;">
66 CKEDITOR.dialog.add('insertcode', function(editor){
67 var escape = function(value){return value;};
68 l = editor.lang;
69 return {
70 title: l.insertcode,
71 resizable: CKEDITOR.DIALOG_RESIZE_BOTH,
72 minWidth: 580,
73 minHeight: 400,
74 style: 'font-size:14px',
75 contents: [{
76 id: 'cb',
77 name: 'cb',
78 label: 'cb',
79 title: 'cb',
80 elements: [{
81 type: 'select',
82 label: l.selectLang,
83 id: 'lang',
84 required: true,
85 'default': 'csharp',
86 items: [['shell','shell'],['ActionScript3', 'as3'], ['Bash/shell', 'bash'], ['C#', 'csharp'], ['C++', 'cpp'], ['CSS', 'css'], ['Delphi', 'delphi'], ['Diff', 'diff'], ['Groovy', 'groovy'], ['Html', 'xhtml'], ['JavaScript', 'js'], ['Java', 'java'], ['JavaFX', 'jfx'], ['Perl', 'perl'], ['PHP', 'php'], ['Plain Text', 'plain'], ['PowerShell', 'ps'], ['Python', 'py'], ['Ruby', 'rails'], ['Scala', 'scala'], ['SQL', 'sql'], ['Visual Basic', 'vb'], ['XML', 'xml']]
87 },
88 {
89 type: 'textarea',
90 style: 'width:100%;height:100%',
91 rows:15,
92 label: l.insertcode,
93 id: 'code',
94 'default': ''
95 },
96 {
97 type: 'hbox',
98 widths: ['15%', '15%', '25%', '45%'],
99 style: 'padding:0;margin:0;',
100 children:[
101 {
102 type: 'text',
103 label: l.firstLine,
104 id:'firstLine',
105 style: 'width:35px;',
106 'default':'1'
107 },
108 {
109 type: 'text',
110 label: l.highlighter,
111 id:'highlight',
112 style: 'width:120px;',
113 'default':'null'
114 },
115 {
116 type: 'radio',
117 label: l.balancing,
118 id:'padLineNumbers',
119 'default':'true',
120 items: [[l.balancing_Yes,'true'],[l.balancing_No, 'false']]
121 },
122 {
123 type: 'radio',
124 label: l.collapse,
125 id:'collapse',
126 'default':'false',
127 items: [[l.collapse_Yes,'true'],[l.collapse_No, 'false']]
128 },
129 {
130 type: 'text',
131 label: l.codeTitle,
132 id:'title',
133 style: 'width:100px;',
134 'default':''
135 }
136 ]
137 }]
138 }],
139 onOk: function(){
140 code = this.getValueOf('cb', 'code');
141 lang = this.getValueOf('cb', 'lang');
142
143 title = this.getValueOf('cb', 'title');
144 firstLine = this.getValueOf('cb', 'firstLine');
145 padLineNumbers = this.getValueOf('cb', 'padLineNumbers');
146 highlight = this.getValueOf('cb', 'highlight');
147 collapse = this.getValueOf('cb', 'collapse');
148
149 attr = '';
150 if(title != '') {attr += 'title:\''+title+'\';';}
151 if(firstLine != '') {attr += 'first-line:'+firstLine+';';}
152 if(padLineNumbers != '') {attr += 'pad-line-numbers:'+padLineNumbers+';';}
153 if(highlight != '') {attr += 'highlight:'+highlight+';';}
154 if(collapse != ''){attr += 'collapse:'+collapse+';';}
155
156 title = this.getValueOf('cb', 'lang');
157 html = escape(code);
158 replaceObj = /&/g;
159 html = html.replace(replaceObj, '&amp;');
160 replaceObj = /</g;
161 html = html.replace(replaceObj, '&lt;');
162 replaceObj = />/g;
163 html = html.replace(replaceObj, '&gt;');
164 editor.insertHtml("<div style='border:1px solid #f9b704;padding:20px'><pre class=\"brush:"+lang+";"+attr+"\">\n"+html+"\n</pre></div>");
165 },
166 onLoad: function(){}
167 };
168 });
169 </pre>
170 </div>
171
172
173 </body>
174 </html>