神的热头发

View Code
  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(&#39;insertcode&#39;, 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: &#39;font-size:14px&#39;,
 75                 contents: [{
 76                     id: &#39;cb&#39;,
 77                     name: &#39;cb&#39;,
 78                     label: &#39;cb&#39;,
 79                     title: &#39;cb&#39;,
 80                     elements: [{
 81                         type: &#39;select&#39;,
 82                         label: l.selectLang,
 83                         id: &#39;lang&#39;,
 84                         required: true,
 85                         &#39;default&#39;: &#39;csharp&#39;,
 86                         items: [[&#39;shell&#39;,&#39;shell&#39;],[&#39;ActionScript3&#39;, &#39;as3&#39;], [&#39;Bash/shell&#39;, &#39;bash&#39;], [&#39;C#&#39;, &#39;csharp&#39;], [&#39;C++&#39;, &#39;cpp&#39;], [&#39;CSS&#39;, &#39;css&#39;], [&#39;Delphi&#39;, &#39;delphi&#39;], [&#39;Diff&#39;, &#39;diff&#39;], [&#39;Groovy&#39;, &#39;groovy&#39;], [&#39;Html&#39;, &#39;xhtml&#39;], [&#39;JavaScript&#39;, &#39;js&#39;], [&#39;Java&#39;, &#39;java&#39;], [&#39;JavaFX&#39;, &#39;jfx&#39;], [&#39;Perl&#39;, &#39;perl&#39;], [&#39;PHP&#39;, &#39;php&#39;], [&#39;Plain Text&#39;, &#39;plain&#39;], [&#39;PowerShell&#39;, &#39;ps&#39;], [&#39;Python&#39;, &#39;py&#39;], [&#39;Ruby&#39;, &#39;rails&#39;], [&#39;Scala&#39;, &#39;scala&#39;], [&#39;SQL&#39;, &#39;sql&#39;], [&#39;Visual Basic&#39;, &#39;vb&#39;], [&#39;XML&#39;, &#39;xml&#39;]] 
 87                     },
 88                     {
 89                         type: &#39;textarea&#39;,
 90                         style: &#39;width:100%;height:100%&#39;,
 91                         rows:15,
 92                         label: l.insertcode,
 93                         id: &#39;code&#39;,
 94                         &#39;default&#39;: &#39;&#39;
 95                     },
 96                     {
 97                         type: &#39;hbox&#39;,
 98                         widths: [&#39;15%&#39;, &#39;15%&#39;, &#39;25%&#39;, &#39;45%&#39;],
 99                         style: &#39;padding:0;margin:0;&#39;,
100                         children:[
101                             {
102                                 type: &#39;text&#39;,
103                                 label: l.firstLine,
104                                 id:&#39;firstLine&#39;,
105                                 style: &#39;width:35px;&#39;,
106                                 &#39;default&#39;:&#39;1&#39;
107                             },
108                             {
109                                 type: &#39;text&#39;,
110                                 label: l.highlighter,
111                                 id:&#39;highlight&#39;,
112                                 style: &#39;width:120px;&#39;,
113                                 &#39;default&#39;:&#39;null&#39;
114                             },
115                             {
116                                 type: &#39;radio&#39;,
117                                 label: l.balancing,
118                                 id:&#39;padLineNumbers&#39;,
119                                 &#39;default&#39;:&#39;true&#39;,
120                                 items: [[l.balancing_Yes,&#39;true&#39;],[l.balancing_No, &#39;false&#39;]]
121                             },
122                             {
123                                 type: &#39;radio&#39;,
124                                 label: l.collapse,
125                                 id:&#39;collapse&#39;,
126                                 &#39;default&#39;:&#39;false&#39;,
127                                 items: [[l.collapse_Yes,&#39;true&#39;],[l.collapse_No, &#39;false&#39;]]
128                             },
129                             {
130                                 type: &#39;text&#39;,
131                                 label: l.codeTitle,
132                                 id:&#39;title&#39;,
133                                 style: &#39;width:100px;&#39;,
134                                 &#39;default&#39;:&#39;&#39;
135                             }
136                         ]
137                     }]
138                 }],
139                 onOk: function(){
140                     code = this.getValueOf(&#39;cb&#39;, &#39;code&#39;);
141                     lang = this.getValueOf(&#39;cb&#39;, &#39;lang&#39;);
142                     
143                     title = this.getValueOf(&#39;cb&#39;, &#39;title&#39;);
144                     firstLine = this.getValueOf(&#39;cb&#39;, &#39;firstLine&#39;);
145                     padLineNumbers = this.getValueOf(&#39;cb&#39;, &#39;padLineNumbers&#39;);
146                     highlight = this.getValueOf(&#39;cb&#39;, &#39;highlight&#39;);
147                     collapse = this.getValueOf(&#39;cb&#39;, &#39;collapse&#39;);
148                     
149                     attr = &#39;&#39;;
150                     if(title != &#39;&#39;) {attr += &#39;title:\&#39;&#39;+title+&#39;\&#39;;&#39;;}
151                     if(firstLine != &#39;&#39;) {attr += &#39;first-line:&#39;+firstLine+&#39;;&#39;;}
152                     if(padLineNumbers != &#39;&#39;) {attr += &#39;pad-line-numbers:&#39;+padLineNumbers+&#39;;&#39;;}
153                     if(highlight != &#39;&#39;) {attr += &#39;highlight:&#39;+highlight+&#39;;&#39;;}
154                     if(collapse != &#39;&#39;){attr += &#39;collapse:&#39;+collapse+&#39;;&#39;;}
155                     
156                     title = this.getValueOf(&#39;cb&#39;, &#39;lang&#39;);
157                     html = escape(code);
158                     replaceObj = /&amp;/g;
159                     html = html.replace(replaceObj, &#39;&amp;amp;&#39;);
160                     replaceObj = /&lt;/g;
161                     html = html.replace(replaceObj, &#39;&amp;lt;&#39;);
162                     replaceObj = /&gt;/g;
163                     html = html.replace(replaceObj, &#39;&amp;gt;&#39;);
164                     editor.insertHtml(&quot;&lt;div style=&#39;border:1px solid #f9b704;padding:20px&#39;&gt;&lt;pre class=\&quot;brush:&quot;+lang+&quot;;&quot;+attr+&quot;\&quot;&gt;\n&quot;+html+&quot;\n&lt;/pre&gt;&lt;/div&gt;&quot;);
165                 },
166                 onLoad: function(){} 
167             };
168         });
169         </pre>
170         </div>
171 
172         
173   </body>
174 </html>
1 function helloSyntaxHighlighter()
2 {
3     return "hi!";
4 }

转载于:https://www.cnblogs.com/zhangweijian/archive/2012/06/25/2561609.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值