Skip to content

Commit

Permalink
Merge pull request #50 from dongchangzhang/master
Browse files Browse the repository at this point in the history
树可以从后台传递数据
  • Loading branch information
gwc377561041 committed Nov 16, 2016
2 parents 3455bf6 + dea3ad7 commit 99247a8
Show file tree
Hide file tree
Showing 38 changed files with 136 additions and 144 deletions.
11 changes: 2 additions & 9 deletions DATABASEINFO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 创建数据库和相应的表
# 创建数据库和相应的表
EDIT@20160929
> 创建数据库
Expand Down Expand Up @@ -97,14 +97,7 @@ CREATE TABLE Tree
userid INT(11),
FOREIGN KEY (userid) REFERENCES User(userid)
);
#测试树(userid=2)
insert into Tree(nodename,pid,userid) values('A',0,2);
insert into Tree(nodename,pid,userid) values('B',1,2);
insert into Tree(nodename,pid,userid) values('C',1,2);
insert into Tree(nodename,pid,userid) values('D',2,2);
insert into Tree(nodename,pid,userid) values('E',2,2);
insert into Tree(nodename,pid,userid) values('F',3,2);
insert into Tree(nodename,pid,userid) values('G',6,2);
# 请增加执行
USE DBGHZ;
# 头像url
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified LiteratureManage/WebContent/WEB-INF/lib/fonts.jar
Binary file not shown.
Binary file not shown.
117 changes: 49 additions & 68 deletions LiteratureManage/WebContent/filemanage.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script type="text/javascript" src="sources/js/jquery.ztree.exedit.js"></script>
<link href="sources/css/animate.css" rel="stylesheet" type="text/css">
<SCRIPT type="text/javascript">
<!--
//<!--
var setting = {
view: {
addHoverDom: addHoverDom,
Expand All @@ -33,8 +33,8 @@
edit: {
enable: true,
editNameSelectAll: true,
showRemoveBtn: showRemoveBtn,
showRenameBtn: showRenameBtn
showRemoveBtn: true,
showRenameBtn: true
},
data: {
simpleData: {
Expand Down Expand Up @@ -73,31 +73,10 @@
var zNodes1 = [{
id: 1,
pId: 0,
name: "父节点 1",
name: "这里创建新的分类",
open: true
}, {
id: 11,
pId: 1,
name: "叶子节点 1-1",
url: "http://www.baidu.com"
}, {
id: 2,
pId: 0,
name: "父节点 2",
open: true
}, {
id: 21,
pId: 2,
name: "叶子节点 2-1"
}];
var zNodes2 =[
{ id:1, pId:0, name:"zTree Home", url:"http://www.ztree.me/", target:"_blank"},
{ id:2, pId:0, name:"zTree in Google", url:"http://code.google.com/p/jquerytree/", target:"_blank"},
{ id:3, pId:0, name:"zTree in Iteye", url:"http://ztreeapi.iteye.com/", target:"_blank"},
{ id:4, pId:0, name:"Nothing...", url:"", target:"_blank", click:"alert('我是不会跳转的...');"}
];
var log, className = "dark";
function beforeDrag(treeId, treeNodes) {
return true;
}
Expand Down Expand Up @@ -143,27 +122,22 @@
window.open(treeNode.url);
return true;
}
function onRename(e, treeId, treeNode, isCancel) {
showLog((isCancel ? "<span style='color:red'>" : "") + "[ " + getTime() + " onRename ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name + (isCancel ? "</span>" : ""));
}
function showRemoveBtn(treeId, treeNode) {
return !treeNode.isFirstNode;
}
function showRenameBtn(treeId, treeNode) {
return !treeNode.isLastNode;
}
function showLog(str) {
if (!log) log = $("#log");
log.append("<li class='" + className + "'>" + str + "</li>");
if (log.children("li").length > 8) {
log.get(0).removeChild(log.children("li")[0]);
}
}
function getTime() {
var now = new Date(),
h = now.getHours(),
Expand All @@ -172,31 +146,23 @@
ms = now.getMilliseconds();
return (h + ":" + m + ":" + s + " " + ms);
}
var newCount = 1;
function addHoverDom(treeId, treeNode) {
var sObj = $("#" + treeNode.tId + "_span");
if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0) return;
var addStr = "<span class='button add' id='addBtn_" + treeNode.tId +
"' title='add node' onfocus='this.blur();'></span>";
sObj.after(addStr);
var btn = $("#addBtn_" + treeNode.tId);
if (btn) btn.bind("click", function() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.addNodes(treeNode, {
id: (100 + newCount),
pId: treeNode.id,
name: "new node" + (newCount++)
});
return false;
});
};
function addHoverDom(treeId, treeNode) {
var sObj = $("#" + treeNode.tId + "_span");
if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
+ "' title='add node' onfocus='this.blur();'></span>";
sObj.after(addStr);
var btn = $("#addBtn_"+treeNode.tId);
if (btn) btn.bind("click", function(){
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.addNodes(treeNode, {id:(100 + newCount), pId:treeNode.id, name:"new node" + (newCount++)});
return false;
});
};
function removeHoverDom(treeId, treeNode) {
$("#addBtn_" + treeNode.tId).unbind().remove();
};
function selectAll() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.setting.edit.editNameSelectAll = $("#selectAll").attr("checked");
Expand All @@ -205,12 +171,12 @@
return targetNode ? targetNode.drop !== false : true;
}
$(document).ready(function(){
$("#selectAll").bind("click", selectAll);
$.fn.zTree.init($("#treeDemo"), setting, zNodes1);
$.fn.zTree.init($("#treeDemo2"), setting2, zNodes2);
//$(document).ready(function(){
// $("#selectAll").bind("click", selectAll);
// $.fn.zTree.init($("#treeDemo"), setting, zNodes1);
// $.fn.zTree.init($("#treeDemo2"), setting2, zNodes2);
});
//});
//-->
// 点击我定义的那个按钮执行action
function myFunction() {
Expand All @@ -229,6 +195,22 @@
$("#msg").val(msg);
alert(msg)
}
$(document).ready(function() {
$.fn.zTree.init($("#treeDemo"), setting, zNodes1);
$.ajax( {
url : "searchAllBooks.action",
type : "get",
dataType : "json",
success : initZtree
});
});
function initZtree(json) {
var data = (json.result);
var zNodes2 = eval("(" + data + ")");
zTreeObj = $.fn.zTree.init($('#treeDemo2'), setting2, zNodes2);
}
</SCRIPT>
<style type="text/css">
.ztree li span.button.add {
Expand Down Expand Up @@ -337,18 +319,17 @@
<div class="panel-heading">
<h3 class="panel-title">构建分类树</h3>
</div>
<div class="panel-body"><div class="content_wrap">
<div>
<button onclick="myFunction()">点击这里</button>
</div>
<div class="zTreeDemoBackground left">
<ul id="treeDemo" class="ztree"></ul>
</div>
<div class="right">
<ul id="treeDemo2" class="ztree"></ul>
</div>
</div>
</div>
<div class="panel-body">
<div class="content_wrap">
<div><button onclick="myFunction()">点击这里</button></div>
<div class="zTreeDemoBackground left">
<ul id="treeDemo" class="ztree "></ul>
</div>
<div class="right">
<ul id="treeDemo2" class="ztree pull-right"></ul>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="panel-3">
Expand Down
14 changes: 7 additions & 7 deletions LiteratureManage/WebContent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
<title>LiteratureManager Welcome</title>
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="container-fluid" ">
<div class="row-fluid clearfix">
<div class="col-md-12 column">
<nav class="navbar navbar-default navbar-inverse navbar-fixed-top" style="background:#036564;border:none" role="navigation">
<div class="navbar-header">
Expand Down Expand Up @@ -132,7 +132,7 @@
</div>
</div>
</div>
<div><br><br><br><br></div>
<div><br><br></div>
<div class="carousel slide" id="carousel-345074" data-ride="carousel">
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#carousel-345074"></li>
Expand All @@ -141,21 +141,21 @@
</ol>
<div class="carousel-inner">
<div class="item active">
<img alt="" src="sources/pics/1.jpg"/>
<img alt="" src="sources/pics/1.jpg"/ style=" width:100%; height:50%; z-index:-1; left:0; top:0;">
<div class="carousel-caption">
<h4>阅读 & 评论</h4>
<p>就像其他同类网站做的那样,阅读文章,发表评论</p>
</div>
</div>
<div class="item">
<img alt="" src="sources/pics/2.jpg"/>
<div class="item" >
<img alt="" src="sources/pics/2.jpg"/ style="left:0;top:0;" width="100%" height="80%">
<div class="carousel-caption">
<h4>分享 & 下载</h4>
<p>与他人分享,下载你感兴趣或对你有帮助的</p>
</div>
</div>
<div class="item">
<img alt="" src="sources/pics/3.jpg"/>
<img alt="" src="sources/pics/3.jpg"/ style="left:0;top:0;" width="100%" height="80%">
<div class="carousel-caption">
<h4>创建你自己的树</h4>
<p>将意义非凡的痕迹记录在这儿</p>
Expand Down
6 changes: 0 additions & 6 deletions LiteratureManage/WebContent/personalcenter.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,6 @@
<div class="form-group">
<input name="articlename" class="form-control" type="text" placeholder="请在这儿输入文件名" required style="padding-left: 30px; height: 42px;" />
</div>
<div class="form-group">
<input name="file" id='file' class="upload" type="file" required style="border:1px solid #ccc;background:#fff;color:#000;padding:5px 15px;width:370px;" />
</div>
</form>
<button type="submit" class="btn btn-success pull-right" form="upload_form" >上传</button>
</div>
<div class="form-group">
<input name="file" id='file' class="upload" type="file" required style="border:1px solid #ccc;background:#fff;color:#000;padding:5px 15px;width:370px;" />
</div>
Expand Down
10 changes: 5 additions & 5 deletions LiteratureManage/WebContent/sources/css/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ li {list-style: circle;font-size: 12px;}
li.title {list-style: none;}
ul.list {margin-left: 17px;}

div.content_wrap {width: 600px;height:380px;}
div.content_wrap div.left{float: left;width: 250px;}
div.content_wrap div.right{float: right;width: 340px;}
div.zTreeDemoBackground {width:250px;height:362px;text-align:left;}
div.content_wrap {width: 100%;height:380px;}
div.content_wrap div.left{float: left;width: 70%;}
div.content_wrap div.right{float: right;width: 30%;}
div.zTreeDemoBackground {width:100%;height:362px;text-align:left;}

ul.ztree {margin-top: 10px;border: 1px solid #617775;background: #f0f6e4;width:220px;height:360px;overflow-y:scroll;overflow-x:auto;}
ul.ztree {margin-top: 10px;border: 1px solid #617775;background: #f9f9f9;width:97%;height:360px;overflow-y:auto;overflow-x:auto;}
ul.log {border: 1px solid #617775;background: #f0f6e4;width:300px;height:170px;overflow: hidden;}
ul.log.small {height:45px;}
ul.log li {color: #666666;list-style: none;padding-left: 10px;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="org.apache.commons.fileupload.servlet.*" %>
<%@ page import="org.json.simple.*" %>
<%
/**
Expand All @@ -16,6 +17,7 @@
//文件保存目录路径
String savePath = pageContext.getServletContext().getRealPath("/") + "attached/";
System.out.println(savePath);
//文件保存目录URL
String saveUrl = request.getContextPath() + "/attached/";
Expand Down Expand Up @@ -97,6 +99,8 @@ while (itr.hasNext()) {
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
try{
System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
System.out.println(savePath + " | " + newFileName);
File uploadedFile = new File(savePath, newFileName);
item.write(uploadedFile);
}catch(Exception e){
Expand Down
36 changes: 34 additions & 2 deletions LiteratureManage/src/com/teamghz/action/AjaxExampleAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package com.teamghz.action;


import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;
import java.util.Map;


import net.sf.json.JSONArray;
import net.sf.json.JSONObject;



public class AjaxExampleAction {

Expand All @@ -15,11 +28,30 @@ public void setName(String name) {
public String getResult() {
return result;
}

public String execute() {
this.result = "Hello! " + this.name + ".";
String tmp = "";
System.out.println("hereh" + this.name);
Map map = new HashMap();
List<String> lstTree = new ArrayList<String>();
JSONObject jsonObject;

String s1 = "{id:1, pId:0, name:\"test1\" , open:true}";
String s2 = "{id:11, pId:1, name:\"test1\" , open:true}";
lstTree.add(s1);
lstTree.add(s2);


String s = JSONArray.fromObject(lstTree).toString();

result = s;
System.out.println(s);




return "success";
}


}
2 changes: 1 addition & 1 deletion LiteratureManage/src/com/teamghz/action/GeneratePDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void HTMLToPDF(String articleID, String noteToHTMLPath) {
PD4ML pd4ml = new PD4ML();
pd4ml.setPageInsets(new Insets(20, 10, 10, 10));
pd4ml.setHtmlWidth(950);
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
pd4ml.setPageSize(PD4Constants.A4);
pd4ml.useTTF("java:fonts", true);
pd4ml.setDefaultTTFs("KaiTi", "KaiTi", "KaiTi");
pd4ml.enableDebugInfo();
Expand Down

0 comments on commit 99247a8

Please sign in to comment.