MapModelType.jsp 11.4 KB
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/systeminfo/init_wev8.jsp"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs2" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="cmutil" class="weaver.km.util.CommonTransUtil" scope="page" />
<%
	String mapId = Util.convertInput2DB(request.getParameter("mapId"));
	String docmodecontents = "";
	if(!"".equals(mapId)){
		rs.executeSql("select docmodecontents from KT_Map where id="+mapId);
	    if(rs.next()){
	        docmodecontents = Util.toHtmlMode(rs.getString("docmodecontents"));
	    }
	}
	//设置知识百科模版的说明
	String example = "<p style=\"text-align: center;\"> "+
		"    <span style=\"font-size: 24px;\">知识百科模式使用说明</span> "+
		"</p> "+
		"<h1 style=\"text-align: left;\"> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">标题1</span> "+
		"</h1> "+
		"<h2 style=\"text-align: left;\"> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">&nbsp; &nbsp;标题1.1<br/></span> "+
		"</h2> "+
		"<h2 style=\"text-align: left;\"> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">&nbsp; &nbsp;标题1.2</span> "+
		"</h2> "+
		"<h1 style=\"white-space: normal; text-align: left;\"> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">标题2</span> "+
		"</h1> "+
		"<h2 style=\"white-space: normal; text-align: left;\"> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">&nbsp; &nbsp;标题2.1<br/></span> "+
		"</h2> "+
		"<h2 style=\"white-space: normal; text-align: left;\"> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">&nbsp; &nbsp;标题2.2</span> "+
		"</h2> "+
		"<p> "+
		"    <span style=\"font-family: 微软雅黑, \" microsoft=\"\" font-size:=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size: 24px;\">选中内容后设置标题,左侧可以出现文档树形结构</span><br/></span> "+
		"</p> ";
	docmodecontents = docmodecontents.equals("")?example:docmodecontents;
	docmodecontents = docmodecontents.replaceAll("\n", "<br>");
	boolean isDocMode = false;
%>
<HTML>
	<HEAD>
		<title></title>
		<LINK href="/css/Weaver_wev8.css" type=text/css rel=STYLESHEET>
		<SCRIPT language="javascript" src="/knowledgeMap/js/common.js"></script>
		<SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
		<script language="JavaScript" src="/js/addRowBg_wev8.js"></script>
        <script type="text/javascript" src="/wui/common/js/ckeditor/ckeditor_wev8.js"></script>
        <script type="text/javascript" src="/wui/common/js/ckeditor/ckeditorext_wev8.js"></script>
		
		<script type="text/javascript" src="../js/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" src="../js/ueditor/ueditor.all.js"></script>
		<script type="text/javascript" src="../js/ueditor/ueditor.parse.js"></script>
		<script type="text/javascript" src="../js/ueditor/lang/zh-cn/zh-cn.js"></script>
		<script type="text/javascript" src="/wui/theme/ecology8/page/perfect-scrollbar/perfect-scrollbar_wev8.js"></script>
		<script type="text/javascript" src="/wui/theme/ecology8/page/perfect-scrollbar/jquery.mousewheel_wev8.js"></script>
		<script src="/js/tabs/jquery.tabs.extend_wev8.js"></script>
		<link type="text/css" href="/js/tabs/css/e8tabs1_wev8.css" rel="stylesheet" />
        <link type="text/css" href="/knowledgeMap/css/rightmenu.css" rel="stylesheet" />
		<SCRIPT language="javascript" src="/knowledgeMap/js/rightmenu.js"></script>
		<style type="text/css">
			Table.detail td{
				line-height: 25px;
				padding: 1px !important;
			}
            .addKnowCls{
                width: 60px;
				background: #F5EAFA;
				height: 25px;
				text-align: center;
				line-height: 25px;
				font-size: 12px;
				cursor: pointer;
				display: inline-block;
				margin-right: 5px;
				float: left;
				border-radius: 4px;
            }
            .addKnowCls:hover{
                background:#F5CAFA;
            }
             .ListStyle th{
            	padding-left: 12px;
            }
            TABLE.ListStyle tr {
				border-bottom: 1px solid #E0E0E0;
			}
			.kt_moveUp{
				cursor: pointer;
				margin-left: 5px;
				transform: rotateX(180deg);
				display: none;
			}
			.kt_moveDown{
				cursor: pointer;
				margin-left: 5px;
				display: none;
			}
			/**知识百科模式css样式**/
            #directionContainer ul {
				margin: 0px;
				padding: 0px 0px 0px 20px;
			}
			
			.main {
				width: 100%;
				min-height: 500px;
				margin-top: 5px;
			}
			
			.left {
				width: 270px;
				height: 50px;
				float: left;
			}
			
			.right {
				max-width: 78%;
				float: left;
			}
			
			#directionWrapper {
				padding: 15px 7px;
				border: 1px solid #CCC;
				margin-right: 14px;
				width: 240px;
			}
			
			.directionTitle {
				font-weight: bold;
				font-size: 14px;
				padding-bottom: 3px;
				border-bottom: 1px dashed #ccc;
			}
			
			.sectionItem {
				height: 22px;
				line-height: 22px;
			}
			
			.sectionItem span {
				*zoom: 1;
				display: inline-block;
			}
			.selectIcon,.deleteIcon,.moveUp,.moveDown {
				float: right;
				color: red;
				font-size: 0px;
				line-height: 20px;
				height: 20px;
				text-align: center;
				cursor: pointer;
			}
			
			.selectIcon,.moveUp,.moveDown {
				width: 14px;
				font-size: 10px;
			}
			
			.selectIcon:hover,.moveUp:hover,.moveDown:hover {
				text-decoration: underline;
			}
			
			.deleteIcon {
				width: 20px;
				margin-left: 3px;
				background: url('/knowledgeMap/js/ueditor/themes/default/images/icons-all.gif') 0 -89px;
			}
			
			.fixTop {
				position: fixed;
				top: -1px;
			}
			
			.btn {
				width: 30px;
				height: 30px;
				line-height: 30px;
				margin-left: 820px;
				border: 1px #ccc solid;
				border-radius: 50%;
				color: #fff;
				background-color: #2a7ee7;
				cursor: pointer;
				font-size: 12px;
				text-align: center;
				display: inline-block;
			}
			.edui-editor-toolbarbox,.edui-editor {
				width: 100%;
			}
			div.edui-editor-iframeholder {
				width: 100% !important;
			}
            /**知识百科模式css样式**/
		</style>
	</head>
	<BODY>
		<table width=100% border="0" cellspacing="0" cellpadding="0">
			<colgroup>
				<col width="10">
				<col width="">
				<col width="10">
			</colgroup>
			<tr>
				<td height="10" colspan="3"></td>
			</tr>
			<tr>
				<td></td>
				<td valign="top">
					<TABLE class=Shadow>
						<tr>
							<td valign="top">
									<input class=inputstyle type="hidden" name=mapId value="<%=mapId %>"/>
									<textarea id="contents" name="contents" rows="0" cols="0" style="display: none;"></textarea>
									<TABLE class=ViewForm>
										<TBODY>
											<!-- 知识地图主题开始 -->
											<TR>
												<TD vAlign=top>
													<div id="docMode">
															<div class="main">
																<div class="left">
																	<div id="directionWrapper">
																		<div class="directionTitle">目录:</div>
																		<div id="directionContainer"></div>
																	</div>
																</div>
																<div class="right">
																	<div id="editor" type="text/plain" style="height: 500px;"></div>
																</div>
																<div style="clear:both;"></div>
															</div>
														</div>
													</div>
												</TD>
											</TR>
											<!-- 知识地图主题结束 -->
										</TBODY>
									</TABLE>
							</td>
						</tr>
					</TABLE>
				</td>
				<td></td>
			</tr>
			<tr>
				<td height="10" colspan="3"></td>
			</tr>
		</table>
		<div id="docmodecontents" style="display: none;"><%=docmodecontents %></div>
		<script language=javascript>
			function saveData(obj) {
				return UE.getEditor("editor").getContent();
			}
			//实例化编辑器
			var ue = UE.getEditor('editor');
			
			ue.ready(function() {
				ue.addListener('updateSections', resetHandler);
			});
			
			var resetHandler = function() {
				var dirmap = {}, dir = ue.execCommand('getsections');
				// 更新目录树
				$('#directionContainer').html(traversal(dir) || null);
				
				// 删除章节按钮
				$('.deleteIcon').click(function(e) {
					var $target = $(this), address = $target.parent().attr('data-address');
					ue.execCommand('deletesection', dirmap[address]);
				});
				
				// 选中章节按钮
				$('.selectIcon').click(function(e) {
					var $target = $(this), address = $target.parent().attr('data-address');
					ue.execCommand('selectsection', dirmap[address], true);
				});
				
				// 章节上移
				$('.moveUp,.moveDown').click(function(e) {
					var $target = $(this), address = $target.parent().attr('data-address'),
						moveUp = $target.hasClass('moveUp') ? true : false;
					if ($target.hasClass('moveUp')) {
						ue.execCommand('movesection', dirmap[address], dirmap[address].previousSection);
					} else {
						ue.execCommand('movesection', dirmap[address], dirmap[address].nextSection, true);
					}
				});
				
				// 页面网上滚动时,让目录固定在顶部
				$(window).scroll(function(e) {
					if ($('.left').offset().top < (document.body.scrollTop || document.documentElement.scrollTop)) {
						$('#directionWrapper').addClass('fixTop');
					} else {
						$('#directionWrapper').removeClass('fixTop');
					}
				});
				
				function traversal(section) {
					var $list, $item, $itemContent, child, childList;
					if (section.children.length) {
						$list = $('<ul>');
						for ( var i = 0; i < section.children.length; i++) {
							child = section.children[i];
							//设置目录节点内容标签
							var title = getSubStr(child['title'], 18);
							$itemContent = $('<div class="sectionItem"></div>').html($('<span class="itemTitle">' + title + '</span>'));
							$itemContent.attr('data-address', child['startAddress'].join(','));
							$itemContent.append($('<span class="deleteIcon">删</span>'
									+ '<span class="selectIcon">选</span>'
									+ '<span class="moveUp">↑</span>'
									+ '<span class="moveDown">↓</span>'));
							dirmap[child['startAddress'].join(',')] = child;
							//设置目录节点容器标签
							$item = $('<li>');
							$item.append($itemContent);
							//继续遍历子节点
							if ($item.children.length) {
								childList = traversal(child);
								childList && $item.append(childList);
							}
							$list.append($item);
						}
					}
					return $list;
				}
			}
			
			function getSubStr(s, l) {
				var i = 0, len = 0;
				for (i; i < s.length; i++) {
					if (s.charAt(i).match(/[^\x00-\xff]/g) != null) {
						len += 2;
					} else {
						len++;
					}
					if (len > l) {
						break;
					}
				}
				return s.substr(0, i);
			};
			
			$(document).ready(function(){
				 jQuery(".right").width(jQuery(window).width()-jQuery(".left").width()-80);
			 	uParse('#editor',{
			        'liiconpath':'/knowledgeMap/js/ueditor/themes/ueditor-list/'  //使用 '/' 开头的绝对路径
			    })
				 //编辑器初始化设置内容
				UE.getEditor("editor").ready(function() {
					UE.getEditor("editor").setContent(jQuery("#docmodecontents").html());
				});
				
				jQuery("#directionWrapper").height(jQuery(window).height()*0.9);
				$("#directionWrapper").perfectScrollbar();
				
				jQuery(window).resize(function(){
			    	jQuery(".right").width(jQuery(window).width()-jQuery(".left").width()-80);
					jQuery("#edui1").width(jQuery("#editor").width());
				});
			});
		</script>
	</BODY>
</HTML>