-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser-mindmap.html
466 lines (388 loc) · 16.3 KB
/
user-mindmap.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Shortcut Icon" href="icon/s.ico">
<title>知识地图 - 秀知识</title>
<!-- Bootstrap -->
<link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/user-mindmap.css">
<link type="text/css" rel="stylesheet" href="jsmind-master/style/jsmind.css" />
<!-- font-awesome -->
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-2 a">
<div id="jsmind_nav">
<!-- 返回他人主页 -->
<button type="button" id="back"><a href="personal-page.html"><span class="glyphicon glyphicon-chevron-left"> </span> 返回</a></button>
<div class="map-like-and-collect-btn">
<button class="btn btn-lg btn-green like-btn"><span class="fa fa-heart fa-fw"></span>点赞</button>
<button class="btn btn-lg btn-green collect-btn"><span class="fa fa-bookmark fa-fw"></span>收藏</button>
</div>
<!-- mindmap简介 -->
<div class="intro">
<h4>地图简介:</h4>
<p>这里写知识地图的简介这里写知识地图的简介这里写知识地图的简介这里写知识地图的简介这里写知识地图的简介</p>
</div><!-- intro end -->
</div>
</div>
<div class="col-md-10 b">
<div id="jsmind_container">
</div>
<div style="display:none">
<input class="file" type="file" id="image-chooser" accept="image/*"/>
</div>
<!-- -->
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-3.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="js/edit-mindmap.js"></script>
<script src="js/user-mindmap.js"></script>
<!-- jsmind plugins -->
<script type="text/javascript" src="jsmind-master/js/jsmind.js"></script>
<script type="text/javascript" src="jsmind-master/js/jsmind.draggable.js"></script>
<script type="text/javascript" src="jsmind-master/js/jsmind.screenshot.js"></script>
<script>
var _jm = null;
function open_empty(){
var options = {
container:'jsmind_container',
theme:'greensea',
editable:true
}
_jm = jsMind.show(options);
// _jm = jsMind.show(options,mind);
}
function open_json(){
var mind = {
"meta":{
"name":"jsMind remote",
"author":"[email protected]",
"version":"0.2"
},
"format":"node_tree",
"data":{"id":"root","topic":"jsMind","children":[
{"id":"easy","topic":"Easy","direction":"left","children":[
{"id":"easy1","topic":"Easy to show"},
{"id":"easy2","topic":"Easy to edit"},
{"id":"easy3","topic":"Easy to store"},
{"id":"easy4","topic":"Easy to embed"},
{"id":"other3","background-image":"jsmind-master/example/ant.png", "width": "100", "height": "100"}
]},
{"id":"open","topic":"Open Source","direction":"right","children":[
{"id":"open1","topic":"on GitHub", "background-color":"#eee", "foreground-color":"blue"},
{"id":"open2","topic":"BSD License"}
]},
{"id":"powerful","topic":"Powerful","direction":"right","children":[
{"id":"powerful1","topic":"Base on Javascript"},
{"id":"powerful2","topic":"Base on HTML5"},
{"id":"powerful3","topic":"Depends on you"}
]},
{"id":"other","topic":"test node","direction":"left","children":[
{"id":"other1","topic":"I'm from local variable"},
{"id":"other2","topic":"I can do everything"}
]}
]}
}
_jm.show(mind);
}
function open_ajax(){
var mind_url = 'jsmind-master/example/data_example.json';
jsMind.util.ajax.get(mind_url,function(mind){
_jm.show(mind);
});
}
function screen_shot(){
_jm.screenshot.shootDownload();
}
function show_data(){
var mind_data = _jm.get_data();
var mind_string = jsMind.util.json.json2string(mind_data);
prompt_info(mind_string);
}
function save_file(){
var mind_data = _jm.get_data();
var mind_name = mind_data.meta.name;
var mind_str = jsMind.util.json.json2string(mind_data);
jsMind.util.file.save(mind_str,'text/jsmind',mind_name+'.jm');
}
function open_file(){
var file_input = document.getElementById('file_input');
var files = file_input.files;
if(files.length > 0){
var file_data = files[0];
jsMind.util.file.read(file_data,function(jsmind_data, jsmind_name){
var mind = jsMind.util.json.string2json(jsmind_data);
if(!!mind){
_jm.show(mind);
}else{
prompt_info('can not open this file as mindmap');
}
});
}else{
prompt_info('please choose a file first')
}
}
function select_node(){
var nodeid = 'other';
_jm.select_node(nodeid);
}
function show_selected(){
var selected_node = _jm.get_selected_node();
if(!!selected_node){
prompt_info(selected_node.topic);
}else{
prompt_info('nothing');
}
}
function get_selected_nodeid(){
var selected_node = _jm.get_selected_node();
if(!!selected_node){
return selected_node.id;
}else{
return null;
}
}
function add_node(){
var selected_node = _jm.get_selected_node(); // as parent of new node
if(!selected_node){prompt_info('请首先选择一个节点');return;}
var nodeid = jsMind.util.uuid.newid();
var topic = '* Node_'+nodeid.substr(0,5)+' *';
var node = _jm.add_node(selected_node, nodeid, topic);
}
var imageChooser = document.getElementById('image-chooser');
imageChooser.addEventListener('change', function (event) {
// Read file here.
var reader = new FileReader();
reader.onloadend = (function () {
var selected_node = _jm.get_selected_node();
var nodeid = jsMind.util.uuid.newid();
var topic = undefined;
var data = {
"background-image": reader.result,
"width": "100",
"height": "100"};
var node = _jm.add_node(selected_node, nodeid, topic, data);
//var node = _jm.add_image_node(selected_node, nodeid, reader.result, 100, 100);
//add_image_node:function(parent_node, nodeid, image, width, height, data, idx, direction, expanded){
});
var file = imageChooser.files[0];
if (file) {
reader.readAsDataURL(file);
};
}, false);
function add_image_node(){
var selected_node = _jm.get_selected_node(); // as parent of new node
if(!selected_node){
prompt_info('请首先选择一个节点');
return;
}
imageChooser.focus();
imageChooser.click();
}
function modify_node(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
// modify the topic
_jm.update_node(selected_id, '--- modified ---');
}
function move_to_first(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.move_node(selected_id,'_first_');
}
function move_to_last(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.move_node(selected_id,'_last_');
}
function move_node(){
// move a node before another
_jm.move_node('other','open');
}
function remove_node(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.remove_node(selected_id);
}
function change_text_font(){
var selected_id = get_selected_nodeid();
var fontSize = document.getElementById("font-size-num").value;
console.log(typeof fontSize);
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.set_node_font_style(selected_id, parseInt(fontSize));
}
var fontColor;
function change_text_color(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
if (fontColor!="#000") fontColor = "#000";
else fontColor = "#FFF";
_jm.set_node_color(selected_id, null, fontColor);
}
var backgroundColor;
function change_background_color(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.set_node_color(selected_id, '#eee', null);
}
function change_background_image(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.set_node_background_image(selected_id, 'jsmind-master/example/ant.png', 100, 100);
}
function set_theme(theme_name){
_jm.set_theme(theme_name);
}
var zoomInButton = document.getElementById("zoom-in-button");
var zoomOutButton = document.getElementById("zoom-out-button");
function zoomIn() {
if (_jm.view.zoomIn()) {
zoomOutButton.disabled = false;
} else {
zoomInButton.disabled = true;
};
};
function zoomOut() {
if (_jm.view.zoomOut()) {
zoomInButton.disabled = false;
} else {
zoomOutButton.disabled = true;
};
};
function toggle_editable(btn){
var editable = _jm.get_editable();
if(editable){
_jm.disable_edit();
btn.innerHTML = '开启编辑模式';
}else{
_jm.enable_edit();
btn.innerHTML = '关闭编辑模式';
}
}
// this method change size of container, perpare for adjusting jsmind
function change_container(){
var c = document.getElementById('jsmind_container');
c.style.width = '800px';
c.style.height = '500px';
}
function resize_jsmind(){
_jm.resize();
}
function expand(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.expand_node(selected_id);
}
function collapse(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.collapse_node(selected_id);
}
function toggle(){
var selected_id = get_selected_nodeid();
if(!selected_id){prompt_info('请首先选择一个节点');return;}
_jm.toggle_node(selected_id);
}
function expand_all(){
_jm.expand_all();
}
function expand_to_level2(){
_jm.expand_to_depth(2);
}
function expand_to_level3(){
_jm.expand_to_depth(3);
}
function collapse_all(){
_jm.collapse_all();
}
function get_nodearray_data(){
var mind_data = _jm.get_data('node_array');
var mind_string = jsMind.util.json.json2string(mind_data);
prompt_info(mind_string);
}
function save_nodearray_file(){
var mind_data = _jm.get_data('node_array');
var mind_name = mind_data.meta.name;
var mind_str = jsMind.util.json.json2string(mind_data);
jsMind.util.file.save(mind_str,'text/jsmind',mind_name+'.jm');
}
function open_nodearray(){
var file_input = document.getElementById('file_input_nodearray');
var files = file_input.files;
if(files.length > 0){
var file_data = files[0];
jsMind.util.file.read(file_data,function(jsmind_data, jsmind_name){
var mind = jsMind.util.json.string2json(jsmind_data);
if(!!mind){
_jm.show(mind);
}else{
prompt_info('can not open this file as mindmap');
}
});
}else{
prompt_info('please choose a file first')
}
}
function get_freemind_data(){
var mind_data = _jm.get_data('freemind');
var mind_string = jsMind.util.json.json2string(mind_data);
alert(mind_string);
}
function save_freemind_file(){
var mind_data = _jm.get_data('freemind');
var mind_name = mind_data.meta.name || 'freemind';
var mind_str = mind_data.data;
jsMind.util.file.save(mind_str,'text/xml',mind_name+'.mm');
}
function open_freemind(){
var file_input = document.getElementById('file_input_freemind');
var files = file_input.files;
if(files.length > 0){
var file_data = files[0];
jsMind.util.file.read(file_data, function(freemind_data, freemind_name){
if(freemind_data){
var mind_name = freemind_name;
if(/.*\.mm$/.test(mind_name)){
mind_name = freemind_name.substring(0,freemind_name.length-3);
}
var mind = {
"meta":{
"name":mind_name,
"author":"[email protected]",
"version":"1.0.1"
},
"format":"freemind",
"data":freemind_data
};
_jm.show(mind);
}else{
prompt_info('can not open this file as mindmap');
}
});
}else{
prompt_info('please choose a file first')
}
}
function prompt_info(msg){
alert(msg);
}
open_empty();
</script>
</body>
</html>