diff --git a/static/html/detail.html b/static/html/detail.html
index c75845b..2dce211 100644
--- a/static/html/detail.html
+++ b/static/html/detail.html
@@ -21,6 +21,7 @@
const fetch = function () {
this.jm = null
this.coop_mind_id = null
+ this.coop_mind_log_id = null
}
// prototype
fetch.prototype = {
@@ -37,13 +38,14 @@
loadMind: function () {
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
let id = {{ id }};
- this.coop_mind_id = id
const me = this
$.get('list?id=' + id, function (resp) {
// reset
me.destroy_coop_timer_if_necessary()
// show
let data = resp.data.snapshot_data
+ me.coop_mind_id = id
+ me.coop_mind_log_id = resp.data.snapshot_log_id
me.show_mind(resp.data.coop_mind_name, JSON.parse(data))
})
},
diff --git a/static/js/jsmind.coop.js b/static/js/jsmind.coop.js
index 95aa36b..ebda493 100644
--- a/static/js/jsmind.coop.js
+++ b/static/js/jsmind.coop.js
@@ -12,7 +12,7 @@
function jsMindCallBackFacade(type, body) {
const coop = $w.coop
if (coop) {
- coop.jsMindCallBack_(type, body)
+ coop.js_mind_callback_(type, body)
} else {
console.error('coop is undefined')
}
@@ -56,18 +56,16 @@
},
_init_properties: function (_jm) {
// 设置属性
+ this.client_id = Jm.util.uuid.newid()
this.coop_api_url = _jm.options.coop_api_url
this.coop_ws_url = _jm.options.coop_ws_url
- this.client_id = Jm.util.uuid.newid()
- const coop_mind_id = _jm.options.coop_mind_id
- if (this.notNull(coop_mind_id)) {
- this.coop_mind_id = coop_mind_id
- // this.timerFetch()
- }
+ 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 () {
- if (!this.web_socket) {
+ 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://开头
@@ -90,6 +88,8 @@
console.log('error');
this.web_socket = null
}
+ } else {
+ console.error('_init_ws failed,this.coop_mind_id is' + this.coop_mind_id)
}
},
// 清理定时任务
@@ -106,16 +106,16 @@
* 是否为空
* @param obj
*/
- notNull: function (obj) {
+ _not_null: function (obj) {
return obj !== null && obj !== undefined
},
- isNull: function (obj) {
- return !this.notNull(obj)
+ _is_null: function (obj) {
+ return !this._not_null(obj)
},
/**
* 构建公共参数
*/
- buildCommonParam: function () {
+ _build_evt_param: function () {
return {'client_id': this.client_id, 'log_uuid': Jm.util.uuid.newid()}
},
/**
@@ -130,36 +130,26 @@
* @param body
* @private
*/
- jsMindCallBack_: function (type, body) {
+ js_mind_callback_: function (type, body) {
const evt = body.evt
- const data = body.data
- const param = this.buildCommonParam()
- param.type = type
+ if (!!evt) {
+ const data = body.data
+ const param = this._build_evt_param()
- if (type === 1 || (evt && evt.length > 0)) {
- if (type === 1) {
- // 新建脑图
- param.name = data[0].meta.name
- } else if (this.notNull(evt) && evt.length > 0) {
- // 脑图编辑
- param.evt = evt
- param.data = data.join(';')
- param.node = body.node
- param.coop_mind_id = this.coop_mind_id
- }
- // ajax
- const me = this
- /*Jm.util.ajax.post(this.coop_api_url, param, function (resp) {
- if (type === 1) {
- // 新建
- me.coop_mind_id = resp.coop_mind_id
- // this.timerFetch()
- // this.timerPush()
- } else {
- // 操作
- me.coop_mind_log_id = resp.coop_mind_log_id
- }
- })*/
+ param.type = type
+ // 脑图编辑
+ param.evt = evt
+ param.data = data.join(';')
+ param.node = body.node
+ param.coop_mind_id = this.coop_mind_id
+ console.log(param)
+ }
+ },
+ _send_ws_message: function (msg) {
+ if (this.web_socket) {
+ this.web_socket.send(msg)
+ } else {
+ console.error('web_socket is not ready!')
}
},
/**
@@ -175,7 +165,7 @@
timerPush: function () {
// 把操作日志最大的data 持久化到数据库
const me = this
- if (this.isNull(me.timer_push_task)) {
+ 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_array').data),
diff --git a/static/js/jsmind.js b/static/js/jsmind.js
index 06b3b0c..9b51b3f 100644
--- a/static/js/jsmind.js
+++ b/static/js/jsmind.js
@@ -52,7 +52,7 @@
n.innerHTML = '';
n.appendChild(t);
} else {
- n.innerHTML = t.replaceAll('\n','
');
+ n.innerHTML = t.replaceAll('\n', '
');
}
};
// detect isElement
@@ -2564,7 +2564,7 @@
}
d.setAttribute('nodeid', node.id);
d.style.visibility = 'hidden';
- this._reset_node_custom_style(d, node.data);
+ this._reset_node_custom_style(node, d, node.data);
parent_node.appendChild(d);
view_data.element = d;
@@ -2826,10 +2826,10 @@
},
reset_node_custom_style: function (node) {
- this._reset_node_custom_style(node._data.view.element, node.data);
+ this._reset_node_custom_style(node, node._data.view.element, node.data);
},
- _reset_node_custom_style: function (node_element, node_data) {
+ _reset_node_custom_style: function (node, node_element, node_data) {
if ('background-color' in node_data) {
node_element.style.backgroundColor = node_data['background-color'];
}
@@ -2842,8 +2842,13 @@
if ('height' in node_data) {
node_element.style.height = node_data['height'] + 'px';
}
- if ('font-size' in node_data) {
+ /*if ('font-size' in node_data) {
node_element.style.fontSize = node_data['font-size'] + 'px';
+ }*/
+ if (node.isroot) {
+ node_element.style.backgroundColor = '#289f45'
+ } else {
+ node_element.style.fontSize = '12px';
}
if ('font-weight' in node_data) {
node_element.style.fontWeight = node_data['font-weight'];