newsUpdate.jsp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <form id="updateNewsForm" method="post">
  4. <table class="mytable" style="width: 100%;">
  5. <tr>
  6. <th width="15%">标题</th>
  7. <td width="85%" colspan="3" >
  8. <input type="hidden" id="id_update" name="news.id"/>
  9. <input type="hidden" id="isImaged_update" name="news.isImaged"/>
  10. <input type="hidden" id="orderID_update" name="news.orderID"/>
  11. <input type="hidden" id="createdOn_update" name="news.createdOn"/>
  12. <input type="hidden" id="createdBy_update" name="news.createdBy"/>
  13. <input class="easyui-validatebox" required="true" type="text" id="title_update" name="news.title" style="width:545px">
  14. </td>
  15. </tr>
  16. <tr>
  17. <th>栏目类型</th>
  18. <td colspan="3">
  19. <select id="newsType_update" name="news.newsType" style="width:173px;" required="true">
  20. </select>
  21. </td>
  22. </tr>
  23. <tr>
  24. <th>发布人</th>
  25. <td>
  26. <input class="easyui-validatebox" required="true" type="text" id="operator_update" name="news.operator">
  27. </td>
  28. <th>发布时间</th>
  29. <td>
  30. <input class="easyui-datebox" required="true" type="text" id="businessTime_update" name="news.businessTime">
  31. </td>
  32. </tr>
  33. <tr>
  34. <th>图片地址</th>
  35. <td colspan="3">
  36. 提取第<input type="text" id="dz_update" name="news.num" style="width:40px;"/> 张图片
  37. <input type="Button" value="提取" width="150px" onclick="ce()" style="margin:5px 0px 5px 0px;"/>
  38. <br>
  39. <input type="text" id="imagePath_update" name="news.imagePath" style="width:545px;margin:5px 0px 5px 0px;">
  40. </td>
  41. </tr>
  42. <tr>
  43. <th>新闻内容</th>
  44. <td colspan="3">
  45. <textarea id="editor_content2" name="news.content" rows="20" cols="100" style="width: 95%; height: 400px;"></textarea>
  46. </td>
  47. </tr>
  48. <tr>
  49. <th>备注</th>
  50. <td colspan="3">
  51. <textarea rows="4" cols="80" name="news.remark" style="width:95%"></textarea>
  52. </td>
  53. </tr>
  54. </table>
  55. </form>
  56. <script type="text/javascript">
  57. KindEditor.ready(function(K) {
  58. var options = {
  59. //自定义工具栏
  60. items : [ 'source', 'plainpaste', 'wordpaste', 'preview', '|',
  61. 'fontname', 'fontsize', '|',
  62. 'forecolor', 'hilitecolor', 'bold',
  63. 'italic', 'underline', 'removeformat', '|',
  64. 'clearhtml', 'selectall','|',
  65. 'justifyleft', 'justifycenter', 'justifyright',
  66. 'indent','outdent','insertorderedlist', 'insertunorderedlist', '|',
  67. 'image', "multiimage", 'insertfile', '|',
  68. 'table', 'baidumap' ],
  69. //图片上传Action
  70. uploadJson : whzl.basePath+'/imgUpload_imgUpload',
  71. //允许网络图片上传
  72. allowImageRemote : true,
  73. //文件空间Action
  74. fileManagerJson : whzl.basePath+'/FileManager_fileManager',
  75. //允许展示文件空间
  76. allowFileManager : true,
  77. //kindeditor创建后,将编辑器的内容设置到原来的textarea控件里
  78. afterCreate : function(){this.sync();},
  79. //编辑器聚焦后,将编辑器的内容设置到原来的textarea控件里
  80. afterBlur: function(){this.sync();},
  81. //编辑器内容发生变化后,将编辑器的内容设置到原来的textarea控件里
  82. afterChange: function(){this.sync();}
  83. };
  84. editor_up = K.create('#editor_content2', options);
  85. });
  86. function ce(){
  87. //indexOf某个指定的字符串值在字符串中首次出现的位置
  88. if (editor_up.html().toLowerCase().indexOf("<img") == -1 && editor_up.html().toLowerCase().indexOf("src=")) {
  89. alert("您设置了把内容中第一条图片设置为图片地址\n但内容中并没有图片");
  90. return false;
  91. }else{
  92. //图片正则
  93. var reg=/<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim;
  94. var arr = [];
  95. while(tem=reg.exec(editor_up.html()))
  96. {
  97. arr.push(tem[2]);
  98. }
  99. var imgIndex = $("#dz_update").val();
  100. if(imgIndex != ""){
  101. if(!isNaN(imgIndex)){
  102. var z = imgIndex.trim();
  103. if(z > arr.length || z <= 0){
  104. alert("内容中没有你要提取的图片!");
  105. return;
  106. }else{
  107. for(var i=1; i <= arr.length; i++){
  108. if(i == z){
  109. alert("提取成功!");
  110. $("#imagePath_update").val(arr[i-1]);
  111. }
  112. }
  113. }
  114. }else{
  115. alert("请输入数字!");
  116. }
  117. }else{
  118. alert("请选择提取的图片!");
  119. }
  120. }
  121. }
  122. </script>