123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <form id="addNewsForm" method="post">
- <table class="mytable" style="width: 100%;">
- <tr>
- <th width="15%">标题</th>
- <td width="85%" colspan="3" >
- <input class="easyui-validatebox" required="true" type="text" id="title_add" name="news.title" style="width:545px">
- </td>
- </tr>
- <tr>
- <th>栏目类型</th>
- <td colspan="3">
- <select id="newsType_add" name="news.newsType" style="width:173px;">
- <option value="">请选择...</option>
- </select>
- </td>
- </tr>
- <tr>
- <th>发布人</th>
- <td>
- <input class="easyui-validatebox" required="true" type="text" id="operator_add" name="news.operator" value="${user.fullName}">
- </td>
- <th>发布时间</th>
- <td>
- <input class="easyui-datebox" required="true" type="text" id="businessTime_add" name="news.businessTime">
- </td>
- </tr>
- <tr>
- <th>图片新闻设置</th>
- <td colspan="3">
- 选取第<input type="text" id="dz" name="news.num" style="width:40px;"/> 张图片作为图片新闻展示
- <input type="Button" value="提取" width="150px" onclick="ce()" style="margin:5px 0px 5px 0px;"/>
- <br>
- <input type="text" id="imagePath_add" name="news.imagePath" style="width:545px;margin:5px 0px 5px 0px;">
- </td>
- </tr>
- <tr>
- <th>新闻内容</th>
- <td colspan="3">
- <textarea id="editor_content" name="news.content" rows="20" cols="100" style="width: 95%; height: 400px;"></textarea>
- </td>
- </tr>
- <tr>
- <th>备注</th>
- <td colspan="3">
- <textarea rows="4" cols="80" name="news.remark" style="width:95%"></textarea>
- </td>
- </tr>
- </table>
- </form>
- <script type="text/javascript">
- KindEditor.ready(function(K) {
- var options = {
- //自定义工具栏
- items : [ 'source', 'plainpaste', 'wordpaste', 'preview', '|',
- 'fontname', 'fontsize', '|',
- 'forecolor', 'hilitecolor', 'bold',
- 'italic', 'underline', 'removeformat', '|',
- 'clearhtml', 'selectall','|',
- 'justifyleft', 'justifycenter', 'justifyright',
- 'indent','outdent','insertorderedlist', 'insertunorderedlist', '|',
- 'image', "multiimage", 'insertfile', '|',
- 'table', 'baidumap' ],
- //图片上传Action
- uploadJson : whzl.basePath+'/imgUpload_imgUpload',
-
- //允许网络图片上传
- allowImageRemote : true,
-
- //文件空间Action
- fileManagerJson : whzl.basePath+'/fileManager_fileManager',
-
- //允许展示文件空间
- allowFileManager : true,
-
- //kindeditor创建后,将编辑器的内容设置到原来的textarea控件里
- afterCreate : function(){ this.sync(); },
-
- //编辑器聚焦后,将编辑器的内容设置到原来的textarea控件里
- afterBlur: function(){ this.sync(); },
-
- //编辑器内容发生变化后,将编辑器的内容设置到原来的textarea控件里
- afterChange: function(){ this.sync(); }
- };
-
- editor = K.create('#editor_content', options);
- });
-
-
- function ce(){
- //indexOf某个指定的字符串值在字符串中首次出现的位置
- if (editor.html().toLowerCase().indexOf("<img") == -1 && editor.html().toLowerCase().indexOf("src=")) {
- alert("您设置了把内容中第一条图片设置为图片地址\n但内容中并没有图片");
- return false;
- }else{
- //图片正则
- var reg=/<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim;
- var arr = [];
- while(tem=reg.exec(editor.html()))
- {
- arr.push(tem[2]);
- }
- var imgIndex = $("#dz").val();
- if(imgIndex != ""){
- if(!isNaN(imgIndex)){
- var z = imgIndex.trim();
- if(z > arr.length || z <= 0){
- alert("内容中没有你要提取的图片!");
- return;
- }else{
- for(var i=1; i <= arr.length; i++){
- if(i == z){
- alert("提取成功!");
- $("#imagePath_add").val(arr[i-1]);
- }
- }
- }
- }else{
- alert("请输入数字!");
- }
- }else{
- alert("请选择提取的图片!");
- }
- }
- }
- </script>
|