first updata
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,325 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v4.6.1 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
line-height: 1.15;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
color: #212529;
|
||||
text-align: left;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
[tabindex="-1"]:focus:not(:focus-visible) {
|
||||
outline: 0 !important;
|
||||
}
|
||||
|
||||
hr {
|
||||
box-sizing: content-box;
|
||||
height: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
abbr[title],
|
||||
abbr[data-original-title] {
|
||||
text-decoration: underline;
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
cursor: help;
|
||||
border-bottom: 0;
|
||||
-webkit-text-decoration-skip-ink: none;
|
||||
text-decoration-skip-ink: none;
|
||||
}
|
||||
|
||||
address {
|
||||
margin-bottom: 1rem;
|
||||
font-style: normal;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul,
|
||||
dl {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
ol ol,
|
||||
ul ul,
|
||||
ol ul,
|
||||
ul ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-bottom: .5rem;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
sub,
|
||||
sup {
|
||||
position: relative;
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -.5em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #0056b3;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:not([href]):not([class]) {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:not([href]):not([class]):hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
pre,
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
overflow: auto;
|
||||
-ms-overflow-style: scrollbar;
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
img {
|
||||
vertical-align: middle;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
svg {
|
||||
overflow: hidden;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
caption {
|
||||
padding-top: 0.75rem;
|
||||
padding-bottom: 0.75rem;
|
||||
color: #6c757d;
|
||||
text-align: left;
|
||||
caption-side: bottom;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: inherit;
|
||||
text-align: -webkit-match-parent;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-block;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
button:focus:not(:focus-visible) {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
input,
|
||||
button,
|
||||
select,
|
||||
optgroup,
|
||||
textarea {
|
||||
margin: 0;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
button,
|
||||
input {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
[role="button"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select {
|
||||
word-wrap: normal;
|
||||
}
|
||||
|
||||
button,
|
||||
[type="button"],
|
||||
[type="reset"],
|
||||
[type="submit"] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
button:not(:disabled),
|
||||
[type="button"]:not(:disabled),
|
||||
[type="reset"]:not(:disabled),
|
||||
[type="submit"]:not(:disabled) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button::-moz-focus-inner,
|
||||
[type="button"]::-moz-focus-inner,
|
||||
[type="reset"]::-moz-focus-inner,
|
||||
[type="submit"]::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
input[type="radio"],
|
||||
input[type="checkbox"] {
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
legend {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
padding: 0;
|
||||
margin-bottom: .5rem;
|
||||
font-size: 1.5rem;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
[type="number"]::-webkit-inner-spin-button,
|
||||
[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
[type="search"] {
|
||||
outline-offset: -2px;
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
font: inherit;
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
output {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
/*# sourceMappingURL=bootstrap-reboot.css.map */
|
||||
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v4.6.1 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([class]){color:inherit;text-decoration:none}a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto;-ms-overflow-style:scrollbar}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit;text-align:-webkit-match-parent}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
|
||||
/*# sourceMappingURL=bootstrap-reboot.min.css.map */
|
||||
@@ -0,0 +1,105 @@
|
||||
body {
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
.feather {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sidebar
|
||||
*/
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.sidebar {
|
||||
top: 5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-sticky {
|
||||
position: relative;
|
||||
top: 0;
|
||||
height: calc(100vh - 48px);
|
||||
padding-top: .5rem;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
|
||||
}
|
||||
|
||||
@supports ((position: -webkit-sticky) or (position: sticky)) {
|
||||
.sidebar-sticky {
|
||||
position: -webkit-sticky;
|
||||
position: sticky;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.sidebar .nav-link .feather {
|
||||
margin-right: 4px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover .feather,
|
||||
.sidebar .nav-link.active .feather {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.sidebar-heading {
|
||||
font-size: .75rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/*
|
||||
* Navbar
|
||||
*/
|
||||
|
||||
.navbar-brand {
|
||||
padding-top: .75rem;
|
||||
padding-bottom: .75rem;
|
||||
font-size: 1rem;
|
||||
background-color: rgba(0, 0, 0, .25);
|
||||
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
|
||||
}
|
||||
|
||||
.navbar .navbar-toggler {
|
||||
top: .25rem;
|
||||
right: 1rem;
|
||||
}
|
||||
|
||||
.navbar .form-control {
|
||||
padding: .75rem 1rem;
|
||||
border-width: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.form-control-dark {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
border-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
.form-control-dark:focus {
|
||||
border-color: transparent;
|
||||
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
|
||||
}
|
||||
|
||||
.card-body .btn {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.modal-body input {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.modal-body .btn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
@@ -0,0 +1,632 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>协作学习投入智能干预平台(学生端)</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
|
||||
|
||||
<!--script start-->
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
|
||||
<script src="/static/js/mind/c_m_m.js"></script>
|
||||
<script>
|
||||
const DefaultView = function () {
|
||||
this.websocket = null
|
||||
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
this.current_page_num = 1
|
||||
this.default_page_size = 15
|
||||
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
|
||||
}
|
||||
|
||||
DefaultView.prototype = {
|
||||
/**界面初始化*/
|
||||
init_view: function () {
|
||||
const uid = $('#uid').html()
|
||||
// 未登录
|
||||
if (!uid || isNaN(uid)) {
|
||||
$('#login_register').show()
|
||||
setTimeout(function () {
|
||||
$('#login_register').click()
|
||||
}, 500)
|
||||
$('#logout_a').hide()
|
||||
$('#newMindModal_btn').hide()
|
||||
} else {
|
||||
$('#login_register').hide()
|
||||
$('#logout_a').show()
|
||||
}
|
||||
|
||||
// 判断页面
|
||||
const page_tag = this.get_page_tag()
|
||||
$('#main h5').html(this.title_map.get(page_tag))
|
||||
},
|
||||
get_uu_id: function () {
|
||||
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
},
|
||||
/**注销登录*/
|
||||
logout_: function () {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "logout",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'xx': 'xx'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
common_alert(data.msg)
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得源页面*/
|
||||
get_page_tag: function () {
|
||||
return $('#src_page').html()
|
||||
},
|
||||
/**获得导图*/
|
||||
fetch_mind: function (current_page, page_size) {
|
||||
const me = this
|
||||
if (!current_page) {
|
||||
current_page = me.current_page_num
|
||||
}
|
||||
if (!page_size) {
|
||||
page_size = me.default_page_size
|
||||
}
|
||||
me.current_page_num = current_page
|
||||
|
||||
// 获得跳转源页面
|
||||
const page_tag = me.get_page_tag()
|
||||
$.ajax({
|
||||
type: `get`,
|
||||
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code !== 0) {
|
||||
return
|
||||
}
|
||||
// clear container-fluid
|
||||
$('main .container-fluid').empty()
|
||||
|
||||
// 解析结果
|
||||
const results = resp.results
|
||||
let idx = 0
|
||||
let row = $(`<div class="row"></row>`)
|
||||
|
||||
results.forEach(function (item) {
|
||||
const uuid = me.get_uu_id()
|
||||
|
||||
// 添加按钮组
|
||||
let sub_btn = '';
|
||||
if (page_tag === 'b9b101e') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
|
||||
} else if (page_tag === 'share') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
|
||||
} else if (page_tag === 'star') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
|
||||
} else if (page_tag === 'recycle') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
|
||||
}
|
||||
|
||||
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
|
||||
<div class="card-body">
|
||||
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
||||
<hr style="margin: 0">
|
||||
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
|
||||
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
row.append(content)
|
||||
})
|
||||
|
||||
// 如果不是3的整数倍,将剩余的添加
|
||||
$('main .container-fluid').append(row)
|
||||
me.init_pagination(resp.count, me.default_page_size)
|
||||
// success end
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**显示分享链接*/
|
||||
show_share_url: function (u, h) {
|
||||
const url = `s_2_d?u=${u}&h=${h}`
|
||||
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
|
||||
$('#share_mind_modal_a').click()
|
||||
},
|
||||
/**分页组件*/
|
||||
init_pagination: function (count, page_size) {
|
||||
const container = $('#pagination_div')
|
||||
/**计算页数*/
|
||||
if (count <= 0) {
|
||||
container.html(`<p class="text-center">无数据</p>`)
|
||||
return
|
||||
}
|
||||
|
||||
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
|
||||
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||
|
||||
if (this.current_page_num > 1) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||
}
|
||||
for (let i = 0; i < all_page; i++) {
|
||||
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||
if (i + 1 === this.current_page_num) {
|
||||
ctt.addClass('active')
|
||||
}
|
||||
navigation_ul.append(ctt)
|
||||
}
|
||||
if (this.current_page_num < all_page) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||
}
|
||||
navigation.append(navigation_ul)
|
||||
container.empty()
|
||||
container.append(navigation)
|
||||
},
|
||||
/**删除导图*/
|
||||
del_mind: function (mind_id, card_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code === 0) {
|
||||
primary_alert(data.msg)
|
||||
// $('#' + card_id).remove()
|
||||
setTimeout(function () {
|
||||
me.fetch_mind()
|
||||
}, 1000)
|
||||
} else {
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**分享脑图*/
|
||||
share_mind: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**取消分享*/
|
||||
share_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
location.reload()
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 删除恢复*/
|
||||
del_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "delete_cancel",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**彻底删除*/
|
||||
del_final: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 取消收藏 */
|
||||
un_star: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得分享信息*/
|
||||
fetch_share_info: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
const data = resp.data
|
||||
me.show_share_url(data.share_uuid, data.share_uuid_hash)
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
is_success_resp(resp) {
|
||||
return resp.code === 0
|
||||
},
|
||||
/** 清除注册时输入内容 */
|
||||
clear_reg_info: function () {
|
||||
$('#userName').val('');
|
||||
$('#inputPassword').val('');
|
||||
$('#inputPassword_').val('');
|
||||
},
|
||||
/**校验密码是否输入一致*/
|
||||
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
||||
if (inputPassword !== inputPassword_) {
|
||||
common_alert('两次密码输入不一样,请确认!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
/** 设置窗口名称 */
|
||||
set_modal_title: function (title) {
|
||||
$('#exampleModal .modal-title').html(title);
|
||||
},
|
||||
|
||||
/************************************************************************************************/
|
||||
/**初始化jquery监听*/
|
||||
jq_listener_init: function () {
|
||||
const me = this
|
||||
/**监听modal窗口事件*/
|
||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
|
||||
ws.onmessage = function (e) {
|
||||
console.log('接收到websocket消息:' + e.data)
|
||||
}
|
||||
me.websocket = ws
|
||||
});
|
||||
$('#exampleModal').on('hidden.bs.modal', function (event) {
|
||||
// console.log('关闭');
|
||||
if (me.websocket) {
|
||||
me.websocket.close()
|
||||
}
|
||||
});
|
||||
|
||||
/**点击 扫码登录 */
|
||||
$('#s_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.qr_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
// 点击注册控件
|
||||
$('#register_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.register_group').show();
|
||||
me.set_modal_title('注册');
|
||||
})
|
||||
|
||||
// 用户名密码登录
|
||||
$('#p_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.pw_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
/** 注册按钮 */
|
||||
$('#register_button').click(function () {
|
||||
const userName = $('#userName').val();
|
||||
const inputPassword = $('#inputPassword').val();
|
||||
const inputPassword_ = $('#inputPassword_').val();
|
||||
|
||||
if (!userName) {
|
||||
common_alert('请输入用户名')
|
||||
return
|
||||
}
|
||||
|
||||
if (!inputPassword) {
|
||||
common_alert('请输入密码')
|
||||
return
|
||||
}
|
||||
|
||||
// 校验输入是否一致
|
||||
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
|
||||
if (validate) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "register",
|
||||
data: {userName: userName, inputPassword: inputPassword},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
me.clear_reg_info()
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
setTimeout(function () {
|
||||
$('#p_login_a').click()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 注册失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
// validate end
|
||||
});
|
||||
|
||||
/**登录按钮*/
|
||||
$('#login_button').click(function () {
|
||||
const userName_login = $('#userName_login').val();
|
||||
const inputPassword_login = $('#inputPassword_login').val();
|
||||
if (!userName_login || !inputPassword_login) {
|
||||
common_alert('请输入用户名和密码')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "login",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {username: userName_login, password: inputPassword_login},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 登录成功
|
||||
if (data.code === 0) {
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
$('#exampleModal').modal('hide')
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 500)
|
||||
} else {
|
||||
// 登录失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
|
||||
/**新建导图*/
|
||||
$('#new_mind_btn').click(function () {
|
||||
const mind_name = $('#mindName').val()
|
||||
if (!mind_name) {
|
||||
common_alert('请输入导图名称')
|
||||
return
|
||||
}
|
||||
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "create",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: post_data,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code === 0) {
|
||||
me.fetch_mind()
|
||||
$('#newMindModal').modal('hide')
|
||||
if ($('#exampleCheck1').prop("checked")) {
|
||||
/**新页面打开*/
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('2_d?id=' + id + `&s_p=b9b101e`)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
/** 新建后打开复选框勾选事件*/
|
||||
$('#exampleCheck1').change(function () {
|
||||
const checked = $(this).prop("checked")
|
||||
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||
})
|
||||
|
||||
/** 创建导图modal 显示完毕后事件*/
|
||||
$('#newMindModal').on('shown.bs.modal', function () {
|
||||
const cookie_checked_ = $.cookie('open_aft_create')
|
||||
$('#mindName').val('')
|
||||
// 从cookie中获得的是字符串
|
||||
if (cookie_checked_ === 'true') {
|
||||
$('#exampleCheck1').attr('checked', 'checked')
|
||||
} else {
|
||||
$('#exampleCheck1').removeAttr('checked');
|
||||
}
|
||||
})
|
||||
/************************************* jq_listener_init end *******************************************/
|
||||
}
|
||||
/** prototype end **/
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
const view = new DefaultView()
|
||||
/**初始化*/
|
||||
view.init_view()
|
||||
view.jq_listener_init()
|
||||
|
||||
/**如果已经登录则查询列表*/
|
||||
view.fetch_mind()
|
||||
window.mind = view
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
<!--script end-->
|
||||
</head>
|
||||
<body>
|
||||
<div style="display: none;">
|
||||
<span id="uid">{{ user.id }}</span>
|
||||
<span id="src_page">{{ page }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 页眉 start-->
|
||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
|
||||
<ul class="navbar-nav px-3">
|
||||
<li class="nav-item text-nowrap">
|
||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- 页眉 end-->
|
||||
|
||||
<!--菜单 和 内容 start-->
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- 左侧菜单 start-->
|
||||
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
|
||||
<div class="sidebar-sticky pt-3">
|
||||
<hr/>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/">
|
||||
<span data-feather="file-text"></span>
|
||||
协作脑图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_share">
|
||||
<span data-feather="share-2"></span>
|
||||
协作分享
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_star">
|
||||
<span data-feather="star"></span>
|
||||
协作收藏
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_echart">
|
||||
<span data-feather="star"></span>
|
||||
学习分析图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/chat_room">
|
||||
<span data-feather="star"></span>
|
||||
聊天室
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="star"></span>
|
||||
任务详情
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/ke_cheng">
|
||||
<span data-feather="star"></span>
|
||||
课程页面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_recycle">
|
||||
<span data-feather="trash-2"></span>
|
||||
回收站
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- 左侧菜单 end-->
|
||||
|
||||
<!-- 右侧内容 start-->
|
||||
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-md-4" id="main">
|
||||
<div style="margin-bottom: 0px;" class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h5 class="h5">全部文件</h5>
|
||||
<button id="newMindModal_btn" type="button" class="btn btn-info" data-toggle="modal" data-target="#newMindModal">新建导图</button>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<!--
|
||||
<div class="row">
|
||||
<div class="card col-3" style="width: 18rem;margin: 8px;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">学习进度</h5>
|
||||
<img src="https://img0.baidu.com/it/u=218959243,558802769&fm=253&fmt=auto&app=138&f=JPEG?w=1377&h=500" class="card-img-top" alt="...">
|
||||
<a href="#" class="btn btn-info">编辑</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<!-- navigation start-->
|
||||
<div id="pagination_div" style="margin-top: 15px;"></div>
|
||||
<!-- navigation end-->
|
||||
</main>
|
||||
<!-- 右侧内容 end-->
|
||||
</div>
|
||||
</div>
|
||||
<!--导航 和 内容 end-->
|
||||
</body>
|
||||
<script src="/static/js/mind/modal.js"></script>
|
||||
<script>
|
||||
if (window.feather) {
|
||||
window.feather.replace();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,203 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>导图详情</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/js/jsmind.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
|
||||
<style>
|
||||
#jsmind_container {
|
||||
width: calc(100vw);
|
||||
height: calc(100vh - 50px);
|
||||
}
|
||||
|
||||
.un_selected {
|
||||
-moz-user-select: none; /*火狐*/
|
||||
-webkit-user-select: none; /*webkit浏览器*/
|
||||
-ms-user-select: none; /*IE10*/
|
||||
-khtml-user-select: none; /*早期浏览器*/
|
||||
user-select: none;
|
||||
}
|
||||
</style>
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="/static/js/jsmind.js"></script>
|
||||
<script src="/static/js/jsmind.draggable.js"></script>
|
||||
<script src="/static/js/jsmind.screenshot.js"></script>
|
||||
<script src="/static/js/jsmind.menu.js"></script>
|
||||
<script src="/static/js/jsmind.coop.js?d="></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="/static/js/mind/c_m_m.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
|
||||
<!-- js 压缩: https://www.toptal.com/developers/javascript-minifier -->
|
||||
<script>
|
||||
const fetch = function () {
|
||||
this.jm = null
|
||||
this.coop_mind_id = null
|
||||
this.coop_mind_log_id = null
|
||||
/**是否通过分享链接访问*/
|
||||
this.from_share = null
|
||||
}
|
||||
// prototype
|
||||
fetch.prototype = {
|
||||
randomNum: function (minNum, maxNum) {
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
return parseInt(Math.random() * minNum + 1, 10);
|
||||
case 2:
|
||||
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
expand_all: function () {
|
||||
this.jm.expand_all()
|
||||
},
|
||||
collapse_all: function () {
|
||||
this.jm.collapse_all()
|
||||
},
|
||||
loadMind: function () {
|
||||
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
||||
let id = `{{ id }}`;
|
||||
let u = `{{ u }}`;
|
||||
let h = `{{ h }}`;
|
||||
const from_share = id.length === 0
|
||||
this.from_share = from_share
|
||||
const me = this
|
||||
const url = from_share ? `s_d?u=${u}&h=${h}` : 'd?id=' + id + `&s_p=b9b101e`;
|
||||
$.get(url, function (resp) {
|
||||
if (resp.code === -1) {
|
||||
common_alert(resp.msg)
|
||||
return
|
||||
}
|
||||
// reset
|
||||
me.close_coop_timer_if_necessary()
|
||||
|
||||
// show
|
||||
let snapshot_data = resp.data.snapshot_data
|
||||
me.coop_mind_id = id
|
||||
|
||||
const resp_data = resp.data
|
||||
me.coop_mind_log_id = resp_data.mind_log_id
|
||||
const data_format = resp_data.data_format
|
||||
const coop_mind_name = resp.data.coop_mind_name
|
||||
|
||||
if (from_share) {
|
||||
me.coop_mind_id = resp_data.id
|
||||
}
|
||||
|
||||
// node_tree 和 node_array 需要被转成对象,freemind 不需要
|
||||
snapshot_data = (data_format === 'node_tree' || data_format === 'node_array') ? JSON.parse(snapshot_data) : snapshot_data
|
||||
me.show_mind(coop_mind_name, data_format, snapshot_data)
|
||||
$('#h1').html(coop_mind_name)
|
||||
})
|
||||
},
|
||||
// 清除定时任务等
|
||||
close_coop_timer_if_necessary() {
|
||||
if (this.jm && this.jm.coop) {
|
||||
this.jm.coop.clear_timer()
|
||||
}
|
||||
},
|
||||
show_mind: function (name, data_format, data_resp) {
|
||||
// options
|
||||
const options = {
|
||||
container: 'jsmind_container',
|
||||
editable: true,
|
||||
theme: 'primary',
|
||||
coop_api_url: 'jsmind_op',
|
||||
coop_ws_url: `ws://${window.location.host}/ws/jsmind/`,
|
||||
coop_mind_id: this.coop_mind_id,
|
||||
coop_mind_log_id: this.coop_mind_log_id,
|
||||
menuOpts: {
|
||||
showMenu: true,
|
||||
injectionList: [
|
||||
{target: 'edit', text: '编辑节点'},
|
||||
{target: 'addChild', text: '添加子节点'},
|
||||
{target: 'addBrother', text: '添加兄弟节点'},
|
||||
{target: 'delete', text: '删除节点'},
|
||||
{target: 'screenshot', text: '下载导图'},
|
||||
{target: 'showAll', text: '展开全部节点'},
|
||||
{target: 'hideAll', text: '收起全部节点'}
|
||||
]
|
||||
},
|
||||
view: {
|
||||
engine: 'svg' // 思维导图各节点之间线条的绘制引擎
|
||||
}
|
||||
}
|
||||
|
||||
// mind
|
||||
const mind = {
|
||||
/* 元数据,定义思维导图的名称、作者、版本等信息 */
|
||||
meta: {name: name, author: 'cy20081118148@163.com', version: '0.2'},
|
||||
/* 数据格式声明 */
|
||||
format: data_format,
|
||||
/* 数据内容 */
|
||||
data: {id: 'root', topic: 'jsMind'}
|
||||
}
|
||||
// eslint-disable-next-line new-cap
|
||||
let jsMind = window.jsMind
|
||||
this.jm = new jsMind(options)
|
||||
if (data_resp) {
|
||||
mind.data = data_resp
|
||||
}
|
||||
this.jm.show(mind)
|
||||
},
|
||||
/**收藏或者取消收藏*/
|
||||
star: function () {
|
||||
const coop_mind_id = this.coop_mind_id
|
||||
// ajax start
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': coop_mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
// ajax end
|
||||
},
|
||||
/**取消收藏*/
|
||||
un_star: function () {
|
||||
const coop_mind_id = this.coop_mind_id
|
||||
// ajax start
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': coop_mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
// ajax end
|
||||
}
|
||||
}
|
||||
|
||||
/***/
|
||||
$(function () {
|
||||
const xxObj = new fetch()
|
||||
xxObj.loadMind()
|
||||
window.xxObj = xxObj
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- -->
|
||||
<div style="position: absolute;top: 0px;z-index: 1000;cursor: pointer;" onclick="xxObj.collapse_all()"><span data-feather="folder-minus"></span><span class="un_selected">折叠</span></div>
|
||||
<div style="position: absolute;top: 0px;left:80px;z-index: 1000;cursor: pointer;" onclick="xxObj.expand_all()"><span data-feather="folder-plus"></span><span class="un_selected">展开</span></div>
|
||||
<div style="position: absolute;top: 0px;left:160px;z-index: 1000;cursor: pointer;" onclick="xxObj.star()"><span data-feather="star"></span><span class="un_selected">收藏</span></div>
|
||||
<div style="position: absolute;top: 0px;left:240px;z-index: 1000;cursor: pointer;" onclick="xxObj.un_star()"><span data-feather="arrow-up-circle"></span><span class="un_selected">取消收藏</span></div>
|
||||
<h3 id="h1" style="text-align: center;max-height: 40px;"></h3>
|
||||
<div id="jsmind_container"></div>
|
||||
</body>
|
||||
<script>
|
||||
if (window.feather) {
|
||||
window.feather.replace();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,844 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>协作学习投入智能干预平台(学生端)</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
|
||||
|
||||
<!--script start-->
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
|
||||
<script src="/static/js/mind/c_m_m.js"></script>
|
||||
<script>
|
||||
const DefaultView = function () {
|
||||
this.websocket = null
|
||||
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
this.current_page_num = 1
|
||||
this.default_page_size = 15
|
||||
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
|
||||
}
|
||||
|
||||
DefaultView.prototype = {
|
||||
/**界面初始化*/
|
||||
init_view: function () {
|
||||
const uid = $('#uid').html()
|
||||
// 未登录
|
||||
if (!uid || isNaN(uid)) {
|
||||
$('#login_register').show()
|
||||
setTimeout(function () {
|
||||
$('#login_register').click()
|
||||
}, 500)
|
||||
$('#logout_a').hide()
|
||||
$('#newMindModal_btn').hide()
|
||||
} else {
|
||||
$('#login_register').hide()
|
||||
$('#logout_a').show()
|
||||
}
|
||||
|
||||
// 判断页面
|
||||
const page_tag = this.get_page_tag()
|
||||
$('#main h5').html(this.title_map.get(page_tag))
|
||||
},
|
||||
get_uu_id: function () {
|
||||
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
},
|
||||
/**注销登录*/
|
||||
logout_: function () {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "logout",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'xx': 'xx'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
common_alert(data.msg)
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得源页面*/
|
||||
get_page_tag: function () {
|
||||
return $('#src_page').html()
|
||||
},
|
||||
/**获得导图*/
|
||||
fetch_mind: function (current_page, page_size) {
|
||||
const me = this
|
||||
if (!current_page) {
|
||||
current_page = me.current_page_num
|
||||
}
|
||||
if (!page_size) {
|
||||
page_size = me.default_page_size
|
||||
}
|
||||
me.current_page_num = current_page
|
||||
|
||||
// 获得跳转源页面
|
||||
const page_tag = me.get_page_tag()
|
||||
$.ajax({
|
||||
type: `get`,
|
||||
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code !== 0) {
|
||||
return
|
||||
}
|
||||
// clear container-fluid
|
||||
$('main .container-fluid').empty()
|
||||
|
||||
// 解析结果
|
||||
const results = resp.results
|
||||
let idx = 0
|
||||
let row = $(`<div class="row"></row>`)
|
||||
|
||||
results.forEach(function (item) {
|
||||
const uuid = me.get_uu_id()
|
||||
|
||||
// 添加按钮组
|
||||
let sub_btn = '';
|
||||
if (page_tag === 'b9b101e') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
|
||||
} else if (page_tag === 'share') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
|
||||
} else if (page_tag === 'star') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
|
||||
} else if (page_tag === 'recycle') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
|
||||
}
|
||||
|
||||
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
|
||||
<div class="card-body">
|
||||
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
||||
<hr style="margin: 0">
|
||||
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
|
||||
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
row.append(content)
|
||||
})
|
||||
|
||||
// 如果不是3的整数倍,将剩余的添加
|
||||
$('main .container-fluid').append(row)
|
||||
me.init_pagination(resp.count, me.default_page_size)
|
||||
// success end
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**显示分享链接*/
|
||||
show_share_url: function (u, h) {
|
||||
const url = `s_2_d?u=${u}&h=${h}`
|
||||
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
|
||||
$('#share_mind_modal_a').click()
|
||||
},
|
||||
/**分页组件*/
|
||||
init_pagination: function (count, page_size) {
|
||||
const container = $('#pagination_div')
|
||||
/**计算页数*/
|
||||
if (count <= 0) {
|
||||
container.html(`<p class="text-center">无数据</p>`)
|
||||
return
|
||||
}
|
||||
|
||||
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
|
||||
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||
|
||||
if (this.current_page_num > 1) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||
}
|
||||
for (let i = 0; i < all_page; i++) {
|
||||
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||
if (i + 1 === this.current_page_num) {
|
||||
ctt.addClass('active')
|
||||
}
|
||||
navigation_ul.append(ctt)
|
||||
}
|
||||
if (this.current_page_num < all_page) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||
}
|
||||
navigation.append(navigation_ul)
|
||||
container.empty()
|
||||
container.append(navigation)
|
||||
},
|
||||
/**删除导图*/
|
||||
del_mind: function (mind_id, card_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code === 0) {
|
||||
primary_alert(data.msg)
|
||||
// $('#' + card_id).remove()
|
||||
setTimeout(function () {
|
||||
me.fetch_mind()
|
||||
}, 1000)
|
||||
} else {
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**分享脑图*/
|
||||
share_mind: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**取消分享*/
|
||||
share_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
location.reload()
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 删除恢复*/
|
||||
del_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "delete_cancel",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**彻底删除*/
|
||||
del_final: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 取消收藏 */
|
||||
un_star: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得分享信息*/
|
||||
fetch_share_info: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
const data = resp.data
|
||||
me.show_share_url(data.share_uuid, data.share_uuid_hash)
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
is_success_resp(resp) {
|
||||
return resp.code === 0
|
||||
},
|
||||
/** 清除注册时输入内容 */
|
||||
clear_reg_info: function () {
|
||||
$('#userName').val('');
|
||||
$('#inputPassword').val('');
|
||||
$('#inputPassword_').val('');
|
||||
},
|
||||
/**校验密码是否输入一致*/
|
||||
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
||||
if (inputPassword !== inputPassword_) {
|
||||
common_alert('两次密码输入不一样,请确认!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
/** 设置窗口名称 */
|
||||
set_modal_title: function (title) {
|
||||
$('#exampleModal .modal-title').html(title);
|
||||
},
|
||||
|
||||
/************************************************************************************************/
|
||||
/**初始化jquery监听*/
|
||||
jq_listener_init: function () {
|
||||
const me = this
|
||||
/**监听modal窗口事件*/
|
||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
|
||||
ws.onmessage = function (e) {
|
||||
console.log('接收到websocket消息:' + e.data)
|
||||
}
|
||||
me.websocket = ws
|
||||
});
|
||||
$('#exampleModal').on('hidden.bs.modal', function (event) {
|
||||
// console.log('关闭');
|
||||
if (me.websocket) {
|
||||
me.websocket.close()
|
||||
}
|
||||
});
|
||||
|
||||
/**点击 扫码登录 */
|
||||
$('#s_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.qr_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
// 点击注册控件
|
||||
$('#register_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.register_group').show();
|
||||
me.set_modal_title('注册');
|
||||
})
|
||||
|
||||
// 用户名密码登录
|
||||
$('#p_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.pw_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
/** 注册按钮 */
|
||||
$('#register_button').click(function () {
|
||||
const userName = $('#userName').val();
|
||||
const inputPassword = $('#inputPassword').val();
|
||||
const inputPassword_ = $('#inputPassword_').val();
|
||||
|
||||
if (!userName) {
|
||||
common_alert('请输入用户名')
|
||||
return
|
||||
}
|
||||
|
||||
if (!inputPassword) {
|
||||
common_alert('请输入密码')
|
||||
return
|
||||
}
|
||||
|
||||
// 校验输入是否一致
|
||||
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
|
||||
if (validate) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "register",
|
||||
data: {userName: userName, inputPassword: inputPassword},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
me.clear_reg_info()
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
setTimeout(function () {
|
||||
$('#p_login_a').click()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 注册失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
// validate end
|
||||
});
|
||||
|
||||
/**登录按钮*/
|
||||
$('#login_button').click(function () {
|
||||
const userName_login = $('#userName_login').val();
|
||||
const inputPassword_login = $('#inputPassword_login').val();
|
||||
if (!userName_login || !inputPassword_login) {
|
||||
common_alert('请输入用户名和密码')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "login",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {username: userName_login, password: inputPassword_login},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 登录成功
|
||||
if (data.code === 0) {
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
$('#exampleModal').modal('hide')
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 500)
|
||||
} else {
|
||||
// 登录失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
|
||||
/**新建导图*/
|
||||
$('#new_mind_btn').click(function () {
|
||||
const mind_name = $('#mindName').val()
|
||||
if (!mind_name) {
|
||||
common_alert('请输入导图名称')
|
||||
return
|
||||
}
|
||||
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "create",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: post_data,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code === 0) {
|
||||
me.fetch_mind()
|
||||
$('#newMindModal').modal('hide')
|
||||
if ($('#exampleCheck1').prop("checked")) {
|
||||
/**新页面打开*/
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('2_d?id=' + id + `&s_p=b9b101e`)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
/** 新建后打开复选框勾选事件*/
|
||||
$('#exampleCheck1').change(function () {
|
||||
const checked = $(this).prop("checked")
|
||||
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||
})
|
||||
|
||||
/** 创建导图modal 显示完毕后事件*/
|
||||
$('#newMindModal').on('shown.bs.modal', function () {
|
||||
const cookie_checked_ = $.cookie('open_aft_create')
|
||||
$('#mindName').val('')
|
||||
// 从cookie中获得的是字符串
|
||||
if (cookie_checked_ === 'true') {
|
||||
$('#exampleCheck1').attr('checked', 'checked')
|
||||
} else {
|
||||
$('#exampleCheck1').removeAttr('checked');
|
||||
}
|
||||
})
|
||||
/************************************* jq_listener_init end *******************************************/
|
||||
}
|
||||
/** prototype end **/
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
const view = new DefaultView()
|
||||
/**初始化*/
|
||||
view.init_view()
|
||||
view.jq_listener_init()
|
||||
|
||||
/**如果已经登录则查询列表*/
|
||||
view.fetch_mind()
|
||||
window.mind = view
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
<!--script end-->
|
||||
</head>
|
||||
<body>
|
||||
<div style="display: none;">
|
||||
<span id="uid">{{ user.id }}</span>
|
||||
<span id="src_page">{{ page }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 页眉 start-->
|
||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
|
||||
<ul class="navbar-nav px-3">
|
||||
<li class="nav-item text-nowrap">
|
||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- 页眉 end-->
|
||||
|
||||
<!--菜单 和 内容 start-->
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- 左侧菜单 start-->
|
||||
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
|
||||
<div class="sidebar-sticky pt-3">
|
||||
<hr/>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/">
|
||||
<span data-feather="file-text"></span>
|
||||
协作脑图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_share">
|
||||
<span data-feather="share-2"></span>
|
||||
协作分享
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_star">
|
||||
<span data-feather="star"></span>
|
||||
协作收藏
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_echart">
|
||||
<span data-feather="star"></span>
|
||||
学习分析图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/chat_room">
|
||||
<span data-feather="star"></span>
|
||||
聊天室
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/reng_wu">
|
||||
<span data-feather="star"></span>
|
||||
任务详情
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/ke_cheng">
|
||||
<span data-feather="star"></span>
|
||||
课程页面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_recycle">
|
||||
<span data-feather="trash-2"></span>
|
||||
回收站
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- 左侧菜单 end-->
|
||||
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
|
||||
<div id="main" style="width: 600px;height:400px;"></div>
|
||||
<div id="app2" style="width: 600px;height:400px;"></div>
|
||||
</main>
|
||||
<!-- 右侧内容 start-->
|
||||
|
||||
<!-- 右侧内容 end-->
|
||||
</div>
|
||||
</div>
|
||||
<!--导航 和 内容 end-->
|
||||
</body>
|
||||
<script src="/static/js/mind/modal.js"></script>
|
||||
<script src="/static/js/echarts.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById('main'));
|
||||
|
||||
option = {
|
||||
color: ['#67F9D8', '#FFE434', '#56A3F1', '#FF917C'],
|
||||
title: {
|
||||
text: '贡献度雷达图'
|
||||
},
|
||||
legend: {},
|
||||
radar: [
|
||||
{
|
||||
indicator: [
|
||||
{ text: '1' },
|
||||
{ text: '2' },
|
||||
{ text: '3' },
|
||||
{ text: '4' },
|
||||
{ text: '5' }
|
||||
],
|
||||
center: ['25%', '50%'],
|
||||
radius: 120,
|
||||
startAngle: 90,
|
||||
splitNumber: 4,
|
||||
shape: 'circle',
|
||||
axisName: {
|
||||
formatter: '【{value}】',
|
||||
color: '#428BD4'
|
||||
},
|
||||
splitArea: {
|
||||
areaStyle: {
|
||||
color: ['#77EADF', '#26C3BE', '#64AFE9', '#428BD4'],
|
||||
shadowColor: 'rgba(0, 0, 0, 0.2)',
|
||||
shadowBlur: 10
|
||||
}
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(211, 253, 250, 0.8)'
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(211, 253, 250, 0.8)'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
indicator: [
|
||||
{ text: '1', max: 150 },
|
||||
{ text: '2', max: 150 },
|
||||
{ text: '3', max: 150 },
|
||||
{ text: '4', max: 120 },
|
||||
{ text: '5', max: 108 },
|
||||
{ text: '6', max: 72 }
|
||||
],
|
||||
center: ['75%', '50%'],
|
||||
radius: 120,
|
||||
axisName: {
|
||||
color: '#fff',
|
||||
backgroundColor: '#666',
|
||||
borderRadius: 3,
|
||||
padding: [3, 5]
|
||||
}
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'radar',
|
||||
emphasis: {
|
||||
lineStyle: {
|
||||
width: 4
|
||||
}
|
||||
},
|
||||
data: [
|
||||
{
|
||||
value: [100, 8, 0.4, -80, 2000],
|
||||
name: 'Data A'
|
||||
},
|
||||
{
|
||||
value: [60, 5, 0.3, -100, 1500],
|
||||
name: 'Data B',
|
||||
areaStyle: {
|
||||
color: 'rgba(255, 228, 52, 0.6)'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'radar',
|
||||
radarIndex: 1,
|
||||
data: [
|
||||
{
|
||||
value: [120, 118, 130, 100, 99, 70],
|
||||
name: 'Data C',
|
||||
symbol: 'rect',
|
||||
symbolSize: 12,
|
||||
lineStyle: {
|
||||
type: 'dashed'
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
formatter: function (params) {
|
||||
return params.value;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
value: [100, 93, 50, 90, 70, 60],
|
||||
name: 'Data D',
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.RadialGradient(0.1, 0.6, 1, [
|
||||
{
|
||||
color: 'rgba(255, 145, 124, 0.1)',
|
||||
offset: 0
|
||||
},
|
||||
{
|
||||
color: 'rgba(255, 145, 124, 0.9)',
|
||||
offset: 1
|
||||
}
|
||||
])
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById('app2'));
|
||||
option = {
|
||||
title: {
|
||||
text: '社会感知图'
|
||||
},
|
||||
tooltip: {},
|
||||
animationDurationUpdate: 1500,
|
||||
animationEasingUpdate: 'quinticInOut',
|
||||
series: [
|
||||
{
|
||||
type: 'graph',
|
||||
layout: 'none',
|
||||
symbolSize: 50,
|
||||
roam: true,
|
||||
label: {
|
||||
show: true
|
||||
},
|
||||
edgeSymbol: ['circle', 'arrow'],
|
||||
edgeSymbolSize: [4, 10],
|
||||
edgeLabel: {
|
||||
fontSize: 20
|
||||
},
|
||||
data: [
|
||||
{
|
||||
name: '郭安',
|
||||
x: 300,
|
||||
y: 300
|
||||
},
|
||||
{
|
||||
name: '组员1',
|
||||
x: 800,
|
||||
y: 300
|
||||
},
|
||||
{
|
||||
name: '组员2',
|
||||
x: 550,
|
||||
y: 100
|
||||
},
|
||||
{
|
||||
name: '组员3',
|
||||
x: 550,
|
||||
y: 500
|
||||
}
|
||||
],
|
||||
// links: [],
|
||||
links: [
|
||||
{
|
||||
source: 0,
|
||||
target: 1,
|
||||
symbolSize: [5, 20],
|
||||
label: {
|
||||
show: true
|
||||
},
|
||||
lineStyle: {
|
||||
width: 5,
|
||||
curveness: 0.2
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '组员1',
|
||||
target: '郭安',
|
||||
label: {
|
||||
show: true
|
||||
},
|
||||
lineStyle: {
|
||||
curveness: 0.2
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '组员2',
|
||||
target: '组员3'
|
||||
},
|
||||
{
|
||||
source: '组员2',
|
||||
target: '郭安'
|
||||
},
|
||||
{
|
||||
source: '郭安',
|
||||
target: '组员3'
|
||||
},
|
||||
{
|
||||
source: '组员1',
|
||||
target: '组员3'
|
||||
}
|
||||
],
|
||||
lineStyle: {
|
||||
opacity: 0.9,
|
||||
width: 2,
|
||||
curveness: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
</script>
|
||||
<script>
|
||||
if (window.feather) {
|
||||
window.feather.replace();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,629 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>协作学习投入智能干预平台(学生端)</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
|
||||
|
||||
<!--script start-->
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
|
||||
<script src="/static/js/mind/c_m_m.js"></script>
|
||||
<script>
|
||||
const DefaultView = function () {
|
||||
this.websocket = null
|
||||
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
this.current_page_num = 1
|
||||
this.default_page_size = 15
|
||||
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
|
||||
}
|
||||
|
||||
DefaultView.prototype = {
|
||||
/**界面初始化*/
|
||||
init_view: function () {
|
||||
const uid = $('#uid').html()
|
||||
// 未登录
|
||||
if (!uid || isNaN(uid)) {
|
||||
$('#login_register').show()
|
||||
setTimeout(function () {
|
||||
$('#login_register').click()
|
||||
}, 500)
|
||||
$('#logout_a').hide()
|
||||
$('#newMindModal_btn').hide()
|
||||
} else {
|
||||
$('#login_register').hide()
|
||||
$('#logout_a').show()
|
||||
}
|
||||
|
||||
// 判断页面
|
||||
const page_tag = this.get_page_tag()
|
||||
$('#main h5').html(this.title_map.get(page_tag))
|
||||
},
|
||||
get_uu_id: function () {
|
||||
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
},
|
||||
/**注销登录*/
|
||||
logout_: function () {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "logout",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'xx': 'xx'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
common_alert(data.msg)
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得源页面*/
|
||||
get_page_tag: function () {
|
||||
return $('#src_page').html()
|
||||
},
|
||||
/**获得导图*/
|
||||
fetch_mind: function (current_page, page_size) {
|
||||
const me = this
|
||||
if (!current_page) {
|
||||
current_page = me.current_page_num
|
||||
}
|
||||
if (!page_size) {
|
||||
page_size = me.default_page_size
|
||||
}
|
||||
me.current_page_num = current_page
|
||||
|
||||
// 获得跳转源页面
|
||||
const page_tag = me.get_page_tag()
|
||||
$.ajax({
|
||||
type: `get`,
|
||||
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code !== 0) {
|
||||
return
|
||||
}
|
||||
// clear container-fluid
|
||||
$('main .container-fluid').empty()
|
||||
|
||||
// 解析结果
|
||||
const results = resp.results
|
||||
let idx = 0
|
||||
let row = $(`<div class="row"></row>`)
|
||||
|
||||
results.forEach(function (item) {
|
||||
const uuid = me.get_uu_id()
|
||||
|
||||
// 添加按钮组
|
||||
let sub_btn = '';
|
||||
if (page_tag === 'b9b101e') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
|
||||
} else if (page_tag === 'share') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
|
||||
} else if (page_tag === 'star') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
|
||||
} else if (page_tag === 'recycle') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
|
||||
}
|
||||
|
||||
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
|
||||
<div class="card-body">
|
||||
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
||||
<hr style="margin: 0">
|
||||
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
|
||||
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
row.append(content)
|
||||
})
|
||||
|
||||
// 如果不是3的整数倍,将剩余的添加
|
||||
$('main .container-fluid').append(row)
|
||||
me.init_pagination(resp.count, me.default_page_size)
|
||||
// success end
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**显示分享链接*/
|
||||
show_share_url: function (u, h) {
|
||||
const url = `s_2_d?u=${u}&h=${h}`
|
||||
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
|
||||
$('#share_mind_modal_a').click()
|
||||
},
|
||||
/**分页组件*/
|
||||
init_pagination: function (count, page_size) {
|
||||
const container = $('#pagination_div')
|
||||
/**计算页数*/
|
||||
if (count <= 0) {
|
||||
container.html(`<p class="text-center">无数据</p>`)
|
||||
return
|
||||
}
|
||||
|
||||
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
|
||||
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||
|
||||
if (this.current_page_num > 1) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||
}
|
||||
for (let i = 0; i < all_page; i++) {
|
||||
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||
if (i + 1 === this.current_page_num) {
|
||||
ctt.addClass('active')
|
||||
}
|
||||
navigation_ul.append(ctt)
|
||||
}
|
||||
if (this.current_page_num < all_page) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||
}
|
||||
navigation.append(navigation_ul)
|
||||
container.empty()
|
||||
container.append(navigation)
|
||||
},
|
||||
/**删除导图*/
|
||||
del_mind: function (mind_id, card_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code === 0) {
|
||||
primary_alert(data.msg)
|
||||
// $('#' + card_id).remove()
|
||||
setTimeout(function () {
|
||||
me.fetch_mind()
|
||||
}, 1000)
|
||||
} else {
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**分享脑图*/
|
||||
share_mind: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**取消分享*/
|
||||
share_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
location.reload()
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 删除恢复*/
|
||||
del_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "delete_cancel",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**彻底删除*/
|
||||
del_final: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 取消收藏 */
|
||||
un_star: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得分享信息*/
|
||||
fetch_share_info: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
const data = resp.data
|
||||
me.show_share_url(data.share_uuid, data.share_uuid_hash)
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
is_success_resp(resp) {
|
||||
return resp.code === 0
|
||||
},
|
||||
/** 清除注册时输入内容 */
|
||||
clear_reg_info: function () {
|
||||
$('#userName').val('');
|
||||
$('#inputPassword').val('');
|
||||
$('#inputPassword_').val('');
|
||||
},
|
||||
/**校验密码是否输入一致*/
|
||||
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
||||
if (inputPassword !== inputPassword_) {
|
||||
common_alert('两次密码输入不一样,请确认!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
/** 设置窗口名称 */
|
||||
set_modal_title: function (title) {
|
||||
$('#exampleModal .modal-title').html(title);
|
||||
},
|
||||
|
||||
/************************************************************************************************/
|
||||
/**初始化jquery监听*/
|
||||
jq_listener_init: function () {
|
||||
const me = this
|
||||
/**监听modal窗口事件*/
|
||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
|
||||
ws.onmessage = function (e) {
|
||||
console.log('接收到websocket消息:' + e.data)
|
||||
}
|
||||
me.websocket = ws
|
||||
});
|
||||
$('#exampleModal').on('hidden.bs.modal', function (event) {
|
||||
// console.log('关闭');
|
||||
if (me.websocket) {
|
||||
me.websocket.close()
|
||||
}
|
||||
});
|
||||
|
||||
/**点击 扫码登录 */
|
||||
$('#s_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.qr_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
// 点击注册控件
|
||||
$('#register_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.register_group').show();
|
||||
me.set_modal_title('注册');
|
||||
})
|
||||
|
||||
// 用户名密码登录
|
||||
$('#p_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.pw_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
/** 注册按钮 */
|
||||
$('#register_button').click(function () {
|
||||
const userName = $('#userName').val();
|
||||
const inputPassword = $('#inputPassword').val();
|
||||
const inputPassword_ = $('#inputPassword_').val();
|
||||
|
||||
if (!userName) {
|
||||
common_alert('请输入用户名')
|
||||
return
|
||||
}
|
||||
|
||||
if (!inputPassword) {
|
||||
common_alert('请输入密码')
|
||||
return
|
||||
}
|
||||
|
||||
// 校验输入是否一致
|
||||
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
|
||||
if (validate) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "register",
|
||||
data: {userName: userName, inputPassword: inputPassword},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
me.clear_reg_info()
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
setTimeout(function () {
|
||||
$('#p_login_a').click()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 注册失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
// validate end
|
||||
});
|
||||
|
||||
/**登录按钮*/
|
||||
$('#login_button').click(function () {
|
||||
const userName_login = $('#userName_login').val();
|
||||
const inputPassword_login = $('#inputPassword_login').val();
|
||||
if (!userName_login || !inputPassword_login) {
|
||||
common_alert('请输入用户名和密码')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "login",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {username: userName_login, password: inputPassword_login},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 登录成功
|
||||
if (data.code === 0) {
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
$('#exampleModal').modal('hide')
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 500)
|
||||
} else {
|
||||
// 登录失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
|
||||
/**新建导图*/
|
||||
$('#new_mind_btn').click(function () {
|
||||
const mind_name = $('#mindName').val()
|
||||
if (!mind_name) {
|
||||
common_alert('请输入导图名称')
|
||||
return
|
||||
}
|
||||
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "create",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: post_data,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code === 0) {
|
||||
me.fetch_mind()
|
||||
$('#newMindModal').modal('hide')
|
||||
if ($('#exampleCheck1').prop("checked")) {
|
||||
/**新页面打开*/
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('2_d?id=' + id + `&s_p=b9b101e`)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
/** 新建后打开复选框勾选事件*/
|
||||
$('#exampleCheck1').change(function () {
|
||||
const checked = $(this).prop("checked")
|
||||
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||
})
|
||||
|
||||
/** 创建导图modal 显示完毕后事件*/
|
||||
$('#newMindModal').on('shown.bs.modal', function () {
|
||||
const cookie_checked_ = $.cookie('open_aft_create')
|
||||
$('#mindName').val('')
|
||||
// 从cookie中获得的是字符串
|
||||
if (cookie_checked_ === 'true') {
|
||||
$('#exampleCheck1').attr('checked', 'checked')
|
||||
} else {
|
||||
$('#exampleCheck1').removeAttr('checked');
|
||||
}
|
||||
})
|
||||
/************************************* jq_listener_init end *******************************************/
|
||||
}
|
||||
/** prototype end **/
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
const view = new DefaultView()
|
||||
/**初始化*/
|
||||
view.init_view()
|
||||
view.jq_listener_init()
|
||||
|
||||
/**如果已经登录则查询列表*/
|
||||
view.fetch_mind()
|
||||
window.mind = view
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
<!--script end-->
|
||||
</head>
|
||||
<body>
|
||||
<div style="display: none;">
|
||||
<span id="uid">{{ user.id }}</span>
|
||||
<span id="src_page">{{ page }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 页眉 start-->
|
||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
|
||||
<ul class="navbar-nav px-3">
|
||||
<li class="nav-item text-nowrap">
|
||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- 页眉 end-->
|
||||
|
||||
<!--菜单 和 内容 start-->
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- 左侧菜单 start-->
|
||||
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
|
||||
<div class="sidebar-sticky pt-3">
|
||||
<hr/>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/">
|
||||
<span data-feather="file-text"></span>
|
||||
协作脑图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_share">
|
||||
<span data-feather="share-2"></span>
|
||||
协作分享
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_star">
|
||||
<span data-feather="star"></span>
|
||||
协作收藏
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_echart">
|
||||
<span data-feather="star"></span>
|
||||
学习分析图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/chat_room">
|
||||
<span data-feather="star"></span>
|
||||
聊天室
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/reng_wu">
|
||||
<span data-feather="star"></span>
|
||||
任务详情
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/ke_cheng">
|
||||
<span data-feather="star"></span>
|
||||
课程页面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_recycle">
|
||||
<span data-feather="trash-2"></span>
|
||||
回收站
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- 左侧菜单 end-->
|
||||
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>课程id</th>
|
||||
<th>课程名字</th>
|
||||
<th>老师</th>
|
||||
<th>添加时间</th>
|
||||
<th>课程介绍</th>
|
||||
<th>课程状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>ADG3232</td>
|
||||
<td>计算机操作系统</td>
|
||||
<td>小安</td>
|
||||
<td>2024-02-25 21:13:29</td>
|
||||
<td>这是一门关于计算机操作系统的课程</td>
|
||||
<td>上课</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
<!-- 右侧内容 start-->
|
||||
|
||||
<!-- 右侧内容 end-->
|
||||
</div>
|
||||
</div>
|
||||
<!--导航 和 内容 end-->
|
||||
</body>
|
||||
<script src="/static/js/mind/modal.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,277 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<title>思维导图列表</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" href="/static/layui-v2.6.8/layui/css/layui.css" media="all">
|
||||
<script src="/static/layui-v2.6.8/layui/layui.js"></script>
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script>
|
||||
let layer //弹层
|
||||
, laypage //分页
|
||||
, laydate //日期
|
||||
, table //表格
|
||||
, carousel //轮播
|
||||
, upload //上传
|
||||
, element //元素操作
|
||||
, slider //滑块
|
||||
, dropdown //下拉菜单
|
||||
//加载模块
|
||||
layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
|
||||
//得到各种内置组件
|
||||
layer = layui.layer //弹层
|
||||
, laypage = layui.laypage //分页
|
||||
, laydate = layui.laydate //日期
|
||||
, table = layui.table //表格
|
||||
, carousel = layui.carousel //轮播
|
||||
, upload = layui.upload //上传
|
||||
, element = layui.element //元素操作
|
||||
, slider = layui.slider //滑块
|
||||
, dropdown = layui.dropdown //下拉菜单
|
||||
});
|
||||
|
||||
// 定义function
|
||||
const listView = function (options) {
|
||||
// 当前页
|
||||
this.current_page = 1
|
||||
// 每页条数
|
||||
this.limit = 10
|
||||
// 总条数
|
||||
this.count = 0
|
||||
|
||||
// 参数
|
||||
this.options = options
|
||||
this.opts = {"h": 'oo'}
|
||||
}
|
||||
|
||||
listView.prototype = {
|
||||
init: function () {
|
||||
this.merge_obj(this.opts, this.options)
|
||||
},
|
||||
// 获取数据
|
||||
fetch_data: function () {
|
||||
const me = this
|
||||
const get_param = {'page': this.current_page, 'page_size': this.limit}
|
||||
if (this.get_search_coop_mind_name()) {
|
||||
get_param.coop_mind_name = this.get_search_coop_mind_name()
|
||||
}
|
||||
$.get('list', get_param, function (resp) {
|
||||
if (resp.code !== 0) {
|
||||
layer.msg(resp.msg)
|
||||
return
|
||||
}
|
||||
// 清空数据
|
||||
$('#layui-table tbody').empty()
|
||||
$('#' + me.opts.page_bar_elem).empty()
|
||||
|
||||
const results = resp.results
|
||||
results.forEach(item => {
|
||||
const tr = `<tr>
|
||||
<td>${item.coop_mind_name}</td>
|
||||
<td>${item.creator}</td>
|
||||
<td>${item.create_time}</td>
|
||||
<td>${item.update_time}</td>
|
||||
<td>
|
||||
<i class="layui-icon layui-icon-edit" style="font-size: 15px; color: #1E9FFF;cursor: pointer;" onclick="window.open('detail?id=${item.id}')">编辑</i>
|
||||
<i class="layui-icon layui-icon-share" style="font-size: 15px; color: #1E9FFF;cursor: pointer;margin-left: 10px;" onclick="copy_url(${item.id})">复制分享</i>
|
||||
<i class="layui-icon layui-icon-delete" style="font-size: 15px; color: #1E9FFF;cursor: pointer;margin-left: 10px;" onclick="delmind(${item.id})">删除</i>
|
||||
</td>
|
||||
</tr>`
|
||||
$('#layui-table tbody').append(tr)
|
||||
})
|
||||
|
||||
// 分页组件
|
||||
me.count = resp.count
|
||||
me.auto_page_bar()
|
||||
})
|
||||
},
|
||||
get_search_coop_mind_name: function () {
|
||||
return $('#mind_name').val()
|
||||
},
|
||||
// 显示分页组件
|
||||
auto_page_bar: function () {
|
||||
const me = this
|
||||
//执行一个laypage实例
|
||||
laypage.render({
|
||||
elem: me.opts.page_bar_elem //注意,这里的 test1 是 ID,不用加 # 号
|
||||
, curr: me.current_page
|
||||
, count: me.count //数据总数,从服务端得到
|
||||
, limit: me.limit // 每页显示的条数。
|
||||
, layout: ['count', 'prev', 'page', 'next', 'limit']
|
||||
, jump: function (obj, first) {
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
me.current_page = obj.curr
|
||||
me.limit = obj.limit
|
||||
if (!first) {
|
||||
me.fetch_data()
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 合并属性
|
||||
merge_obj: function (target, src) {
|
||||
for (let o in src) {
|
||||
if (o in target) {
|
||||
if (typeof target[o] === 'object' && Object.prototype.toString.call(target[o]).toLowerCase() === '[object object]' && !target[o].length) {
|
||||
this.merge(target[o], src[o]);
|
||||
} else {
|
||||
target[o] = src[o];
|
||||
}
|
||||
} else {
|
||||
target[o] = src[o];
|
||||
}
|
||||
}
|
||||
return target;
|
||||
},
|
||||
json2string: function (json) {
|
||||
if (!!JSON) {
|
||||
try {
|
||||
return JSON.stringify(json);
|
||||
} catch (e) {
|
||||
logger.warn(e);
|
||||
logger.warn('can not convert to string');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 删除
|
||||
del_mind: function (id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
url: 'delete',
|
||||
type: 'DELETE',
|
||||
data: {'id': id},
|
||||
success: function (result) {
|
||||
layer.closeAll()
|
||||
me.fetch_data()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let view
|
||||
$(function () {
|
||||
// 初始化对象
|
||||
view = new listView({'page_bar_elem': 'page_bar'})
|
||||
view.init()
|
||||
view.fetch_data()
|
||||
|
||||
|
||||
// 搜索
|
||||
$('#search').click(function () {
|
||||
view.fetch_data()
|
||||
})
|
||||
// 清空
|
||||
$('#clear').click(function () {
|
||||
$('#mind_name').val('')
|
||||
view.fetch_data()
|
||||
})
|
||||
// 创建
|
||||
$('#create_mind').click(function () {
|
||||
const content_html = `<div style="margin-left: 30px;margin-top: 20px;">
|
||||
<div class="layui-input-inline">
|
||||
<div class="layui-input-inline">思维导图名称:</div>
|
||||
<div class="layui-input-inline"><input required autocomplete="off" class="layui-input" id="mind_name_crt"></div>
|
||||
</div>
|
||||
<button type="button" class="layui-btn" id="create_inner">创建</button>
|
||||
</div>`
|
||||
layer.open({
|
||||
title: '新建思维导图',
|
||||
skin: 'layui-layer-molv',
|
||||
anim: 5,
|
||||
type: 1,
|
||||
content: content_html, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||
area: ['400px', '200px']
|
||||
});
|
||||
|
||||
// 调用后台创建脑图
|
||||
$('#create_inner').click(create_inner)
|
||||
//
|
||||
})
|
||||
|
||||
// 创建mind
|
||||
function create_inner() {
|
||||
const mind_name = $('#mind_name_crt').val()
|
||||
if (mind_name) {
|
||||
// post start
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "create",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: post_data,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
layer.closeAll()
|
||||
view.fetch_data()
|
||||
layer.msg('创建成功')
|
||||
// 新页面打开
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('detail?id=' + id)
|
||||
}, 500)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
// post end
|
||||
} else {
|
||||
layer.msg('请输入导图名称')
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
})
|
||||
|
||||
function delmind(id) {
|
||||
view.del_mind(id)
|
||||
}
|
||||
|
||||
// 复制链接
|
||||
function copy_url(id) {
|
||||
let href = location.href + `detail?id=${id}`;
|
||||
navigator.clipboard.writeText(href)
|
||||
.then(() => {
|
||||
// Success!
|
||||
layer.msg('复制成功')
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Something went wrong', err);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="margin-top: 5px;">
|
||||
<div class="layui-input-inline">
|
||||
<input autocomplete="off" class="layui-input" id="mind_name">
|
||||
</div>
|
||||
<button type="button" class="layui-btn" id="search">搜索</button>
|
||||
<button type="button" class="layui-btn" id="clear">清空</button>
|
||||
<button type="button" class="layui-btn" id="create_mind">创建导图</button>
|
||||
</div>
|
||||
<table class="layui-table" id="layui-table">
|
||||
<colgroup>
|
||||
<col width="500">
|
||||
<col width="100">
|
||||
<col width="300">
|
||||
<col width="300">
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>创建人</th>
|
||||
<th>创建时间</th>
|
||||
<th>更新时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="page_bar"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,621 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>协作学习投入智能干预平台(学生端)</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
|
||||
|
||||
<!--script start-->
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
|
||||
<script src="/static/js/mind/c_m_m.js"></script>
|
||||
<script>
|
||||
const DefaultView = function () {
|
||||
this.websocket = null
|
||||
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
this.current_page_num = 1
|
||||
this.default_page_size = 15
|
||||
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
|
||||
}
|
||||
|
||||
DefaultView.prototype = {
|
||||
/**界面初始化*/
|
||||
init_view: function () {
|
||||
const uid = $('#uid').html()
|
||||
// 未登录
|
||||
if (!uid || isNaN(uid)) {
|
||||
$('#login_register').show()
|
||||
setTimeout(function () {
|
||||
$('#login_register').click()
|
||||
}, 500)
|
||||
$('#logout_a').hide()
|
||||
$('#newMindModal_btn').hide()
|
||||
} else {
|
||||
$('#login_register').hide()
|
||||
$('#logout_a').show()
|
||||
}
|
||||
|
||||
// 判断页面
|
||||
const page_tag = this.get_page_tag()
|
||||
$('#main h5').html(this.title_map.get(page_tag))
|
||||
},
|
||||
get_uu_id: function () {
|
||||
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
},
|
||||
/**注销登录*/
|
||||
logout_: function () {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "logout",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'xx': 'xx'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
common_alert(data.msg)
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得源页面*/
|
||||
get_page_tag: function () {
|
||||
return $('#src_page').html()
|
||||
},
|
||||
/**获得导图*/
|
||||
fetch_mind: function (current_page, page_size) {
|
||||
const me = this
|
||||
if (!current_page) {
|
||||
current_page = me.current_page_num
|
||||
}
|
||||
if (!page_size) {
|
||||
page_size = me.default_page_size
|
||||
}
|
||||
me.current_page_num = current_page
|
||||
|
||||
// 获得跳转源页面
|
||||
const page_tag = me.get_page_tag()
|
||||
$.ajax({
|
||||
type: `get`,
|
||||
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code !== 0) {
|
||||
return
|
||||
}
|
||||
// clear container-fluid
|
||||
$('main .container-fluid').empty()
|
||||
|
||||
// 解析结果
|
||||
const results = resp.results
|
||||
let idx = 0
|
||||
let row = $(`<div class="row"></row>`)
|
||||
|
||||
results.forEach(function (item) {
|
||||
const uuid = me.get_uu_id()
|
||||
|
||||
// 添加按钮组
|
||||
let sub_btn = '';
|
||||
if (page_tag === 'b9b101e') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
|
||||
} else if (page_tag === 'share') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
|
||||
} else if (page_tag === 'star') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
|
||||
} else if (page_tag === 'recycle') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
|
||||
}
|
||||
|
||||
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
|
||||
<div class="card-body">
|
||||
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
||||
<hr style="margin: 0">
|
||||
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
|
||||
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
row.append(content)
|
||||
})
|
||||
|
||||
// 如果不是3的整数倍,将剩余的添加
|
||||
$('main .container-fluid').append(row)
|
||||
me.init_pagination(resp.count, me.default_page_size)
|
||||
// success end
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**显示分享链接*/
|
||||
show_share_url: function (u, h) {
|
||||
const url = `s_2_d?u=${u}&h=${h}`
|
||||
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
|
||||
$('#share_mind_modal_a').click()
|
||||
},
|
||||
/**分页组件*/
|
||||
init_pagination: function (count, page_size) {
|
||||
const container = $('#pagination_div')
|
||||
/**计算页数*/
|
||||
if (count <= 0) {
|
||||
container.html(`<p class="text-center">无数据</p>`)
|
||||
return
|
||||
}
|
||||
|
||||
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
|
||||
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||
|
||||
if (this.current_page_num > 1) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||
}
|
||||
for (let i = 0; i < all_page; i++) {
|
||||
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||
if (i + 1 === this.current_page_num) {
|
||||
ctt.addClass('active')
|
||||
}
|
||||
navigation_ul.append(ctt)
|
||||
}
|
||||
if (this.current_page_num < all_page) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||
}
|
||||
navigation.append(navigation_ul)
|
||||
container.empty()
|
||||
container.append(navigation)
|
||||
},
|
||||
/**删除导图*/
|
||||
del_mind: function (mind_id, card_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code === 0) {
|
||||
primary_alert(data.msg)
|
||||
// $('#' + card_id).remove()
|
||||
setTimeout(function () {
|
||||
me.fetch_mind()
|
||||
}, 1000)
|
||||
} else {
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**分享脑图*/
|
||||
share_mind: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**取消分享*/
|
||||
share_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
location.reload()
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 删除恢复*/
|
||||
del_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "delete_cancel",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**彻底删除*/
|
||||
del_final: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 取消收藏 */
|
||||
un_star: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得分享信息*/
|
||||
fetch_share_info: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
const data = resp.data
|
||||
me.show_share_url(data.share_uuid, data.share_uuid_hash)
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
is_success_resp(resp) {
|
||||
return resp.code === 0
|
||||
},
|
||||
/** 清除注册时输入内容 */
|
||||
clear_reg_info: function () {
|
||||
$('#userName').val('');
|
||||
$('#inputPassword').val('');
|
||||
$('#inputPassword_').val('');
|
||||
},
|
||||
/**校验密码是否输入一致*/
|
||||
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
||||
if (inputPassword !== inputPassword_) {
|
||||
common_alert('两次密码输入不一样,请确认!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
/** 设置窗口名称 */
|
||||
set_modal_title: function (title) {
|
||||
$('#exampleModal .modal-title').html(title);
|
||||
},
|
||||
|
||||
/************************************************************************************************/
|
||||
/**初始化jquery监听*/
|
||||
jq_listener_init: function () {
|
||||
const me = this
|
||||
/**监听modal窗口事件*/
|
||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
|
||||
ws.onmessage = function (e) {
|
||||
console.log('接收到websocket消息:' + e.data)
|
||||
}
|
||||
me.websocket = ws
|
||||
});
|
||||
$('#exampleModal').on('hidden.bs.modal', function (event) {
|
||||
// console.log('关闭');
|
||||
if (me.websocket) {
|
||||
me.websocket.close()
|
||||
}
|
||||
});
|
||||
|
||||
/**点击 扫码登录 */
|
||||
$('#s_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.qr_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
// 点击注册控件
|
||||
$('#register_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.register_group').show();
|
||||
me.set_modal_title('注册');
|
||||
})
|
||||
|
||||
// 用户名密码登录
|
||||
$('#p_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.pw_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
/** 注册按钮 */
|
||||
$('#register_button').click(function () {
|
||||
const userName = $('#userName').val();
|
||||
const inputPassword = $('#inputPassword').val();
|
||||
const inputPassword_ = $('#inputPassword_').val();
|
||||
|
||||
if (!userName) {
|
||||
common_alert('请输入用户名')
|
||||
return
|
||||
}
|
||||
|
||||
if (!inputPassword) {
|
||||
common_alert('请输入密码')
|
||||
return
|
||||
}
|
||||
|
||||
// 校验输入是否一致
|
||||
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
|
||||
if (validate) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "register",
|
||||
data: {userName: userName, inputPassword: inputPassword},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
me.clear_reg_info()
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
setTimeout(function () {
|
||||
$('#p_login_a').click()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 注册失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
// validate end
|
||||
});
|
||||
|
||||
/**登录按钮*/
|
||||
$('#login_button').click(function () {
|
||||
const userName_login = $('#userName_login').val();
|
||||
const inputPassword_login = $('#inputPassword_login').val();
|
||||
if (!userName_login || !inputPassword_login) {
|
||||
common_alert('请输入用户名和密码')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "login",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {username: userName_login, password: inputPassword_login},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 登录成功
|
||||
if (data.code === 0) {
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
$('#exampleModal').modal('hide')
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 500)
|
||||
} else {
|
||||
// 登录失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
|
||||
/**新建导图*/
|
||||
$('#new_mind_btn').click(function () {
|
||||
const mind_name = $('#mindName').val()
|
||||
if (!mind_name) {
|
||||
common_alert('请输入导图名称')
|
||||
return
|
||||
}
|
||||
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "create",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: post_data,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code === 0) {
|
||||
me.fetch_mind()
|
||||
$('#newMindModal').modal('hide')
|
||||
if ($('#exampleCheck1').prop("checked")) {
|
||||
/**新页面打开*/
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('2_d?id=' + id + `&s_p=b9b101e`)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
/** 新建后打开复选框勾选事件*/
|
||||
$('#exampleCheck1').change(function () {
|
||||
const checked = $(this).prop("checked")
|
||||
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||
})
|
||||
|
||||
/** 创建导图modal 显示完毕后事件*/
|
||||
$('#newMindModal').on('shown.bs.modal', function () {
|
||||
const cookie_checked_ = $.cookie('open_aft_create')
|
||||
$('#mindName').val('')
|
||||
// 从cookie中获得的是字符串
|
||||
if (cookie_checked_ === 'true') {
|
||||
$('#exampleCheck1').attr('checked', 'checked')
|
||||
} else {
|
||||
$('#exampleCheck1').removeAttr('checked');
|
||||
}
|
||||
})
|
||||
/************************************* jq_listener_init end *******************************************/
|
||||
}
|
||||
/** prototype end **/
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
const view = new DefaultView()
|
||||
/**初始化*/
|
||||
view.init_view()
|
||||
view.jq_listener_init()
|
||||
|
||||
/**如果已经登录则查询列表*/
|
||||
view.fetch_mind()
|
||||
window.mind = view
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
<!--script end-->
|
||||
</head>
|
||||
<body>
|
||||
<div style="display: none;">
|
||||
<span id="uid">{{ user.id }}</span>
|
||||
<span id="src_page">{{ page }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 页眉 start-->
|
||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
|
||||
<ul class="navbar-nav px-3">
|
||||
<li class="nav-item text-nowrap">
|
||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- 页眉 end-->
|
||||
|
||||
<!--菜单 和 内容 start-->
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- 左侧菜单 start-->
|
||||
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
|
||||
<div class="sidebar-sticky pt-3">
|
||||
<hr/>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/">
|
||||
<span data-feather="file-text"></span>
|
||||
协作脑图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_share">
|
||||
<span data-feather="share-2"></span>
|
||||
协作分享
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_star">
|
||||
<span data-feather="star"></span>
|
||||
协作收藏
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_echart">
|
||||
<span data-feather="star"></span>
|
||||
学习分析图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/chat_room">
|
||||
<span data-feather="star"></span>
|
||||
聊天室
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/reng_wu">
|
||||
<span data-feather="star"></span>
|
||||
任务详情
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/ke_cheng">
|
||||
<span data-feather="star"></span>
|
||||
课程页面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_recycle">
|
||||
<span data-feather="trash-2"></span>
|
||||
回收站
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- 左侧菜单 end-->
|
||||
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
|
||||
<h1>任务详情</h1>
|
||||
<p>任务核心:对于某话题,有何看法与探讨思路?任务分工如下</p>
|
||||
<hr />
|
||||
<p>A同学负责xxx</p>
|
||||
<hr />
|
||||
<p>B同学负责xxx</p>
|
||||
<hr />
|
||||
<p>C同学负责xxx3</p>
|
||||
</main>
|
||||
<!-- 右侧内容 start-->
|
||||
|
||||
<!-- 右侧内容 end-->
|
||||
</div>
|
||||
</div>
|
||||
<!--导航 和 内容 end-->
|
||||
</body>
|
||||
<script src="/static/js/mind/modal.js"></script>
|
||||
<script src="/static/js/echarts.js"></script>
|
||||
|
||||
<script>
|
||||
if (window.feather) {
|
||||
window.feather.replace();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,804 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>协作学习投入智能干预平台(学生端)</title>
|
||||
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
|
||||
|
||||
<!--script start-->
|
||||
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
|
||||
<script src="/static/js/mind/c_m_m.js"></script>
|
||||
<script>
|
||||
const DefaultView = function () {
|
||||
this.websocket = null
|
||||
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
this.current_page_num = 1
|
||||
this.default_page_size = 15
|
||||
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
|
||||
}
|
||||
|
||||
DefaultView.prototype = {
|
||||
/**界面初始化*/
|
||||
init_view: function () {
|
||||
const uid = $('#uid').html()
|
||||
// 未登录
|
||||
if (!uid || isNaN(uid)) {
|
||||
$('#login_register').show()
|
||||
setTimeout(function () {
|
||||
$('#login_register').click()
|
||||
}, 500)
|
||||
$('#logout_a').hide()
|
||||
$('#newMindModal_btn').hide()
|
||||
} else {
|
||||
$('#login_register').hide()
|
||||
$('#logout_a').show()
|
||||
}
|
||||
|
||||
// 判断页面
|
||||
const page_tag = this.get_page_tag()
|
||||
$('#main h5').html(this.title_map.get(page_tag))
|
||||
},
|
||||
get_uu_id: function () {
|
||||
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||
},
|
||||
/**注销登录*/
|
||||
logout_: function () {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "logout",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'xx': 'xx'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
common_alert(data.msg)
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得源页面*/
|
||||
get_page_tag: function () {
|
||||
return $('#src_page').html()
|
||||
},
|
||||
/**获得导图*/
|
||||
fetch_mind: function (current_page, page_size) {
|
||||
const me = this
|
||||
if (!current_page) {
|
||||
current_page = me.current_page_num
|
||||
}
|
||||
if (!page_size) {
|
||||
page_size = me.default_page_size
|
||||
}
|
||||
me.current_page_num = current_page
|
||||
|
||||
// 获得跳转源页面
|
||||
const page_tag = me.get_page_tag()
|
||||
$.ajax({
|
||||
type: `get`,
|
||||
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code !== 0) {
|
||||
return
|
||||
}
|
||||
// clear container-fluid
|
||||
$('main .container-fluid').empty()
|
||||
|
||||
// 解析结果
|
||||
const results = resp.results
|
||||
let idx = 0
|
||||
let row = $(`<div class="row"></row>`)
|
||||
|
||||
results.forEach(function (item) {
|
||||
const uuid = me.get_uu_id()
|
||||
|
||||
// 添加按钮组
|
||||
let sub_btn = '';
|
||||
if (page_tag === 'b9b101e') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
|
||||
} else if (page_tag === 'share') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
|
||||
} else if (page_tag === 'star') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
|
||||
} else if (page_tag === 'recycle') {
|
||||
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
|
||||
}
|
||||
|
||||
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
|
||||
<div class="card-body">
|
||||
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
|
||||
<hr style="margin: 0">
|
||||
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
|
||||
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
|
||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
row.append(content)
|
||||
})
|
||||
|
||||
// 如果不是3的整数倍,将剩余的添加
|
||||
$('main .container-fluid').append(row)
|
||||
me.init_pagination(resp.count, me.default_page_size)
|
||||
// success end
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**显示分享链接*/
|
||||
show_share_url: function (u, h) {
|
||||
const url = `s_2_d?u=${u}&h=${h}`
|
||||
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
|
||||
$('#share_mind_modal_a').click()
|
||||
},
|
||||
/**分页组件*/
|
||||
init_pagination: function (count, page_size) {
|
||||
const container = $('#pagination_div')
|
||||
/**计算页数*/
|
||||
if (count <= 0) {
|
||||
container.html(`<p class="text-center">无数据</p>`)
|
||||
return
|
||||
}
|
||||
|
||||
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
|
||||
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||
|
||||
if (this.current_page_num > 1) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||
}
|
||||
for (let i = 0; i < all_page; i++) {
|
||||
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||
if (i + 1 === this.current_page_num) {
|
||||
ctt.addClass('active')
|
||||
}
|
||||
navigation_ul.append(ctt)
|
||||
}
|
||||
if (this.current_page_num < all_page) {
|
||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||
}
|
||||
navigation.append(navigation_ul)
|
||||
container.empty()
|
||||
container.append(navigation)
|
||||
},
|
||||
/**删除导图*/
|
||||
del_mind: function (mind_id, card_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code === 0) {
|
||||
primary_alert(data.msg)
|
||||
// $('#' + card_id).remove()
|
||||
setTimeout(function () {
|
||||
me.fetch_mind()
|
||||
}, 1000)
|
||||
} else {
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**分享脑图*/
|
||||
share_mind: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**取消分享*/
|
||||
share_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
location.reload()
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 删除恢复*/
|
||||
del_cancel: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "delete_cancel",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**彻底删除*/
|
||||
del_final: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "delete",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 取消收藏 */
|
||||
un_star: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "delete",
|
||||
url: "star",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
common_alert(resp.msg)
|
||||
if (me.is_success_resp(resp)) {
|
||||
me.fetch_mind()
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**获得分享信息*/
|
||||
fetch_share_info: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'coop_mind_id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (me.is_success_resp(resp)) {
|
||||
const data = resp.data
|
||||
me.show_share_url(data.share_uuid, data.share_uuid_hash)
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
is_success_resp(resp) {
|
||||
return resp.code === 0
|
||||
},
|
||||
/** 清除注册时输入内容 */
|
||||
clear_reg_info: function () {
|
||||
$('#userName').val('');
|
||||
$('#inputPassword').val('');
|
||||
$('#inputPassword_').val('');
|
||||
},
|
||||
/**校验密码是否输入一致*/
|
||||
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
||||
if (inputPassword !== inputPassword_) {
|
||||
common_alert('两次密码输入不一样,请确认!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
/** 设置窗口名称 */
|
||||
set_modal_title: function (title) {
|
||||
$('#exampleModal .modal-title').html(title);
|
||||
},
|
||||
|
||||
/************************************************************************************************/
|
||||
/**初始化jquery监听*/
|
||||
jq_listener_init: function () {
|
||||
const me = this
|
||||
/**监听modal窗口事件*/
|
||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
|
||||
ws.onmessage = function (e) {
|
||||
console.log('接收到websocket消息:' + e.data)
|
||||
}
|
||||
me.websocket = ws
|
||||
});
|
||||
$('#exampleModal').on('hidden.bs.modal', function (event) {
|
||||
// console.log('关闭');
|
||||
if (me.websocket) {
|
||||
me.websocket.close()
|
||||
}
|
||||
});
|
||||
|
||||
/**点击 扫码登录 */
|
||||
$('#s_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.qr_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
// 点击注册控件
|
||||
$('#register_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.register_group').show();
|
||||
me.set_modal_title('注册');
|
||||
})
|
||||
|
||||
// 用户名密码登录
|
||||
$('#p_login_a').click(function () {
|
||||
$('.modal-body').hide();
|
||||
$('.pw_login_group').show();
|
||||
me.set_modal_title('登录');
|
||||
})
|
||||
|
||||
/** 注册按钮 */
|
||||
$('#register_button').click(function () {
|
||||
const userName = $('#userName').val();
|
||||
const inputPassword = $('#inputPassword').val();
|
||||
const inputPassword_ = $('#inputPassword_').val();
|
||||
|
||||
if (!userName) {
|
||||
common_alert('请输入用户名')
|
||||
return
|
||||
}
|
||||
|
||||
if (!inputPassword) {
|
||||
common_alert('请输入密码')
|
||||
return
|
||||
}
|
||||
|
||||
// 校验输入是否一致
|
||||
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
|
||||
if (validate) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "register",
|
||||
data: {userName: userName, inputPassword: inputPassword},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
me.clear_reg_info()
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
setTimeout(function () {
|
||||
$('#p_login_a').click()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 注册失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
// validate end
|
||||
});
|
||||
|
||||
/**登录按钮*/
|
||||
$('#login_button').click(function () {
|
||||
const userName_login = $('#userName_login').val();
|
||||
const inputPassword_login = $('#inputPassword_login').val();
|
||||
if (!userName_login || !inputPassword_login) {
|
||||
common_alert('请输入用户名和密码')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "login",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {username: userName_login, password: inputPassword_login},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
// 登录成功
|
||||
if (data.code === 0) {
|
||||
common_alert(data.msg, 'alert-primary')
|
||||
$('#exampleModal').modal('hide')
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 500)
|
||||
} else {
|
||||
// 登录失败
|
||||
common_alert(data.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
|
||||
/**新建导图*/
|
||||
$('#new_mind_btn').click(function () {
|
||||
const mind_name = $('#mindName').val()
|
||||
if (!mind_name) {
|
||||
common_alert('请输入导图名称')
|
||||
return
|
||||
}
|
||||
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "create",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: post_data,
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.code === 0) {
|
||||
me.fetch_mind()
|
||||
$('#newMindModal').modal('hide')
|
||||
if ($('#exampleCheck1').prop("checked")) {
|
||||
/**新页面打开*/
|
||||
setTimeout(function () {
|
||||
const id = resp.data
|
||||
window.open('2_d?id=' + id + `&s_p=b9b101e`)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
common_alert(resp.msg)
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
})
|
||||
/** 新建后打开复选框勾选事件*/
|
||||
$('#exampleCheck1').change(function () {
|
||||
const checked = $(this).prop("checked")
|
||||
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||
})
|
||||
|
||||
/** 创建导图modal 显示完毕后事件*/
|
||||
$('#newMindModal').on('shown.bs.modal', function () {
|
||||
const cookie_checked_ = $.cookie('open_aft_create')
|
||||
$('#mindName').val('')
|
||||
// 从cookie中获得的是字符串
|
||||
if (cookie_checked_ === 'true') {
|
||||
$('#exampleCheck1').attr('checked', 'checked')
|
||||
} else {
|
||||
$('#exampleCheck1').removeAttr('checked');
|
||||
}
|
||||
})
|
||||
/************************************* jq_listener_init end *******************************************/
|
||||
}
|
||||
/** prototype end **/
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
const view = new DefaultView()
|
||||
/**初始化*/
|
||||
view.init_view()
|
||||
view.jq_listener_init()
|
||||
|
||||
/**如果已经登录则查询列表*/
|
||||
view.fetch_mind()
|
||||
window.mind = view
|
||||
// js end
|
||||
})
|
||||
</script>
|
||||
<!--script end-->
|
||||
</head>
|
||||
<body>
|
||||
<div style="display: none;">
|
||||
<span id="uid">{{ user.id }}</span>
|
||||
<span id="src_page">{{ page }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 页眉 start-->
|
||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
|
||||
<ul class="navbar-nav px-3">
|
||||
<li class="nav-item text-nowrap">
|
||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- 页眉 end-->
|
||||
|
||||
<!--菜单 和 内容 start-->
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- 左侧菜单 start-->
|
||||
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
|
||||
<div class="sidebar-sticky pt-3">
|
||||
<hr/>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/">
|
||||
<span data-feather="file-text"></span>
|
||||
协作脑图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_share">
|
||||
<span data-feather="share-2"></span>
|
||||
协作分享
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_star">
|
||||
<span data-feather="star"></span>
|
||||
协作收藏
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_echart">
|
||||
<span data-feather="star"></span>
|
||||
学习分析图
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/chat_room">
|
||||
<span data-feather="star"></span>
|
||||
聊天室
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/reng_wu">
|
||||
<span data-feather="star"></span>
|
||||
任务详情
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/ke_cheng">
|
||||
<span data-feather="star"></span>
|
||||
课程页面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/2_recycle">
|
||||
<span data-feather="trash-2"></span>
|
||||
回收站
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- 左侧菜单 end-->
|
||||
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
|
||||
<div style="width: 800px;height: 600px;margin: 30px auto;text-align: center">
|
||||
<h1>课程A小组A聊天室</h1>
|
||||
<div style="width: 800px;border: 1px solid gray;height: 300px;">
|
||||
<div style="width: 200px;height: 300px;float: left;text-align: left;">
|
||||
<p><span>当前在线:</span><span id="user_num">0</span></p>
|
||||
<div id="user_list" style="overflow: auto;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="msg_list" style=" width: 598px;border: 1px solid gray; height: 300px;overflow: scroll;float: left;">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<textarea id="msg_box" rows="6" cols="50" onkeydown="confirm(event)"></textarea><br>
|
||||
<input type="button" value="发送" onclick="send()">
|
||||
</div>
|
||||
</main>
|
||||
<!-- 右侧内容 start-->
|
||||
|
||||
<!-- 右侧内容 end-->
|
||||
</div>
|
||||
</div>
|
||||
<!--导航 和 内容 end-->
|
||||
</body>
|
||||
<script src="/static/js/mind/modal.js"></script>
|
||||
<script src="/static/js/echarts.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 存储用户名到全局变量,握手成功后发送给服务器
|
||||
var uname = "guoan";
|
||||
var ws = new WebSocket("ws://127.0.0.1:4321");
|
||||
ws.onopen = function() {
|
||||
var data = "系统消息:建立连接成功";
|
||||
listMsg(data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 分析服务器返回信息
|
||||
*
|
||||
* msg.type : user 普通信息;system 系统信息;handshake 握手信息;login 登陆信息; logout 退出信息;
|
||||
* msg.from : 消息来源
|
||||
* msg.content: 消息内容
|
||||
*/
|
||||
ws.onmessage = function(e) {
|
||||
var msg = JSON.parse(e.data);
|
||||
var sender, user_name, name_list, change_type;
|
||||
|
||||
switch (msg.type) {
|
||||
case 'system':
|
||||
sender = '系统消息: ';
|
||||
break;
|
||||
case 'user':
|
||||
sender = msg.from + ': ';
|
||||
break;
|
||||
case 'handshake':
|
||||
var user_info = {
|
||||
'type': 'login',
|
||||
'content': uname
|
||||
};
|
||||
sendMsg(user_info);
|
||||
return;
|
||||
case 'login':
|
||||
case 'logout':
|
||||
user_name = msg.content;
|
||||
name_list = msg.user_list;
|
||||
change_type = msg.type;
|
||||
dealUser(user_name, change_type, name_list);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = sender + msg.content;
|
||||
listMsg(data);
|
||||
};
|
||||
|
||||
ws.onerror = function() {
|
||||
var data = "系统消息 : 出错了,请退出重试.";
|
||||
listMsg(data);
|
||||
};
|
||||
|
||||
//窗口关闭时,发信息给服务器,说明下线了
|
||||
window.onbeforeunload = function() {
|
||||
var user_info = {
|
||||
'type': 'logout',
|
||||
'content': uname
|
||||
};
|
||||
sendMsg(user_info);
|
||||
ws.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在输入框内按下回车键时发送消息
|
||||
*
|
||||
* @param event
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function confirm(event) {
|
||||
var key_num = event.keyCode;
|
||||
if (13 == key_num) {
|
||||
send();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送并清空消息输入框内的消息
|
||||
*/
|
||||
function send() {
|
||||
var msg_box = document.getElementById("msg_box");
|
||||
var content = msg_box.value;
|
||||
var reg = new RegExp("\r\n", "g");
|
||||
content = content.replace(reg, "");
|
||||
var msg = {
|
||||
'content': content.trim(),
|
||||
'type': 'send'
|
||||
};
|
||||
sendMsg(msg);
|
||||
msg_box.value = '';
|
||||
// todo 清除换行符
|
||||
}
|
||||
|
||||
/**
|
||||
* 将消息内容添加到输出框中,并将滚动条滚动到最下方
|
||||
*/
|
||||
function listMsg(data) {
|
||||
var msg_list = document.getElementById("msg_list");
|
||||
var msg = document.createElement("p");
|
||||
|
||||
msg.innerHTML = data;
|
||||
msg_list.appendChild(msg);
|
||||
msg_list.scrollTop = msg_list.scrollHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户登陆消息
|
||||
*
|
||||
* @param user_name 用户名
|
||||
* @param type login/logout
|
||||
* @param name_list 用户列表
|
||||
*/
|
||||
function dealUser(user_name, type, name_list) {
|
||||
var user_list = document.getElementById("user_list");
|
||||
var user_num = document.getElementById("user_num");
|
||||
while (user_list.hasChildNodes()) {
|
||||
user_list.removeChild(user_list.firstChild);
|
||||
}
|
||||
|
||||
for (var index in name_list) {
|
||||
var user = document.createElement("p");
|
||||
user.innerHTML = name_list[index];
|
||||
user_list.appendChild(user);
|
||||
}
|
||||
user_num.innerHTML = name_list.length;
|
||||
user_list.scrollTop = user_list.scrollHeight;
|
||||
|
||||
var change = type == 'login' ? '上线' : '下线';
|
||||
|
||||
var data = '系统消息: ' + user_name + ' 已' + change;
|
||||
listMsg(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数据转为json并发送
|
||||
* @param msg
|
||||
*/
|
||||
function sendMsg(msg) {
|
||||
var data = JSON.stringify(msg);
|
||||
ws.send(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产一个全局唯一ID作为用户名的默认值;
|
||||
*
|
||||
* @param len
|
||||
* @param radix
|
||||
* @returns {string}
|
||||
*/
|
||||
function uuid(len, radix) {
|
||||
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
||||
var uuid = [],
|
||||
i;
|
||||
radix = radix || chars.length;
|
||||
|
||||
if (len) {
|
||||
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
|
||||
} else {
|
||||
var r;
|
||||
|
||||
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
||||
uuid[14] = '4';
|
||||
|
||||
for (i = 0; i < 36; i++) {
|
||||
if (!uuid[i]) {
|
||||
r = 0 | Math.random() * 16;
|
||||
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uuid.join('');
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
if (window.feather) {
|
||||
window.feather.replace();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,212 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<style>
|
||||
p {
|
||||
text-align: left;
|
||||
padding-left: 20px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="width: 800px;height: 600px;margin: 30px auto;text-align: center">
|
||||
<h1>websocket聊天室</h1>
|
||||
<div style="width: 800px;border: 1px solid gray;height: 300px;">
|
||||
<div style="width: 200px;height: 300px;float: left;text-align: left;">
|
||||
<p><span>当前在线:</span><span id="user_num">0</span></p>
|
||||
<div id="user_list" style="overflow: auto;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="msg_list" style=" width: 598px;border: 1px solid gray; height: 300px;overflow: scroll;float: left;">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<textarea id="msg_box" rows="6" cols="50" onkeydown="confirm(event)"></textarea><br>
|
||||
<input type="button" value="发送" onclick="send()">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<script type="text/javascript">
|
||||
// 存储用户名到全局变量,握手成功后发送给服务器
|
||||
var uname = prompt('请输入用户名', 'user' + uuid(8, 16));
|
||||
var ws = new WebSocket("ws://127.0.0.1:4321");
|
||||
ws.onopen = function() {
|
||||
var data = "系统消息:建立连接成功";
|
||||
listMsg(data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 分析服务器返回信息
|
||||
*
|
||||
* msg.type : user 普通信息;system 系统信息;handshake 握手信息;login 登陆信息; logout 退出信息;
|
||||
* msg.from : 消息来源
|
||||
* msg.content: 消息内容
|
||||
*/
|
||||
ws.onmessage = function(e) {
|
||||
var msg = JSON.parse(e.data);
|
||||
var sender, user_name, name_list, change_type;
|
||||
|
||||
switch (msg.type) {
|
||||
case 'system':
|
||||
sender = '系统消息: ';
|
||||
break;
|
||||
case 'user':
|
||||
sender = msg.from + ': ';
|
||||
break;
|
||||
case 'handshake':
|
||||
var user_info = {
|
||||
'type': 'login',
|
||||
'content': uname
|
||||
};
|
||||
sendMsg(user_info);
|
||||
return;
|
||||
case 'login':
|
||||
case 'logout':
|
||||
user_name = msg.content;
|
||||
name_list = msg.user_list;
|
||||
change_type = msg.type;
|
||||
dealUser(user_name, change_type, name_list);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = sender + msg.content;
|
||||
listMsg(data);
|
||||
};
|
||||
|
||||
ws.onerror = function() {
|
||||
var data = "系统消息 : 出错了,请退出重试.";
|
||||
listMsg(data);
|
||||
};
|
||||
|
||||
//窗口关闭时,发信息给服务器,说明下线了
|
||||
window.onbeforeunload = function() {
|
||||
var user_info = {
|
||||
'type': 'logout',
|
||||
'content': uname
|
||||
};
|
||||
sendMsg(user_info);
|
||||
ws.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在输入框内按下回车键时发送消息
|
||||
*
|
||||
* @param event
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function confirm(event) {
|
||||
var key_num = event.keyCode;
|
||||
if (13 == key_num) {
|
||||
send();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送并清空消息输入框内的消息
|
||||
*/
|
||||
function send() {
|
||||
var msg_box = document.getElementById("msg_box");
|
||||
var content = msg_box.value;
|
||||
var reg = new RegExp("\r\n", "g");
|
||||
content = content.replace(reg, "");
|
||||
var msg = {
|
||||
'content': content.trim(),
|
||||
'type': 'send'
|
||||
};
|
||||
sendMsg(msg);
|
||||
msg_box.value = '';
|
||||
// todo 清除换行符
|
||||
}
|
||||
|
||||
/**
|
||||
* 将消息内容添加到输出框中,并将滚动条滚动到最下方
|
||||
*/
|
||||
function listMsg(data) {
|
||||
var msg_list = document.getElementById("msg_list");
|
||||
var msg = document.createElement("p");
|
||||
|
||||
msg.innerHTML = data;
|
||||
msg_list.appendChild(msg);
|
||||
msg_list.scrollTop = msg_list.scrollHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户登陆消息
|
||||
*
|
||||
* @param user_name 用户名
|
||||
* @param type login/logout
|
||||
* @param name_list 用户列表
|
||||
*/
|
||||
function dealUser(user_name, type, name_list) {
|
||||
var user_list = document.getElementById("user_list");
|
||||
var user_num = document.getElementById("user_num");
|
||||
while (user_list.hasChildNodes()) {
|
||||
user_list.removeChild(user_list.firstChild);
|
||||
}
|
||||
|
||||
for (var index in name_list) {
|
||||
var user = document.createElement("p");
|
||||
user.innerHTML = name_list[index];
|
||||
user_list.appendChild(user);
|
||||
}
|
||||
user_num.innerHTML = name_list.length;
|
||||
user_list.scrollTop = user_list.scrollHeight;
|
||||
|
||||
var change = type == 'login' ? '上线' : '下线';
|
||||
|
||||
var data = '系统消息: ' + user_name + ' 已' + change;
|
||||
listMsg(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数据转为json并发送
|
||||
* @param msg
|
||||
*/
|
||||
function sendMsg(msg) {
|
||||
var data = JSON.stringify(msg);
|
||||
ws.send(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产一个全局唯一ID作为用户名的默认值;
|
||||
*
|
||||
* @param len
|
||||
* @param radix
|
||||
* @returns {string}
|
||||
*/
|
||||
function uuid(len, radix) {
|
||||
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
||||
var uuid = [],
|
||||
i;
|
||||
radix = radix || chars.length;
|
||||
|
||||
if (len) {
|
||||
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
|
||||
} else {
|
||||
var r;
|
||||
|
||||
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
||||
uuid[14] = '4';
|
||||
|
||||
for (i = 0; i < 36; i++) {
|
||||
if (!uuid[i]) {
|
||||
r = 0 | Math.random() * 16;
|
||||
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uuid.join('');
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
// In somehow. If we export like
|
||||
// export * as LineChart './chart/line/install'
|
||||
// The exported code will be transformed to
|
||||
// import * as LineChart_1 './chart/line/install'; export {LineChart_1 as LineChart};
|
||||
// Treeshaking in webpack will not work even if we configured sideEffects to false in package.json
|
||||
|
||||
export * from './lib/export/charts.js';
|
||||
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Released under BSD License
|
||||
* Copyright (c) cy20081118148@163.com
|
||||
*
|
||||
*/
|
||||
(function ($w, temp) {
|
||||
const Jm = $w[temp]
|
||||
if (!Jm) return
|
||||
|
||||
function jsMindCallBackFacade(type, body) {
|
||||
const coop = $w.coop
|
||||
if (coop) {
|
||||
coop.js_mind_callback_(type, body)
|
||||
} else {
|
||||
console.error('coop is undefined')
|
||||
}
|
||||
}
|
||||
|
||||
Jm.coop = function (_jm) {
|
||||
this._init(_jm)
|
||||
}
|
||||
Jm.coop.prototype = {
|
||||
// jsMind 对象
|
||||
_jm: null,
|
||||
// 后台api 接口地址
|
||||
coop_api_url: null,
|
||||
// websocket 地址
|
||||
coop_ws_url: null,
|
||||
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_uuid区分)
|
||||
client_uuid: null,
|
||||
// 当前脑图ID
|
||||
coop_mind_id: null,
|
||||
// 上一次操作日志ID
|
||||
coop_mind_log_last_id: 0,
|
||||
// 默认操作日志IDh
|
||||
coop_mind_log_id: 0,
|
||||
// 定时备份数据
|
||||
timer_push_task: null,
|
||||
// web_socket
|
||||
web_socket: null,
|
||||
// init
|
||||
_init: function (_jm) {
|
||||
if (!this._jm) {
|
||||
this._jm = _jm
|
||||
|
||||
// 添加事件处理
|
||||
_jm.add_event_listener(jsMindCallBackFacade)
|
||||
|
||||
// 初始化属性
|
||||
this._init_properties(_jm)
|
||||
|
||||
// 初始化websocket
|
||||
this._init_ws()
|
||||
|
||||
// 获取一次日志
|
||||
this.fetch_log()
|
||||
|
||||
// 定时提交
|
||||
this.timerPush()
|
||||
}
|
||||
},
|
||||
_init_properties: function (_jm) {
|
||||
// 设置属性
|
||||
this.client_uuid = Jm.util.uuid.newid()
|
||||
this.coop_api_url = _jm.options.coop_api_url
|
||||
this.coop_ws_url = _jm.options.coop_ws_url
|
||||
this.coop_mind_id = _jm.options.coop_mind_id
|
||||
this.coop_mind_log_id = _jm.options.coop_mind_log_id
|
||||
this.coop_mind_log_last_id = _jm.options.coop_mind_log_id
|
||||
},
|
||||
// 初始化websocket
|
||||
_init_ws: function () {
|
||||
const me = this
|
||||
if (!this.web_socket && this.coop_mind_id) {
|
||||
const ws = new WebSocket(this.coop_ws_url + '?_' + this.coop_mind_id)
|
||||
this.web_socket = ws
|
||||
//申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
|
||||
ws.onopen = function () {
|
||||
//当WebSocket创建成功时,触发onopen事件
|
||||
ws.send(`{"h":"w"}`); //将消息发送到服务端
|
||||
}
|
||||
ws.onmessage = function (e) {
|
||||
//当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
|
||||
me._handle_jsmind_with_ws_message(e.data)
|
||||
}
|
||||
ws.onclose = function (e) {
|
||||
//当客户端收到服务端发送的关闭连接请求时,触发onclose事件
|
||||
this.web_socket = null
|
||||
}
|
||||
ws.onerror = function (e) {
|
||||
//如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
|
||||
console.log('error');
|
||||
this.web_socket = null
|
||||
}
|
||||
} else {
|
||||
console.error('_init_ws failed,this.coop_mind_id is' + this.coop_mind_id)
|
||||
}
|
||||
},
|
||||
// 获得一次日志
|
||||
fetch_log: function () {
|
||||
const me = this
|
||||
Jm.util.ajax.get(`${this.coop_api_url}?coop_mind_id=${this.coop_mind_id}&cooperation_mind_log_id=${this.coop_mind_log_id}`, function (resp) {
|
||||
//
|
||||
const resp_data_array = resp.data
|
||||
resp_data_array.forEach(item => {
|
||||
me._handle_msg_inner(item, true)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 清理定时任务
|
||||
clear_timer: function () {
|
||||
if (this.timer_push_task) {
|
||||
$w.clearInterval(this.timer_push_task)
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 是否为空
|
||||
* @param obj
|
||||
*/
|
||||
_not_null: function (obj) {
|
||||
return obj !== null && obj !== undefined
|
||||
},
|
||||
_is_null: function (obj) {
|
||||
return !this._not_null(obj)
|
||||
},
|
||||
/**
|
||||
* 构建公共参数
|
||||
*/
|
||||
_build_evt_param: function () {
|
||||
return {'client_uuid': this.client_uuid, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
|
||||
},
|
||||
// 调用jsmind接口
|
||||
_handle_jsmind_with_ws_message: function (message) {
|
||||
const msg_json = JSON.parse(message)
|
||||
this._handle_msg_inner(msg_json, false)
|
||||
},
|
||||
// 处理消息广告方法
|
||||
_handle_msg_inner(msg_json, is_batch) {
|
||||
|
||||
// 校验 client_uuid
|
||||
const client_uuid = msg_json.client_uuid
|
||||
if (!client_uuid) {
|
||||
return
|
||||
}
|
||||
const log_content = JSON.parse(msg_json.log_content)
|
||||
const log_id = msg_json.id
|
||||
if (log_id > this.coop_mind_log_id) {
|
||||
// 第一次批量获得日志和被动接收日志,设置coop_mind_log_last_id和coop_mind_log_id 相同,不进行批量保存快照
|
||||
if (is_batch || client_uuid !== this.client_uuid) {
|
||||
this.coop_mind_log_last_id = log_id
|
||||
} else {
|
||||
// 设置 coop_mind_log_last_id 便于批量保存快照
|
||||
this.coop_mind_log_last_id = this.coop_mind_log_id
|
||||
}
|
||||
this.coop_mind_log_id = log_id
|
||||
}
|
||||
|
||||
// 回放
|
||||
if (client_uuid === this.client_uuid) {
|
||||
console.log('self msg')
|
||||
} else {
|
||||
const evt = log_content.evt
|
||||
const data_array = log_content.data
|
||||
// console.log(msg_json)
|
||||
if ('add_node' === evt) {
|
||||
this._jm.add_node(data_array[0], data_array[1], data_array[2], null, true)
|
||||
} else if ('insert_node_before' === evt) {
|
||||
this._jm.insert_node_before(data_array[0], data_array[1], data_array[2], null, true)
|
||||
} else if ('insert_node_after' === evt) {
|
||||
this._jm.insert_node_after(data_array[0], data_array[1], data_array[2], null, true)
|
||||
} else if ('remove_node' === evt) {
|
||||
this._jm.remove_node(data_array[0], true)
|
||||
} else if ('update_node' === evt) {
|
||||
this._jm.update_node(data_array[0], data_array[1], true)
|
||||
} else if ('move_node' === evt) {
|
||||
this._jm.move_node(data_array[0], data_array[1], data_array[2], data_array[3], true)
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* body:
|
||||
* # {evt:'add_node',data:[parent_node.id,nodeid,topic,data],node:nodeid}
|
||||
* # {evt:'insert_node_before',data:[beforeid,nodeid,topic,data],node:nodeid}
|
||||
* # {evt:'insert_node_after',data:[afterid,nodeid,topic,data],node:nodeid}
|
||||
* # {evt:'remove_node',data:[nodeid],node:parentid}
|
||||
* # {evt:'update_node',data:[nodeid,topic],node:nodeid}
|
||||
* # {evt:'move_node',data:[nodeid,beforeid,parentid,direction],node:nodeid}
|
||||
* @param type
|
||||
* @param body
|
||||
* @private
|
||||
*/
|
||||
js_mind_callback_: function (type, body) {
|
||||
const evt = body.evt
|
||||
if (this.should_handle_evt(evt)) {
|
||||
const param = this._build_evt_param()
|
||||
Jm.util.json.merge(body, param)
|
||||
|
||||
// 序列化数据,处理特殊字符
|
||||
let msg = Jm.util.json.json2string(body)
|
||||
msg = this.handle_spec_str(msg)
|
||||
this._send_ws_message(msg)
|
||||
}
|
||||
},
|
||||
should_handle_evt: function (evt) {
|
||||
return evt && ['add_node', 'insert_node_before', 'insert_node_after', 'remove_node', 'update_node', 'move_node'].includes(evt)
|
||||
},
|
||||
// 处理特殊字符
|
||||
handle_spec_str: function (msg) {
|
||||
if (!!msg) {
|
||||
return msg.replaceAll('\\n', '<br/>')
|
||||
}
|
||||
return msg
|
||||
},
|
||||
// 发送ws消息
|
||||
_send_ws_message: function (msg) {
|
||||
if (this.web_socket != null) {
|
||||
this.web_socket.send(msg)
|
||||
} else {
|
||||
console.error('web_socket is not ready!')
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 每隔n秒钟同步一次数据到db
|
||||
*/
|
||||
timerPush: function () {
|
||||
// 把操作日志最大的data 持久化到数据库
|
||||
const me = this
|
||||
if (this._is_null(me.timer_push_task)) {
|
||||
me.timer_push_task = setInterval(function () {
|
||||
const param = {
|
||||
'data': Jm.util.json.json2string(me._jm.get_data('node_tree').data),
|
||||
'client_uuid': me.client_uuid,
|
||||
'coop_mind_id': me.coop_mind_id,
|
||||
'coop_mind_log_id': me.coop_mind_log_id,
|
||||
'type': 'snapshot',
|
||||
'data_format': 'node_tree'
|
||||
}
|
||||
// 保存快照,保存完毕后设置 coop_mind_log_last_id 和 coop_mind_log_id
|
||||
if (me.coop_mind_log_id > me.coop_mind_log_last_id) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: me.coop_api_url,
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: param,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
me.coop_mind_log_last_id = me.coop_mind_log_id
|
||||
},
|
||||
async: false
|
||||
});
|
||||
}
|
||||
}, 10000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var plugin = new Jm.plugin('coop', function (_jm) {
|
||||
// _jm 已经实例化好的jm对象
|
||||
$w.coop = new Jm.coop(_jm)
|
||||
// coop 对象 与 _jm 对象互相设置关联关系
|
||||
coop.jm = _jm
|
||||
_jm.coop = coop
|
||||
})
|
||||
Jm.register_plugin(plugin)
|
||||
|
||||
})(window, 'jsMind')
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Released under BSD License
|
||||
* Copyright (c) 2014-2021 hizzgdev@163.com
|
||||
*
|
||||
* Project Home:
|
||||
* https://github.com/hizzgdev/jsmind/
|
||||
*/
|
||||
|
||||
/* important section */
|
||||
.jsmind-inner{position:relative;overflow:auto;width:100%;height:100%;outline:none;}/*box-shadow:0 0 2px #000;*/
|
||||
.jsmind-inner{
|
||||
moz-user-select:-moz-none;
|
||||
-moz-user-select:none;
|
||||
-o-user-select:none;
|
||||
-khtml-user-select:none;
|
||||
-webkit-user-select:none;
|
||||
-ms-user-select:none;
|
||||
user-select:none;
|
||||
}
|
||||
|
||||
/* z-index:1 */
|
||||
svg.jsmind{position:absolute;z-index:1;}
|
||||
canvas.jsmind{position:absolute;z-index:1;}
|
||||
|
||||
/* z-index:2 */
|
||||
jmnodes{position:absolute;z-index:2;background-color:rgba(0,0,0,0);}/*background color is necessary*/
|
||||
jmnode{position:absolute;cursor:default;max-width:400px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
jmexpander{position:absolute;width:11px;height:11px;display:block;overflow:hidden;line-height:12px;font-size:12px;text-align:center;border-radius:6px;border-width:1px;border-style:solid;cursor:pointer;}
|
||||
|
||||
/* default theme */
|
||||
jmnode{padding:10px;background-color:#fff;color:#333;border-radius:5px;box-shadow:1px 1px 1px #666;font:16px/1.125 Verdana,Arial,Helvetica,sans-serif;}
|
||||
jmnode:hover{box-shadow:2px 2px 8px #000;background-color:#ebebeb;color:#333;}
|
||||
jmnode.selected{background-color:#11f;color:#fff;box-shadow:2px 2px 8px #000;}
|
||||
jmnode.root{font-size:24px;}
|
||||
jmexpander{border-color:gray;}
|
||||
jmexpander:hover{border-color:#000;}
|
||||
|
||||
@media screen and (max-device-width: 1024px) {
|
||||
jmnode{padding:5px;border-radius:3px;font-size:14px;}
|
||||
jmnode.root{font-size:21px;}
|
||||
}
|
||||
/* primary theme */
|
||||
jmnodes.theme-primary jmnode{background-color:#428bca;color:#fff;border-color:#357ebd;}
|
||||
jmnodes.theme-primary jmnode:hover{background-color:#3276b1;border-color:#285e8e;}
|
||||
jmnodes.theme-primary jmnode.selected{background-color:#f1c40f;color:#fff;}
|
||||
jmnodes.theme-primary jmnode.root{}
|
||||
jmnodes.theme-primary jmexpander{}
|
||||
jmnodes.theme-primary jmexpander:hover{}
|
||||
|
||||
/* warning theme */
|
||||
jmnodes.theme-warning jmnode{background-color:#f0ad4e;border-color:#eea236;color:#fff;}
|
||||
jmnodes.theme-warning jmnode:hover{background-color:#ed9c28;border-color:#d58512;}
|
||||
jmnodes.theme-warning jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-warning jmnode.root{}
|
||||
jmnodes.theme-warning jmexpander{}
|
||||
jmnodes.theme-warning jmexpander:hover{}
|
||||
|
||||
/* danger theme */
|
||||
jmnodes.theme-danger jmnode{background-color:#d9534f;border-color:#d43f3a;color:#fff;}
|
||||
jmnodes.theme-danger jmnode:hover{background-color:#d2322d;border-color:#ac2925;}
|
||||
jmnodes.theme-danger jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-danger jmnode.root{}
|
||||
jmnodes.theme-danger jmexpander{}
|
||||
jmnodes.theme-danger jmexpander:hover{}
|
||||
|
||||
/* success theme */
|
||||
jmnodes.theme-success jmnode{background-color:#5cb85c;border-color:#4cae4c;color:#fff;}
|
||||
jmnodes.theme-success jmnode:hover{background-color:#47a447;border-color:#398439;}
|
||||
jmnodes.theme-success jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-success jmnode.root{}
|
||||
jmnodes.theme-success jmexpander{}
|
||||
jmnodes.theme-success jmexpander:hover{}
|
||||
|
||||
/* info theme */
|
||||
jmnodes.theme-info jmnode{background-color:#5dc0de;border-color:#46b8da;;color:#fff;}
|
||||
jmnodes.theme-info jmnode:hover{background-color:#39b3d7;border-color:#269abc;}
|
||||
jmnodes.theme-info jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-info jmnode.root{}
|
||||
jmnodes.theme-info jmexpander{}
|
||||
jmnodes.theme-info jmexpander:hover{}
|
||||
|
||||
/* greensea theme */
|
||||
jmnodes.theme-greensea jmnode{background-color:#1abc9c;color:#fff;}
|
||||
jmnodes.theme-greensea jmnode:hover{background-color:#16a085;}
|
||||
jmnodes.theme-greensea jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-greensea jmnode.root{}
|
||||
jmnodes.theme-greensea jmexpander{}
|
||||
jmnodes.theme-greensea jmexpander:hover{}
|
||||
|
||||
/* nephrite theme */
|
||||
jmnodes.theme-nephrite jmnode{background-color:#2ecc71;color:#fff;}
|
||||
jmnodes.theme-nephrite jmnode:hover{background-color:#27ae60;}
|
||||
jmnodes.theme-nephrite jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-nephrite jmnode.root{}
|
||||
jmnodes.theme-nephrite jmexpander{}
|
||||
jmnodes.theme-nephrite jmexpander:hover{}
|
||||
|
||||
/* belizehole theme */
|
||||
jmnodes.theme-belizehole jmnode{background-color:#3498db;color:#fff;}
|
||||
jmnodes.theme-belizehole jmnode:hover{background-color:#2980b9;}
|
||||
jmnodes.theme-belizehole jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-belizehole jmnode.root{}
|
||||
jmnodes.theme-belizehole jmexpander{}
|
||||
jmnodes.theme-belizehole jmexpander:hover{}
|
||||
|
||||
/* wisteria theme */
|
||||
jmnodes.theme-wisteria jmnode{background-color:#9b59b6;color:#fff;}
|
||||
jmnodes.theme-wisteria jmnode:hover{background-color:#8e44ad;}
|
||||
jmnodes.theme-wisteria jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-wisteria jmnode.root{}
|
||||
jmnodes.theme-wisteria jmexpander{}
|
||||
jmnodes.theme-wisteria jmexpander:hover{}
|
||||
|
||||
/* asphalt theme */
|
||||
jmnodes.theme-asphalt jmnode{background-color:#34495e;color:#fff;}
|
||||
jmnodes.theme-asphalt jmnode:hover{background-color:#2c3e50;}
|
||||
jmnodes.theme-asphalt jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-asphalt jmnode.root{}
|
||||
jmnodes.theme-asphalt jmexpander{}
|
||||
jmnodes.theme-asphalt jmexpander:hover{}
|
||||
|
||||
/* orange theme */
|
||||
jmnodes.theme-orange jmnode{background-color:#f1c40f;color:#fff;}
|
||||
jmnodes.theme-orange jmnode:hover{background-color:#f39c12;}
|
||||
jmnodes.theme-orange jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-orange jmnode.root{}
|
||||
jmnodes.theme-orange jmexpander{}
|
||||
jmnodes.theme-orange jmexpander:hover{}
|
||||
|
||||
/* pumpkin theme */
|
||||
jmnodes.theme-pumpkin jmnode{background-color:#e67e22;color:#fff;}
|
||||
jmnodes.theme-pumpkin jmnode:hover{background-color:#d35400;}
|
||||
jmnodes.theme-pumpkin jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-pumpkin jmnode.root{}
|
||||
jmnodes.theme-pumpkin jmexpander{}
|
||||
jmnodes.theme-pumpkin jmexpander:hover{}
|
||||
|
||||
/* pomegranate theme */
|
||||
jmnodes.theme-pomegranate jmnode{background-color:#e74c3c;color:#fff;}
|
||||
jmnodes.theme-pomegranate jmnode:hover{background-color:#c0392b;}
|
||||
jmnodes.theme-pomegranate jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-pomegranate jmnode.root{}
|
||||
jmnodes.theme-pomegranate jmexpander{}
|
||||
jmnodes.theme-pomegranate jmexpander:hover{}
|
||||
|
||||
/* clouds theme */
|
||||
jmnodes.theme-clouds jmnode{background-color:#ecf0f1;color:#333;}
|
||||
jmnodes.theme-clouds jmnode:hover{background-color:#bdc3c7;}
|
||||
jmnodes.theme-clouds jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-clouds jmnode.root{}
|
||||
jmnodes.theme-clouds jmexpander{}
|
||||
jmnodes.theme-clouds jmexpander:hover{}
|
||||
|
||||
/* asbestos theme */
|
||||
jmnodes.theme-asbestos jmnode{background-color:#95a5a6;color:#fff;}
|
||||
jmnodes.theme-asbestos jmnode:hover{background-color:#7f8c8d;}
|
||||
jmnodes.theme-asbestos jmnode.selected{background-color:#11f;color:#fff;}
|
||||
jmnodes.theme-asbestos jmnode.root{}
|
||||
jmnodes.theme-asbestos jmexpander{}
|
||||
jmnodes.theme-asbestos jmexpander:hover{}
|
||||
@@ -0,0 +1,353 @@
|
||||
/*
|
||||
* Released under BSD License
|
||||
* Copyright (c) 2014-2021 hizzgdev@163.com
|
||||
*
|
||||
* Project Home:
|
||||
* https://github.com/hizzgdev/jsmind/
|
||||
*/
|
||||
|
||||
(function ($w) {
|
||||
'use strict';
|
||||
var $d = $w.document;
|
||||
var __name__ = 'jsMind';
|
||||
var jsMind = $w[__name__];
|
||||
if (!jsMind) { return; }
|
||||
if (typeof jsMind.draggable != 'undefined') { return; }
|
||||
|
||||
var jdom = jsMind.util.dom;
|
||||
var clear_selection = 'getSelection' in $w ? function () {
|
||||
$w.getSelection().removeAllRanges();
|
||||
} : function () {
|
||||
$d.selection.empty();
|
||||
};
|
||||
|
||||
var options = {
|
||||
line_width: 5,
|
||||
lookup_delay: 500,
|
||||
lookup_interval: 80
|
||||
};
|
||||
|
||||
jsMind.draggable = function (jm) {
|
||||
this.jm = jm;
|
||||
this.e_canvas = null;
|
||||
this.canvas_ctx = null;
|
||||
this.shadow = null;
|
||||
this.shadow_w = 0;
|
||||
this.shadow_h = 0;
|
||||
this.active_node = null;
|
||||
this.target_node = null;
|
||||
this.target_direct = null;
|
||||
this.client_w = 0;
|
||||
this.client_h = 0;
|
||||
this.offset_x = 0;
|
||||
this.offset_y = 0;
|
||||
this.hlookup_delay = 0;
|
||||
this.hlookup_timer = 0;
|
||||
this.capture = false;
|
||||
this.moved = false;
|
||||
};
|
||||
|
||||
jsMind.draggable.prototype = {
|
||||
init: function () {
|
||||
this._create_canvas();
|
||||
this._create_shadow();
|
||||
this._event_bind();
|
||||
},
|
||||
|
||||
resize: function () {
|
||||
this.jm.view.e_nodes.appendChild(this.shadow);
|
||||
this.e_canvas.width = this.jm.view.size.w;
|
||||
this.e_canvas.height = this.jm.view.size.h;
|
||||
},
|
||||
|
||||
_create_canvas: function () {
|
||||
var c = $d.createElement('canvas');
|
||||
this.jm.view.e_panel.appendChild(c);
|
||||
var ctx = c.getContext('2d');
|
||||
this.e_canvas = c;
|
||||
this.canvas_ctx = ctx;
|
||||
},
|
||||
|
||||
_create_shadow: function () {
|
||||
var s = $d.createElement('jmnode');
|
||||
s.style.visibility = 'hidden';
|
||||
s.style.zIndex = '3';
|
||||
s.style.cursor = 'move';
|
||||
s.style.opacity = '0.7';
|
||||
this.shadow = s;
|
||||
},
|
||||
|
||||
reset_shadow: function (el) {
|
||||
var s = this.shadow.style;
|
||||
this.shadow.innerHTML = el.innerHTML;
|
||||
s.left = el.style.left;
|
||||
s.top = el.style.top;
|
||||
s.width = el.style.width;
|
||||
s.height = el.style.height;
|
||||
s.backgroundImage = el.style.backgroundImage;
|
||||
s.backgroundSize = el.style.backgroundSize;
|
||||
s.transform = el.style.transform;
|
||||
this.shadow_w = this.shadow.clientWidth;
|
||||
this.shadow_h = this.shadow.clientHeight;
|
||||
|
||||
},
|
||||
|
||||
show_shadow: function () {
|
||||
if (!this.moved) {
|
||||
this.shadow.style.visibility = 'visible';
|
||||
}
|
||||
},
|
||||
|
||||
hide_shadow: function () {
|
||||
this.shadow.style.visibility = 'hidden';
|
||||
},
|
||||
|
||||
_magnet_shadow: function (node) {
|
||||
if (!!node) {
|
||||
this.canvas_ctx.lineWidth = options.line_width;
|
||||
this.canvas_ctx.strokeStyle = 'rgba(0,0,0,0.3)';
|
||||
this.canvas_ctx.lineCap = 'round';
|
||||
this._clear_lines();
|
||||
this._canvas_lineto(node.sp.x, node.sp.y, node.np.x, node.np.y);
|
||||
}
|
||||
},
|
||||
|
||||
_clear_lines: function () {
|
||||
this.canvas_ctx.clearRect(0, 0, this.jm.view.size.w, this.jm.view.size.h);
|
||||
},
|
||||
|
||||
_canvas_lineto: function (x1, y1, x2, y2) {
|
||||
this.canvas_ctx.beginPath();
|
||||
this.canvas_ctx.moveTo(x1, y1);
|
||||
this.canvas_ctx.lineTo(x2, y2);
|
||||
this.canvas_ctx.stroke();
|
||||
},
|
||||
|
||||
_lookup_close_node: function () {
|
||||
var root = this.jm.get_root();
|
||||
var root_location = root.get_location();
|
||||
var root_size = root.get_size();
|
||||
var root_x = root_location.x + root_size.w / 2;
|
||||
|
||||
var sw = this.shadow_w;
|
||||
var sh = this.shadow_h;
|
||||
var sx = this.shadow.offsetLeft;
|
||||
var sy = this.shadow.offsetTop;
|
||||
|
||||
var ns, nl;
|
||||
|
||||
var direct = (sx + sw / 2) >= root_x ?
|
||||
jsMind.direction.right : jsMind.direction.left;
|
||||
var nodes = this.jm.mind.nodes;
|
||||
var node = null;
|
||||
var layout = this.jm.layout;
|
||||
var min_distance = Number.MAX_VALUE;
|
||||
var distance = 0;
|
||||
var closest_node = null;
|
||||
var closest_p = null;
|
||||
var shadow_p = null;
|
||||
for (var nodeid in nodes) {
|
||||
var np, sp;
|
||||
node = nodes[nodeid];
|
||||
if (node.isroot || node.direction == direct) {
|
||||
if (node.id == this.active_node.id) {
|
||||
continue;
|
||||
}
|
||||
if (!layout.is_visible(node)) {
|
||||
continue;
|
||||
}
|
||||
ns = node.get_size();
|
||||
nl = node.get_location();
|
||||
if (direct == jsMind.direction.right) {
|
||||
if (sx - nl.x - ns.w <= 0) { continue; }
|
||||
distance = Math.abs(sx - nl.x - ns.w) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
|
||||
np = { x: nl.x + ns.w - options.line_width, y: nl.y + ns.h / 2 };
|
||||
sp = { x: sx + options.line_width, y: sy + sh / 2 };
|
||||
} else {
|
||||
if (nl.x - sx - sw <= 0) { continue; }
|
||||
distance = Math.abs(sx + sw - nl.x) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
|
||||
np = { x: nl.x + options.line_width, y: nl.y + ns.h / 2 };
|
||||
sp = { x: sx + sw - options.line_width, y: sy + sh / 2 };
|
||||
}
|
||||
if (distance < min_distance) {
|
||||
closest_node = node;
|
||||
closest_p = np;
|
||||
shadow_p = sp;
|
||||
min_distance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
var result_node = null;
|
||||
if (!!closest_node) {
|
||||
result_node = {
|
||||
node: closest_node,
|
||||
direction: direct,
|
||||
sp: shadow_p,
|
||||
np: closest_p
|
||||
};
|
||||
}
|
||||
return result_node;
|
||||
},
|
||||
|
||||
lookup_close_node: function () {
|
||||
var node_data = this._lookup_close_node();
|
||||
if (!!node_data) {
|
||||
this._magnet_shadow(node_data);
|
||||
this.target_node = node_data.node;
|
||||
this.target_direct = node_data.direction;
|
||||
}
|
||||
},
|
||||
|
||||
_event_bind: function () {
|
||||
var jd = this;
|
||||
var container = this.jm.view.container;
|
||||
jdom.add_event(container, 'mousedown', function (e) {
|
||||
var evt = e || event;
|
||||
jd.dragstart.call(jd, evt);
|
||||
});
|
||||
jdom.add_event(container, 'mousemove', function (e) {
|
||||
var evt = e || event;
|
||||
jd.drag.call(jd, evt);
|
||||
});
|
||||
jdom.add_event(container, 'mouseup', function (e) {
|
||||
var evt = e || event;
|
||||
jd.dragend.call(jd, evt);
|
||||
});
|
||||
jdom.add_event(container, 'touchstart', function (e) {
|
||||
var evt = e || event;
|
||||
jd.dragstart.call(jd, evt);
|
||||
});
|
||||
jdom.add_event(container, 'touchmove', function (e) {
|
||||
var evt = e || event;
|
||||
jd.drag.call(jd, evt);
|
||||
});
|
||||
jdom.add_event(container, 'touchend', function (e) {
|
||||
var evt = e || event;
|
||||
jd.dragend.call(jd, evt);
|
||||
});
|
||||
},
|
||||
|
||||
dragstart: function (e) {
|
||||
if (!this.jm.get_editable()) { return; }
|
||||
if (this.capture) { return; }
|
||||
this.active_node = null;
|
||||
|
||||
var jview = this.jm.view;
|
||||
var el = e.target || event.srcElement;
|
||||
if (el.tagName.toLowerCase() != 'jmnode') { return; }
|
||||
var nodeid = jview.get_binded_nodeid(el);
|
||||
if (!!nodeid) {
|
||||
var node = this.jm.get_node(nodeid);
|
||||
if (!node.isroot) {
|
||||
this.reset_shadow(el);
|
||||
this.active_node = node;
|
||||
this.offset_x = (e.clientX || e.touches[0].clientX) / jview.actualZoom - el.offsetLeft;
|
||||
this.offset_y = (e.clientY || e.touches[0].clientY) / jview.actualZoom - el.offsetTop;
|
||||
this.client_hw = Math.floor(el.clientWidth / 2);
|
||||
this.client_hh = Math.floor(el.clientHeight / 2);
|
||||
if (this.hlookup_delay != 0) {
|
||||
$w.clearTimeout(this.hlookup_delay);
|
||||
}
|
||||
if (this.hlookup_timer != 0) {
|
||||
$w.clearInterval(this.hlookup_timer);
|
||||
}
|
||||
var jd = this;
|
||||
this.hlookup_delay = $w.setTimeout(function () {
|
||||
jd.hlookup_delay = 0;
|
||||
jd.hlookup_timer = $w.setInterval(function () {
|
||||
jd.lookup_close_node.call(jd);
|
||||
}, options.lookup_interval);
|
||||
}, options.lookup_delay);
|
||||
this.capture = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
drag: function (e) {
|
||||
if (!this.jm.get_editable()) { return; }
|
||||
if (this.capture) {
|
||||
e.preventDefault();
|
||||
this.show_shadow();
|
||||
this.moved = true;
|
||||
clear_selection();
|
||||
var jview = this.jm.view;
|
||||
var px = (e.clientX || e.touches[0].clientX) / jview.actualZoom - this.offset_x;
|
||||
var py = (e.clientY || e.touches[0].clientY) / jview.actualZoom - this.offset_y;
|
||||
this.shadow.style.left = px + 'px';
|
||||
this.shadow.style.top = py + 'px';
|
||||
clear_selection();
|
||||
}
|
||||
},
|
||||
|
||||
dragend: function (e) {
|
||||
if (!this.jm.get_editable()) { return; }
|
||||
if (this.capture) {
|
||||
if (this.hlookup_delay != 0) {
|
||||
$w.clearTimeout(this.hlookup_delay);
|
||||
this.hlookup_delay = 0;
|
||||
this._clear_lines();
|
||||
}
|
||||
if (this.hlookup_timer != 0) {
|
||||
$w.clearInterval(this.hlookup_timer);
|
||||
this.hlookup_timer = 0;
|
||||
this._clear_lines();
|
||||
}
|
||||
if (this.moved) {
|
||||
var src_node = this.active_node;
|
||||
var target_node = this.target_node;
|
||||
var target_direct = this.target_direct;
|
||||
this.move_node(src_node, target_node, target_direct);
|
||||
}
|
||||
this.hide_shadow();
|
||||
}
|
||||
this.moved = false;
|
||||
this.capture = false;
|
||||
},
|
||||
|
||||
move_node: function (src_node, target_node, target_direct) {
|
||||
var shadow_h = this.shadow.offsetTop;
|
||||
if (!!target_node && !!src_node && !jsMind.node.inherited(src_node, target_node)) {
|
||||
// lookup before_node
|
||||
var sibling_nodes = target_node.children;
|
||||
var sc = sibling_nodes.length;
|
||||
var node = null;
|
||||
var delta_y = Number.MAX_VALUE;
|
||||
var node_before = null;
|
||||
var beforeid = '_last_';
|
||||
while (sc--) {
|
||||
node = sibling_nodes[sc];
|
||||
if (node.direction == target_direct && node.id != src_node.id) {
|
||||
var dy = node.get_location().y - shadow_h;
|
||||
if (dy > 0 && dy < delta_y) {
|
||||
delta_y = dy;
|
||||
node_before = node;
|
||||
beforeid = '_first_';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!!node_before) { beforeid = node_before.id; }
|
||||
this.jm.move_node(src_node.id, beforeid, target_node.id, target_direct);
|
||||
}
|
||||
this.active_node = null;
|
||||
this.target_node = null;
|
||||
this.target_direct = null;
|
||||
},
|
||||
|
||||
jm_event_handle: function (type, data) {
|
||||
if (type === jsMind.event_type.resize) {
|
||||
this.resize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var draggable_plugin = new jsMind.plugin('draggable', function (jm) {
|
||||
var jd = new jsMind.draggable(jm);
|
||||
jd.init();
|
||||
jm.add_event_listener(function (type, data) {
|
||||
jd.jm_event_handle.call(jd, type, data);
|
||||
});
|
||||
});
|
||||
|
||||
jsMind.register_plugin(draggable_plugin);
|
||||
|
||||
})(window);
|
||||
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Released under BSD License
|
||||
* Copyright (c) 2019-2020 Allen_sun_js@hotmail.com
|
||||
*
|
||||
* Project Home:
|
||||
* https://github.com/allensunjian
|
||||
*/
|
||||
|
||||
(function ($w, temp) {
|
||||
var Jm = $w[temp]
|
||||
|
||||
var name = 'menu'
|
||||
|
||||
var $d = $w['document']
|
||||
|
||||
var menuEvent = 'oncontextmenu'
|
||||
|
||||
var clickEvent = 'onclick'
|
||||
|
||||
var overEvent = 'mouseover'
|
||||
|
||||
var $c = function (tag) { return $d.createElement(tag) }
|
||||
|
||||
var _noop = function () { }
|
||||
|
||||
var logger = (typeof console === 'undefined') ? {
|
||||
|
||||
log: _noop, debug: _noop, error: _noop, warn: _noop, info: _noop
|
||||
|
||||
} : console
|
||||
|
||||
var $t = function (n, t) { if (n.hasChildNodes()) { n.firstChild.nodeValue = t } else { n.appendChild($d.createTextNode(t)) } }
|
||||
|
||||
var $h = function (n, t) {
|
||||
if (t instanceof HTMLElement) {
|
||||
t.innerHTML = ''
|
||||
n.appendChild(t)
|
||||
} else {
|
||||
n.innerHTML = t
|
||||
}
|
||||
}
|
||||
|
||||
if (!Jm || Jm[name]) return
|
||||
|
||||
Jm.menu = function (_jm) {
|
||||
this._get_menu_options(_jm, function () {
|
||||
this.init(_jm)
|
||||
|
||||
this._mount_events()
|
||||
})
|
||||
}
|
||||
Jm.menu.prototype = {
|
||||
|
||||
defaultDataMap: {
|
||||
funcMap: {
|
||||
edit: {
|
||||
isDepNode: true,
|
||||
// defaultFn不受到中台变量的控制,始终会先于fn去执行
|
||||
defaultFn: function (node) {
|
||||
var f = this._menu_default_mind_methods._menu_begin_edit.call(this.jm)
|
||||
f && this._menu_default_mind_methods._menu_edit_node_begin(this.jm.view, node)
|
||||
},
|
||||
fn: _noop,
|
||||
text: 'edit node'
|
||||
},
|
||||
addChild: {
|
||||
isDepNode: true,
|
||||
fn: function (nodeid, text) {
|
||||
var selected_node = this.get_selected_node()
|
||||
if (selected_node) {
|
||||
var node = this.add_node(selected_node, nodeid, text)
|
||||
if (node) {
|
||||
this.select_node(nodeid)
|
||||
this.begin_edit(nodeid)
|
||||
}
|
||||
}
|
||||
},
|
||||
text: 'append child'
|
||||
},
|
||||
addBrother: {
|
||||
isDepNode: true,
|
||||
fn: function (nodeid, text) {
|
||||
var selected_node = this.get_selected_node()
|
||||
if (!!selected_node && !selected_node.isroot) {
|
||||
var node = this.insert_node_after(selected_node, nodeid, text)
|
||||
if (node) {
|
||||
this.select_node(nodeid)
|
||||
this.begin_edit(nodeid)
|
||||
}
|
||||
}
|
||||
},
|
||||
text: 'append brother'
|
||||
},
|
||||
delete: {
|
||||
isDepNode: true,
|
||||
fn: function () {
|
||||
this.shortcut.handle_delnode.call(this.shortcut, this)
|
||||
},
|
||||
text: 'delete node'
|
||||
},
|
||||
showAll: {
|
||||
sDepNode: false,
|
||||
fn: function () {
|
||||
this.expand_all(this)
|
||||
},
|
||||
text: 'show all'
|
||||
},
|
||||
hideAll: {
|
||||
isDepNode: false,
|
||||
fn: function () {
|
||||
this.collapse_all(this)
|
||||
},
|
||||
text: 'hide all'
|
||||
},
|
||||
screenshot: {
|
||||
isDepNode: false,
|
||||
fn: function () {
|
||||
if (!this.screenshot) {
|
||||
logger.error('[jsmind] screenshot dependent on jsmind.screenshot.js !')
|
||||
return
|
||||
}
|
||||
this.screenshot.shootDownload()
|
||||
},
|
||||
text: 'load mind picture'
|
||||
},
|
||||
showNode: {
|
||||
isDepNode: true,
|
||||
fn: function (node) {
|
||||
this.expand_node(node)
|
||||
},
|
||||
text: 'show target node'
|
||||
},
|
||||
hideNode: {
|
||||
isDepNode: true,
|
||||
fn: function (node) {
|
||||
this.collapse_node(node)
|
||||
},
|
||||
text: 'hide target node'
|
||||
}
|
||||
},
|
||||
menuStl: {
|
||||
'width': '150px',
|
||||
'padding': '12px 0',
|
||||
'position': 'fixed',
|
||||
'z-index': '10',
|
||||
'background': '#fff',
|
||||
'box-shadow': '0 2px 12px 0 rgba(0,0,0,0.1)',
|
||||
'border-radius': '5px',
|
||||
'font-size': '12px',
|
||||
'display': 'none'
|
||||
},
|
||||
menuItemStl: {
|
||||
padding: '5px 15px',
|
||||
cursor: 'pointer',
|
||||
display: 'block',
|
||||
'text-align': 'center',
|
||||
'transition': 'all .2s'
|
||||
},
|
||||
injectionList: ['edit', 'addChild', 'delete']
|
||||
},
|
||||
|
||||
init: function (_jm) {
|
||||
this._create_menu(_jm)
|
||||
this._get_injectionList(_jm)
|
||||
this.menuOpts.switchMidStage && Jm.util.dom.add_event(_jm.view.e_editor, 'blur', function (e) {
|
||||
this._menu_default_mind_methods._menu_edit_node_end.call(_jm.view)
|
||||
if (typeof this.menuOpts.editCaller === 'function') {
|
||||
this.menuOpts.editCaller($w.menu._update_node_info, this._menu_default_mind_methods._menu_update_edit_node)
|
||||
return
|
||||
}
|
||||
this._menu_default_mind_methods._menu_update_edit_node()
|
||||
}.bind(this))
|
||||
},
|
||||
|
||||
_event_contextMenu (e) {
|
||||
e.preventDefault()
|
||||
this.menu.style.left = e.clientX + 'px'
|
||||
this.menu.style.top = e.clientY + 'px'
|
||||
this.menu.style.display = 'block'
|
||||
this.selected_node = this.jm.get_selected_node()
|
||||
},
|
||||
|
||||
_event_hideMenu () {
|
||||
this.menu.style.display = 'none'
|
||||
},
|
||||
|
||||
_mount_events () {
|
||||
$w[menuEvent] = this._event_contextMenu.bind(this)
|
||||
$w[clickEvent] = this._event_hideMenu.bind(this)
|
||||
},
|
||||
|
||||
_create_menu (_jm) {
|
||||
var d = $c('menu')
|
||||
this._set_menu_wrap_syl(d)
|
||||
this.menu = d
|
||||
this.e_panel = _jm.view.e_panel
|
||||
this.e_panel.appendChild(d)
|
||||
},
|
||||
|
||||
_create_menu_item (j, text, fn, isDepNode, cb, defaultFn) {
|
||||
var d = $c('menu-item'); var _this = this
|
||||
this._set_menu_item_syl(d)
|
||||
d.innerText = text
|
||||
d.addEventListener('click', function () {
|
||||
if (this.selected_node || !isDepNode) {
|
||||
defaultFn.call(_this, this.selected_node)
|
||||
if (!_this._get_mid_opts()) {
|
||||
cb(this.selected_node, _noop)
|
||||
fn.call(j, Jm.util.uuid.newid(), this.menuOpts.newNodeText || '请输入名称')
|
||||
return
|
||||
}
|
||||
cb(this.selected_node, _this._mid_stage_next(function () {
|
||||
var retArgs = [this.selected_node]
|
||||
var argus = Array.prototype.slice.call(arguments[0], 0)
|
||||
argus[1] = this.menuOpts.newNodeText || '请输入名称'
|
||||
if (argus[0]) {
|
||||
retArgs = argus
|
||||
}
|
||||
fn.apply(j, retArgs)
|
||||
}.bind(this)))
|
||||
return
|
||||
}
|
||||
alert(this.menuOpts.tipContent || 'Continue with node selected!')
|
||||
}.bind(this))
|
||||
d.addEventListener('mouseover', function () {
|
||||
d.style.background = 'rgb(179, 216, 255)'
|
||||
})
|
||||
d.addEventListener('mouseleave', function () {
|
||||
d.style.background = '#fff'
|
||||
})
|
||||
return d
|
||||
},
|
||||
|
||||
_set_menu_wrap_syl (d) {
|
||||
var os = this._get_option_sty('menu', this._get_mixin_sty)
|
||||
d.style.cssText = this._format_cssText(os)
|
||||
},
|
||||
|
||||
_set_menu_item_syl (d) {
|
||||
var os = this._get_option_sty('menuItem', this._get_mixin_sty)
|
||||
d.style.cssText = this._format_cssText(os)
|
||||
},
|
||||
|
||||
_format_cssText (o) {
|
||||
var text = ''
|
||||
Object.keys(o).forEach(function (k) {
|
||||
text += k + ':' + o[k] + ';'
|
||||
})
|
||||
return text
|
||||
},
|
||||
|
||||
_empty_object (o) {
|
||||
return Object.keys(o).length == 0
|
||||
},
|
||||
|
||||
_get_option_sty (type, fn) {
|
||||
var sty = this.menuOpts.style
|
||||
var menu = this.defaultDataMap.menuStl
|
||||
var menuItem = this.defaultDataMap.menuItemStl
|
||||
var o = {menu, menuItem}
|
||||
if (!sty) return o[type]
|
||||
if (!sty[type]) return o[type]
|
||||
if (!sty[type] || this._empty_object(sty[type])) return o[type]
|
||||
return fn(o[type], sty[type])
|
||||
},
|
||||
|
||||
_get_mixin_sty (dSty, oSty) {
|
||||
var o = {}
|
||||
Object.keys(oSty).forEach(function (k) {
|
||||
o[k] = oSty[k]
|
||||
})
|
||||
Object.keys(dSty).forEach(function (k) {
|
||||
if (!o[k]) o[k] = dSty[k]
|
||||
})
|
||||
return o
|
||||
},
|
||||
|
||||
_get_menu_options (j, fn) {
|
||||
var options = j.options
|
||||
if (!options.menuOpts) return
|
||||
if (!options.menuOpts.showMenu) return
|
||||
this.menuOpts = j.options.menuOpts
|
||||
fn.call(this)
|
||||
},
|
||||
|
||||
_get_injectionDetail () {
|
||||
var iLs = this.menuOpts.injectionList
|
||||
var dLs = this.defaultDataMap.injectionList
|
||||
if (!iLs) return dLs
|
||||
if (!Array.isArray(iLs)) {
|
||||
logger.error('[jsmind] injectionList must be a Array')
|
||||
return
|
||||
}
|
||||
if (iLs.length == 0) return dLs
|
||||
return iLs
|
||||
},
|
||||
|
||||
_get_injectionList (j) {
|
||||
var list = this._get_injectionDetail()
|
||||
var _this = this
|
||||
list.forEach(function (k) {
|
||||
var o = null
|
||||
var text = ''
|
||||
var callback = _noop
|
||||
var defaultFn = _noop
|
||||
|
||||
if (typeof k === 'object') {
|
||||
o = _this.defaultDataMap.funcMap[k.target]
|
||||
text = k.text
|
||||
k.callback && (callback = k.callback)
|
||||
} else {
|
||||
o = _this.defaultDataMap.funcMap[k]
|
||||
text = o.text
|
||||
}
|
||||
|
||||
if (o.defaultFn) defaultFn = o.defaultFn
|
||||
_this.menu.appendChild(_this._create_menu_item(j, text, o.fn, o.isDepNode, callback, defaultFn))
|
||||
})
|
||||
},
|
||||
|
||||
_get_mid_opts () {
|
||||
var b = this.menuOpts.switchMidStage
|
||||
if (!b) return false
|
||||
if (typeof b !== 'boolean') {
|
||||
logger.error('[jsmind] switchMidStage must be Boolean')
|
||||
return false
|
||||
}
|
||||
return b
|
||||
},
|
||||
|
||||
_switch_view_db_event (b, jm) {
|
||||
Jm.prototype.dblclick_handle = _noop
|
||||
Jm.shortcut_provider.prototype.handler = _noop
|
||||
Jm.view_provider.prototype.edit_node_end = _noop
|
||||
},
|
||||
|
||||
_mid_stage_next (fn) {
|
||||
return function () {
|
||||
fn(arguments)
|
||||
}
|
||||
},
|
||||
|
||||
_reset_mind_event_edit () {},
|
||||
|
||||
_menu_default_mind_methods: {
|
||||
_menu_begin_edit: function () {
|
||||
var f = this.get_editable()
|
||||
if (!f) {
|
||||
logger.error('fail, this mind map is not editable.')
|
||||
};
|
||||
return f
|
||||
},
|
||||
_menu_edit_node_begin (scope, node) {
|
||||
if (!node.topic) {
|
||||
logger.warn("don't edit image nodes")
|
||||
return
|
||||
}
|
||||
if (scope.editing_node != null) {
|
||||
this._menu_default_mind_methods._menu_edit_node_end.call(scope)
|
||||
}
|
||||
scope.editing_node = node
|
||||
var view_data = node._data.view
|
||||
var element = view_data.element
|
||||
var topic = node.topic
|
||||
var ncs = getComputedStyle(element)
|
||||
scope.e_editor.value = topic
|
||||
scope.e_editor.style.width = (element.clientWidth - parseInt(ncs.getPropertyValue('padding-left')) - parseInt(ncs.getPropertyValue('padding-right'))) + 'px'
|
||||
scope.e_editor.style.height = (element.clientHeight - parseInt(ncs.getPropertyValue('padding-top')) - parseInt(ncs.getPropertyValue('padding-bottom'))) + 'px'
|
||||
element.innerHTML = ''
|
||||
element.appendChild(scope.e_editor)
|
||||
element.style.zIndex = 5
|
||||
scope.e_editor.focus()
|
||||
scope.e_editor.select()
|
||||
},
|
||||
_menu_edit_node_end: function () {
|
||||
if (this.editing_node != null) {
|
||||
var node = this.editing_node
|
||||
this.editing_node = null
|
||||
var view_data = node._data.view
|
||||
var element = view_data.element
|
||||
var topic = this.e_editor.value
|
||||
element.style.zIndex = 'auto'
|
||||
element.removeChild(this.e_editor)
|
||||
$w.menu._update_node_info = {id: node.id, topic: topic}
|
||||
if (Jm.util.text.is_empty(topic) || node.topic === topic) {
|
||||
if (this.opts.support_html) {
|
||||
$h(element, node.topic)
|
||||
} else {
|
||||
$t(element, node.topic)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_menu_update_edit_node: function () {
|
||||
var info = $w.menu._update_node_info
|
||||
$w.menu.jm.update_node(info.id, info.topic)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
var plugin = new Jm.plugin('menu', function (_jm) {
|
||||
$w.menu = new Jm.menu(_jm)
|
||||
|
||||
menu.jm = _jm
|
||||
|
||||
if (menu.menuOpts) _jm.menu = menu
|
||||
})
|
||||
|
||||
Jm.register_plugin(plugin)
|
||||
|
||||
|
||||
function preventMindEventDefault () {
|
||||
Jm.menu.prototype._switch_view_db_event()
|
||||
}
|
||||
Jm.preventMindEventDefault = preventMindEventDefault
|
||||
})(window, 'jsMind')
|
||||
@@ -0,0 +1,351 @@
|
||||
/*
|
||||
* Released under BSD License
|
||||
* Copyright (c) 2014-2021 hizzgdev@163.com
|
||||
*
|
||||
* Project Home:
|
||||
* https://github.com/hizzgdev/jsmind/
|
||||
*/
|
||||
|
||||
(function ($w) {
|
||||
'use strict';
|
||||
|
||||
var __name__ = 'jsMind';
|
||||
var jsMind = $w[__name__];
|
||||
if (!jsMind) { return; }
|
||||
if (typeof jsMind.screenshot != 'undefined') { return; }
|
||||
|
||||
var $d = $w.document;
|
||||
var $c = function (tag) { return $d.createElement(tag); };
|
||||
|
||||
var css = function (cstyle, property_name) {
|
||||
return cstyle.getPropertyValue(property_name);
|
||||
};
|
||||
var is_visible = function (cstyle) {
|
||||
var visibility = css(cstyle, 'visibility');
|
||||
var display = css(cstyle, 'display');
|
||||
return (visibility !== 'hidden' && display !== 'none');
|
||||
};
|
||||
var jcanvas = {};
|
||||
jcanvas.rect = function (ctx, x, y, w, h, r) {
|
||||
if (w < 2 * r) r = w / 2;
|
||||
if (h < 2 * r) r = h / 2;
|
||||
ctx.moveTo(x + r, y);
|
||||
ctx.arcTo(x + w, y, x + w, y + h, r);
|
||||
ctx.arcTo(x + w, y + h, x, y + h, r);
|
||||
ctx.arcTo(x, y + h, x, y, r);
|
||||
ctx.arcTo(x, y, x + w, y, r);
|
||||
};
|
||||
|
||||
jcanvas.text_multiline = function (ctx, text, x, y, w, h, lineheight) {
|
||||
var line = '';
|
||||
var text_len = text.length;
|
||||
var chars = text.split('');
|
||||
var test_line = null;
|
||||
ctx.textAlign = 'left';
|
||||
ctx.textBaseline = 'top';
|
||||
for (var i = 0; i < text_len; i++) {
|
||||
test_line = line + chars[i];
|
||||
if (ctx.measureText(test_line).width > w && i > 0) {
|
||||
ctx.fillText(line, x, y);
|
||||
line = chars[i];
|
||||
y += lineheight;
|
||||
} else {
|
||||
line = test_line;
|
||||
}
|
||||
}
|
||||
ctx.fillText(line, x, y);
|
||||
};
|
||||
|
||||
jcanvas.text_ellipsis = function (ctx, text, x, y, w, h) {
|
||||
var center_y = y + h / 2;
|
||||
var text = jcanvas.fittingString(ctx, text, w);
|
||||
ctx.textAlign = 'left';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillText(text, x, center_y, w);
|
||||
};
|
||||
|
||||
jcanvas.fittingString = function (ctx, text, max_width) {
|
||||
var width = ctx.measureText(text).width;
|
||||
var ellipsis = '…';
|
||||
var ellipsis_width = ctx.measureText(ellipsis).width;
|
||||
if (width <= max_width || width <= ellipsis_width) {
|
||||
return text;
|
||||
} else {
|
||||
var len = text.length;
|
||||
while (width >= max_width - ellipsis_width && len-- > 0) {
|
||||
text = text.substring(0, len);
|
||||
width = ctx.measureText(text).width;
|
||||
}
|
||||
return text + ellipsis;
|
||||
}
|
||||
};
|
||||
|
||||
jcanvas.image = function (ctx, url, x, y, w, h, r, rotation, callback) {
|
||||
var img = new Image();
|
||||
img.onload = function () {
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
jcanvas.rect(ctx, 0, 0, w, h, r);
|
||||
ctx.closePath();
|
||||
ctx.clip();
|
||||
ctx.translate(w / 2, h / 2);
|
||||
ctx.rotate(rotation * Math.PI / 180);
|
||||
ctx.drawImage(img, -w / 2, -h / 2);
|
||||
ctx.restore();
|
||||
ctx.restore();
|
||||
!!callback && callback();
|
||||
}
|
||||
img.src = url;
|
||||
};
|
||||
|
||||
jsMind.screenshot = function (jm) {
|
||||
this.jm = jm;
|
||||
this.canvas_elem = null;
|
||||
this.canvas_ctx = null;
|
||||
this._inited = false;
|
||||
};
|
||||
|
||||
jsMind.screenshot.prototype = {
|
||||
init: function () {
|
||||
if (this._inited) { return; }
|
||||
console.log('init');
|
||||
var c = $c('canvas');
|
||||
var ctx = c.getContext('2d');
|
||||
|
||||
this.canvas_elem = c;
|
||||
this.canvas_ctx = ctx;
|
||||
this.jm.view.e_panel.appendChild(c);
|
||||
this._inited = true;
|
||||
this.resize();
|
||||
},
|
||||
|
||||
shoot: function (callback) {
|
||||
this.init();
|
||||
this._draw(function () {
|
||||
!!callback && callback();
|
||||
this.clean();
|
||||
}.bind(this));
|
||||
this._watermark();
|
||||
},
|
||||
|
||||
shootDownload: function () {
|
||||
this.shoot(function () {
|
||||
this._download();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
shootAsDataURL: function (callback) {
|
||||
this.shoot(function () {
|
||||
!!callback && callback(this.canvas_elem.toDataURL());
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
resize: function () {
|
||||
if (this._inited) {
|
||||
this.canvas_elem.width = this.jm.view.size.w;
|
||||
this.canvas_elem.height = this.jm.view.size.h;
|
||||
}
|
||||
},
|
||||
|
||||
clean: function () {
|
||||
var c = this.canvas_elem;
|
||||
this.canvas_ctx.clearRect(0, 0, c.width, c.height);
|
||||
},
|
||||
|
||||
_draw: function (callback) {
|
||||
var ctx = this.canvas_ctx;
|
||||
ctx.textAlign = 'left';
|
||||
ctx.textBaseline = 'top';
|
||||
this._draw_lines(function () {
|
||||
this._draw_nodes(callback);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_watermark: function () {
|
||||
var c = this.canvas_elem;
|
||||
var ctx = this.canvas_ctx;
|
||||
ctx.textAlign = 'right';
|
||||
ctx.textBaseline = 'bottom';
|
||||
ctx.fillStyle = '#000';
|
||||
ctx.font = '11px Verdana,Arial,Helvetica,sans-serif';
|
||||
ctx.fillText('hizzgdev.github.io/jsmind', c.width - 5.5, c.height - 2.5);
|
||||
ctx.textAlign = 'left';
|
||||
ctx.fillText($w.location, 5.5, c.height - 2.5);
|
||||
},
|
||||
|
||||
_draw_lines: function (callback) {
|
||||
this.jm.view.graph.copy_to(this.canvas_ctx, callback);
|
||||
},
|
||||
|
||||
_draw_nodes: function (callback) {
|
||||
var nodes = this.jm.mind.nodes;
|
||||
var node;
|
||||
for (var nodeid in nodes) {
|
||||
node = nodes[nodeid];
|
||||
this._draw_node(node);
|
||||
}
|
||||
|
||||
function check_nodes_ready() {
|
||||
console.log('check_node_ready' + new Date());
|
||||
var allOk = true;
|
||||
for (var nodeid in nodes) {
|
||||
node = nodes[nodeid];
|
||||
allOk = allOk & node.ready;
|
||||
}
|
||||
|
||||
if (!allOk) {
|
||||
$w.setTimeout(check_nodes_ready, 200);
|
||||
} else {
|
||||
$w.setTimeout(callback, 200);
|
||||
}
|
||||
}
|
||||
check_nodes_ready();
|
||||
},
|
||||
|
||||
_draw_node: function (node) {
|
||||
var ctx = this.canvas_ctx;
|
||||
var view_data = node._data.view;
|
||||
var node_element = view_data.element;
|
||||
var ncs = getComputedStyle(node_element);
|
||||
if (!is_visible(ncs)) {
|
||||
node.ready = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var bgcolor = css(ncs, 'background-color');
|
||||
var round_radius = parseInt(css(ncs, 'border-top-left-radius'));
|
||||
var color = css(ncs, 'color');
|
||||
var padding_left = parseInt(css(ncs, 'padding-left'));
|
||||
var padding_right = parseInt(css(ncs, 'padding-right'));
|
||||
var padding_top = parseInt(css(ncs, 'padding-top'));
|
||||
var padding_bottom = parseInt(css(ncs, 'padding-bottom'));
|
||||
var text_overflow = css(ncs, 'text-overflow');
|
||||
var font = css(ncs, 'font-style') + ' ' +
|
||||
css(ncs, 'font-variant') + ' ' +
|
||||
css(ncs, 'font-weight') + ' ' +
|
||||
css(ncs, 'font-size') + '/' + css(ncs, 'line-height') + ' ' +
|
||||
css(ncs, 'font-family');
|
||||
|
||||
var rb = {
|
||||
x: view_data.abs_x,
|
||||
y: view_data.abs_y,
|
||||
w: view_data.width + 1,
|
||||
h: view_data.height + 1
|
||||
};
|
||||
var tb = {
|
||||
x: rb.x + padding_left,
|
||||
y: rb.y + padding_top,
|
||||
w: rb.w - padding_left - padding_right,
|
||||
h: rb.h - padding_top - padding_bottom
|
||||
};
|
||||
|
||||
ctx.font = font;
|
||||
ctx.fillStyle = bgcolor;
|
||||
ctx.beginPath();
|
||||
jcanvas.rect(ctx, rb.x, rb.y, rb.w, rb.h, round_radius);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
|
||||
ctx.fillStyle = color;
|
||||
if ('background-image' in node.data) {
|
||||
var backgroundUrl = css(ncs, 'background-image').slice(5, -2);
|
||||
node.ready = false;
|
||||
var rotation = 0;
|
||||
if ('background-rotation' in node.data) {
|
||||
rotation = node.data['background-rotation'];
|
||||
}
|
||||
jcanvas.image(ctx, backgroundUrl, rb.x, rb.y, rb.w, rb.h, round_radius, rotation,
|
||||
function () {
|
||||
node.ready = true;
|
||||
});
|
||||
}
|
||||
if (!!node.topic) {
|
||||
if (text_overflow === 'ellipsis') {
|
||||
jcanvas.text_ellipsis(ctx, node.topic, tb.x, tb.y, tb.w, tb.h);
|
||||
} else {
|
||||
var line_height = parseInt(css(ncs, 'line-height'));
|
||||
jcanvas.text_multiline(ctx, node.topic, tb.x, tb.y, tb.w, tb.h, line_height);
|
||||
}
|
||||
}
|
||||
if (!!view_data.expander) {
|
||||
this._draw_expander(view_data.expander);
|
||||
}
|
||||
if (!('background-image' in node.data)) {
|
||||
node.ready = true;
|
||||
}
|
||||
},
|
||||
|
||||
_draw_expander: function (expander) {
|
||||
var ctx = this.canvas_ctx;
|
||||
var ncs = getComputedStyle(expander);
|
||||
if (!is_visible(ncs)) { return; }
|
||||
|
||||
var style_left = css(ncs, 'left');
|
||||
var style_top = css(ncs, 'top');
|
||||
var font = css(ncs, 'font');
|
||||
var left = parseInt(style_left);
|
||||
var top = parseInt(style_top);
|
||||
var is_plus = expander.innerHTML === '+';
|
||||
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.arc(left + 7, top + 7, 5, 0, Math.PI * 2, true);
|
||||
ctx.moveTo(left + 10, top + 7);
|
||||
ctx.lineTo(left + 4, top + 7);
|
||||
if (is_plus) {
|
||||
ctx.moveTo(left + 7, top + 4);
|
||||
ctx.lineTo(left + 7, top + 10);
|
||||
}
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
},
|
||||
|
||||
_download: function () {
|
||||
var c = this.canvas_elem;
|
||||
var name = this.jm.mind.name + '.png';
|
||||
|
||||
if (navigator.msSaveBlob && (!!c.msToBlob)) {
|
||||
var blob = c.msToBlob();
|
||||
navigator.msSaveBlob(blob, name);
|
||||
} else {
|
||||
var bloburl = this.canvas_elem.toDataURL();
|
||||
var anchor = $c('a');
|
||||
if ('download' in anchor) {
|
||||
anchor.style.visibility = 'hidden';
|
||||
anchor.href = bloburl;
|
||||
anchor.download = name;
|
||||
$d.body.appendChild(anchor);
|
||||
var evt = $d.createEvent('MouseEvents');
|
||||
evt.initEvent('click', true, true);
|
||||
anchor.dispatchEvent(evt);
|
||||
$d.body.removeChild(anchor);
|
||||
} else {
|
||||
location.href = bloburl;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
jm_event_handle: function (type, data) {
|
||||
if (type === jsMind.event_type.resize) {
|
||||
this.resize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var screenshot_plugin = new jsMind.plugin('screenshot', function (jm) {
|
||||
var jss = new jsMind.screenshot(jm);
|
||||
jm.screenshot = jss;
|
||||
jm.shoot = function () {
|
||||
jss.shoot();
|
||||
};
|
||||
jm.add_event_listener(function (type, data) {
|
||||
jss.jm_event_handle.call(jss, type, data);
|
||||
});
|
||||
});
|
||||
|
||||
jsMind.register_plugin(screenshot_plugin);
|
||||
|
||||
})(window);
|
||||
@@ -0,0 +1,29 @@
|
||||
function common_alert(text, class_str) {
|
||||
if (!class_str) {
|
||||
class_str = 'alert-warning'
|
||||
}
|
||||
// reset bootstrap.bundle.js 里的方法
|
||||
const bundle_alert = typeof ($('.alert').alert) === 'function'
|
||||
if (bundle_alert) {
|
||||
$('.alert').alert('close')
|
||||
}
|
||||
// content
|
||||
const content = `
|
||||
<div class="alert ${class_str} fade show" role="alert" style="z-index: 2000;position: absolute;top: 0;width: calc(100%);">
|
||||
${text}
|
||||
</div>`
|
||||
// append
|
||||
$('body').append(content)
|
||||
// clean
|
||||
setTimeout(function () {
|
||||
if (bundle_alert) {
|
||||
$('.alert').alert('close')
|
||||
} else {
|
||||
$('.alert').fadeOut('slow')
|
||||
}
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
function primary_alert(text) {
|
||||
common_alert(text, 'alert-primary')
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
const modal = `
|
||||
<!-- login Modal start-->
|
||||
<div class="modal fade" id="exampleModal" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">注册</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!--qr_login Modal start
|
||||
<div class="modal-body qr_login_group" style="height: 360px;">
|
||||
<img src="https://img0.baidu.com/it/u=3881180510,1470858589&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200" height="300px">
|
||||
</div>
|
||||
-->
|
||||
<!--qr_login Modal end-->
|
||||
|
||||
<!--register Modal start-->
|
||||
<form>
|
||||
<div class="modal-body register_group" style="height: 360px;">
|
||||
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
|
||||
<label for="userName" class="sr-only"></label>
|
||||
<input type="text" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
|
||||
|
||||
<label for="inputPassword" class="sr-only"></label>
|
||||
<input type="password" id="inputPassword" class="form-control" placeholder="密码" autocomplete="new-password" required>
|
||||
|
||||
<label for="inputPassword_" class="sr-only"></label>
|
||||
<input type="password" id="inputPassword_" class="form-control" placeholder="密码" autocomplete="new-password" required>
|
||||
|
||||
<div style="margin-bottom: 10px; text-align:right;">
|
||||
<button class="btn btn-sm btn-primary" type="submit" id="register_button">注册</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!--register Modal end-->
|
||||
|
||||
<!--pw_login Modal start-->
|
||||
<form>
|
||||
<div class="modal-body pw_login_group" style="display: none;height: 360px;">
|
||||
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
|
||||
<label for="userName_login" class="sr-only">用户名</label>
|
||||
<input type="text" id="userName_login" name="userName_login" class="form-control" placeholder="用户名" autocomplete="username" required autofocus>
|
||||
|
||||
<label for="inputPassword_login" class="sr-only">密码</label>
|
||||
<input type="password" id="inputPassword_login" name="inputPassword_login" class="form-control" placeholder="密码" autocomplete="current-password" required>
|
||||
|
||||
<div style="margin-bottom: 10px; text-align:right;">
|
||||
<button class="btn btn-sm btn-primary" id="login_button" type="button">登录</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!--pw_login Modal end-->
|
||||
|
||||
<div class="modal-footer">
|
||||
<!--<a class="nav-link active" href="#" id="s_login_a">
|
||||
<span data-feather="grid"></span>
|
||||
扫码登录
|
||||
</a>-->
|
||||
<a class="nav-link active" id="register_a" href="#">
|
||||
<span data-feather="check-circle"></span>
|
||||
用户注册
|
||||
</a>
|
||||
<a class="nav-link active" href="#" id="p_login_a">
|
||||
<span data-feather="smartphone"></span>
|
||||
用户名登录
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- login Modal end-->
|
||||
|
||||
<!-- new mind Modal start-->
|
||||
<div class="modal fade" id="newMindModal" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">新建</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!--modal-body start-->
|
||||
<form>
|
||||
<div class="modal-body">
|
||||
<label for="mindName" class="sr-only"></label>
|
||||
<input type="text" id="mindName" class="form-control" placeholder="思维导图名称" autocomplete="off" required autofocus>
|
||||
<div style="text-align:right;">
|
||||
<button type="button" class="btn btn-info" id="new_mind_btn">确认创建</button>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox" class="form-check-input" id="exampleCheck1">
|
||||
<label class="form-check-label" for="exampleCheck1">新建后打开</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!--modal-body end-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- new mind Modal end-->
|
||||
|
||||
<!-- share Modal start-->
|
||||
<div class="modal fade" id="share_mind_modal" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">分享成功</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!--modal-body start-->
|
||||
<div class="modal-body">请复制以下链接</div>
|
||||
<!--modal-body end-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- share Modal end-->
|
||||
|
||||
`
|
||||
$('body').append($(modal))
|
||||
@@ -0,0 +1 @@
|
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#FAFAFA;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 701 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 299 KiB |
@@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>测试 - layui</title>
|
||||
<link rel="stylesheet" href="layui/css/layui.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="layui-container">
|
||||
<div class="layui-progress" style="margin: 15px 0 30px;">
|
||||
<div class="layui-progress-bar" lay-percent="100%"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn" test-active="test-form">一个按钮</button>
|
||||
<button class="layui-btn layui-btn-normal" id="test2">当前日期</button>
|
||||
</div>
|
||||
|
||||
<blockquote class="layui-elem-quote" style="margin-top: 30px;">
|
||||
<div class="layui-text">
|
||||
<ul>
|
||||
<li>你当前预览的是:<span>layui-v<span id="version"></span></span></li>
|
||||
<li>layui 是一套开源的 Web UI(界面)组件库。这是一个极其简洁的演示页面</li>
|
||||
</ul>
|
||||
</div>
|
||||
</blockquote>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- 引入 layui.js 的 <script> 标签最好放置在 html 末尾 -->
|
||||
<script src="layui/layui.js"></script>
|
||||
<script>
|
||||
layui.use(function(){
|
||||
var layer = layui.layer
|
||||
,form = layui.form
|
||||
,laypage = layui.laypage
|
||||
,element = layui.element
|
||||
,laydate = layui.laydate
|
||||
,util = layui.util;
|
||||
|
||||
//欢迎信息
|
||||
layer.msg('Hello World');
|
||||
|
||||
//输出版本号
|
||||
lay('#version').html(layui.v);
|
||||
|
||||
//日期
|
||||
laydate.render({
|
||||
elem: '#test2'
|
||||
,value: new Date()
|
||||
,isInitValue: true
|
||||
});
|
||||
|
||||
//触发事件
|
||||
util.event('test-active', {
|
||||
'test-form': function(){
|
||||
layer.open({
|
||||
type: 1
|
||||
,resize: false
|
||||
,shadeClose: true
|
||||
,area: '350px'
|
||||
,title: 'layer + form'
|
||||
,content: ['<ul class="layui-form layui-form-pane" style="margin: 15px;">'
|
||||
,'<li class="layui-form-item">'
|
||||
,'<label class="layui-form-label">输入框</label>'
|
||||
,'<div class="layui-input-block">'
|
||||
,'<input class="layui-input" lay-verify="required" name="field1">'
|
||||
,'</div>'
|
||||
,'</li>'
|
||||
,'<li class="layui-form-item">'
|
||||
,'<label class="layui-form-label">选择框</label>'
|
||||
,'<div class="layui-input-block">'
|
||||
,'<select name="field2">'
|
||||
,'<option value="A">A</option>'
|
||||
,'<option value="B">B</option>'
|
||||
,'<select>'
|
||||
,'</div>'
|
||||
,'</li>'
|
||||
,'<li class="layui-form-item" style="text-align:center;">'
|
||||
,'<button type="submit" lay-submit lay-filter="*" class="layui-btn">提交</button>'
|
||||
,'</li>'
|
||||
,'</ul>'].join('')
|
||||
,success: function(layero, index){
|
||||
layero.find('.layui-layer-content').css('overflow', 'visible');
|
||||
|
||||
form.render().on('submit(*)', function(data){
|
||||
layer.msg(JSON.stringify(data.field), {icon: 1});
|
||||
//layer.close(index); //关闭层
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 6.3 KiB |