style
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
const fetch = function () {
|
const fetch = function () {
|
||||||
this.jm = null
|
this.jm = null
|
||||||
this.coop_mind_id = null
|
this.coop_mind_id = null
|
||||||
|
this.coop_mind_log_id = null
|
||||||
}
|
}
|
||||||
// prototype
|
// prototype
|
||||||
fetch.prototype = {
|
fetch.prototype = {
|
||||||
@@ -37,13 +38,14 @@
|
|||||||
loadMind: function () {
|
loadMind: function () {
|
||||||
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
||||||
let id = {{ id }};
|
let id = {{ id }};
|
||||||
this.coop_mind_id = id
|
|
||||||
const me = this
|
const me = this
|
||||||
$.get('list?id=' + id, function (resp) {
|
$.get('list?id=' + id, function (resp) {
|
||||||
// reset
|
// reset
|
||||||
me.destroy_coop_timer_if_necessary()
|
me.destroy_coop_timer_if_necessary()
|
||||||
// show
|
// show
|
||||||
let data = resp.data.snapshot_data
|
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))
|
me.show_mind(resp.data.coop_mind_name, JSON.parse(data))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
+31
-41
@@ -12,7 +12,7 @@
|
|||||||
function jsMindCallBackFacade(type, body) {
|
function jsMindCallBackFacade(type, body) {
|
||||||
const coop = $w.coop
|
const coop = $w.coop
|
||||||
if (coop) {
|
if (coop) {
|
||||||
coop.jsMindCallBack_(type, body)
|
coop.js_mind_callback_(type, body)
|
||||||
} else {
|
} else {
|
||||||
console.error('coop is undefined')
|
console.error('coop is undefined')
|
||||||
}
|
}
|
||||||
@@ -56,18 +56,16 @@
|
|||||||
},
|
},
|
||||||
_init_properties: function (_jm) {
|
_init_properties: function (_jm) {
|
||||||
// 设置属性
|
// 设置属性
|
||||||
|
this.client_id = Jm.util.uuid.newid()
|
||||||
this.coop_api_url = _jm.options.coop_api_url
|
this.coop_api_url = _jm.options.coop_api_url
|
||||||
this.coop_ws_url = _jm.options.coop_ws_url
|
this.coop_ws_url = _jm.options.coop_ws_url
|
||||||
this.client_id = Jm.util.uuid.newid()
|
this.coop_mind_id = _jm.options.coop_mind_id
|
||||||
const coop_mind_id = _jm.options.coop_mind_id
|
this.coop_mind_log_id = _jm.options.coop_mind_log_id
|
||||||
if (this.notNull(coop_mind_id)) {
|
this.coop_mind_log_last_id = _jm.options.coop_mind_log_id
|
||||||
this.coop_mind_id = coop_mind_id
|
|
||||||
// this.timerFetch()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// 初始化websocket
|
// 初始化websocket
|
||||||
_init_ws: function () {
|
_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)
|
const ws = new WebSocket(this.coop_ws_url + '?_' + this.coop_mind_id)
|
||||||
this.web_socket = ws
|
this.web_socket = ws
|
||||||
//申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
|
//申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
|
||||||
@@ -90,6 +88,8 @@
|
|||||||
console.log('error');
|
console.log('error');
|
||||||
this.web_socket = null
|
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
|
* @param obj
|
||||||
*/
|
*/
|
||||||
notNull: function (obj) {
|
_not_null: function (obj) {
|
||||||
return obj !== null && obj !== undefined
|
return obj !== null && obj !== undefined
|
||||||
},
|
},
|
||||||
isNull: function (obj) {
|
_is_null: function (obj) {
|
||||||
return !this.notNull(obj)
|
return !this._not_null(obj)
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 构建公共参数
|
* 构建公共参数
|
||||||
*/
|
*/
|
||||||
buildCommonParam: function () {
|
_build_evt_param: function () {
|
||||||
return {'client_id': this.client_id, 'log_uuid': Jm.util.uuid.newid()}
|
return {'client_id': this.client_id, 'log_uuid': Jm.util.uuid.newid()}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -130,36 +130,26 @@
|
|||||||
* @param body
|
* @param body
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
jsMindCallBack_: function (type, body) {
|
js_mind_callback_: function (type, body) {
|
||||||
const evt = body.evt
|
const evt = body.evt
|
||||||
const data = body.data
|
if (!!evt) {
|
||||||
const param = this.buildCommonParam()
|
const data = body.data
|
||||||
param.type = type
|
const param = this._build_evt_param()
|
||||||
|
|
||||||
if (type === 1 || (evt && evt.length > 0)) {
|
param.type = type
|
||||||
if (type === 1) {
|
// 脑图编辑
|
||||||
// 新建脑图
|
param.evt = evt
|
||||||
param.name = data[0].meta.name
|
param.data = data.join(';')
|
||||||
} else if (this.notNull(evt) && evt.length > 0) {
|
param.node = body.node
|
||||||
// 脑图编辑
|
param.coop_mind_id = this.coop_mind_id
|
||||||
param.evt = evt
|
console.log(param)
|
||||||
param.data = data.join(';')
|
}
|
||||||
param.node = body.node
|
},
|
||||||
param.coop_mind_id = this.coop_mind_id
|
_send_ws_message: function (msg) {
|
||||||
}
|
if (this.web_socket) {
|
||||||
// ajax
|
this.web_socket.send(msg)
|
||||||
const me = this
|
} else {
|
||||||
/*Jm.util.ajax.post(this.coop_api_url, param, function (resp) {
|
console.error('web_socket is not ready!')
|
||||||
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
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -175,7 +165,7 @@
|
|||||||
timerPush: function () {
|
timerPush: function () {
|
||||||
// 把操作日志最大的data 持久化到数据库
|
// 把操作日志最大的data 持久化到数据库
|
||||||
const me = this
|
const me = this
|
||||||
if (this.isNull(me.timer_push_task)) {
|
if (this._is_null(me.timer_push_task)) {
|
||||||
me.timer_push_task = setInterval(function () {
|
me.timer_push_task = setInterval(function () {
|
||||||
const param = {
|
const param = {
|
||||||
'data': Jm.util.json.json2string(me._jm.get_data('node_array').data),
|
'data': Jm.util.json.json2string(me._jm.get_data('node_array').data),
|
||||||
|
|||||||
+10
-5
@@ -52,7 +52,7 @@
|
|||||||
n.innerHTML = '';
|
n.innerHTML = '';
|
||||||
n.appendChild(t);
|
n.appendChild(t);
|
||||||
} else {
|
} else {
|
||||||
n.innerHTML = t.replaceAll('\n','<br>');
|
n.innerHTML = t.replaceAll('\n', '<br>');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// detect isElement
|
// detect isElement
|
||||||
@@ -2564,7 +2564,7 @@
|
|||||||
}
|
}
|
||||||
d.setAttribute('nodeid', node.id);
|
d.setAttribute('nodeid', node.id);
|
||||||
d.style.visibility = 'hidden';
|
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);
|
parent_node.appendChild(d);
|
||||||
view_data.element = d;
|
view_data.element = d;
|
||||||
@@ -2826,10 +2826,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset_node_custom_style: function (node) {
|
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) {
|
if ('background-color' in node_data) {
|
||||||
node_element.style.backgroundColor = node_data['background-color'];
|
node_element.style.backgroundColor = node_data['background-color'];
|
||||||
}
|
}
|
||||||
@@ -2842,8 +2842,13 @@
|
|||||||
if ('height' in node_data) {
|
if ('height' in node_data) {
|
||||||
node_element.style.height = node_data['height'] + 'px';
|
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';
|
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) {
|
if ('font-weight' in node_data) {
|
||||||
node_element.style.fontWeight = node_data['font-weight'];
|
node_element.style.fontWeight = node_data['font-weight'];
|
||||||
|
|||||||
Reference in New Issue
Block a user