-
Notifications
You must be signed in to change notification settings - Fork 99
/
index.html
169 lines (156 loc) · 7.76 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>webchart--时序图</title>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="Keywords" content="在线时序图, 在线流程图, webchart, webflow, 免费在线作图工具, 代码作图, 代码绘制, 时序图, 流程图, 代码绘制流程图, 代码绘制时序图">
<meta name="description" content="webchart提供免费在线制作时序图,流程图,使用简单的描述代码绘制图形,方便快捷,易于修改、分享" />
<link href="css/style.css" rel="stylesheet"/>
<link rel="stylesheet" type="text/css" href="css/sequence-diagram-min.css" media="screen" />
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/webfont/1.6.6/webfontloader.js"></script>
<script src="https://cdn.bootcss.com/snap.svg/0.5.1/snap.svg-min.js"></script>
<script src="https://cdn.bootcss.com/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdn.bootcss.com/ace/1.2.6/ace.js"></script>
<script src="jslib/svginnerhtml.min.js"></script>
<script src="jslib/sequence-diagram-min.js"></script>
</head>
<body>
<div id="main">
<div class="tab">
<label class="logo">Web Chart</label>
<a class="active" href="index.html">时序图</a>
<a href="flow.html">流程图</a>
</div>
<section id="demo">
<table align="center" class="inner">
<tr>
<td width="500">
<div class="toolbar">
<div class="left">
主题:
<select class="theme">
<option value="simple" selected>默认</option>
<option value="hand">手绘</option>
</select>
</div>
<div class="right">
<a href="#" class="download">下载图片</a>
| <a href="#" class="case">示例</a>
| <a href="https://bramp.github.io/js-sequence-diagrams" target="_blank">帮助</a>
| <a href="https://github.com/huhai463127310/webchart/issues/new" target="_blank">反馈</a>
</div>
</div>
<div class="editor-wrapper">
<div class="editor">Andrew->China: Says Hello
Note right of China: China thinks\nabout it
China-->Andrew: How are you?
Andrew->>China: I am good thanks!</div>
</div>
</td>
<td class="diagram">This should be a diagram! If you don't see it you need Javascript enabled</td>
</tr>
</table>
</section>
</div>
<a href="https://github.com/huhai463127310/webchart"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<script>
$(function() {
var code_default ='Andrew->China: Says Hello\n'+
'Note right of China: China thinks\\nabout it' +'\n'+
'China-->Andrew: How are you?\n'+
'Andrew->>China: I am good thanks!';
function setup_editor(div) {
var editor_div = div.find(".editor");
var diagram_div = div.find(".diagram");
var theme_div = div.find(".theme");
var download_link = div.find('.download');
// Setup the editor diagram
var editor = ace.edit(editor_div.get(0));
editor.$blockScrolling = Infinity;
editor.setTheme("ace/theme/crimson_editor");
editor.getSession().setMode("ace/mode/asciidoc");
editor.getSession().on('change', _.debounce(on_change, 100));
loadData(editor);
$('.case').click({editor:editor},resetData);
download_link.click(function(ev) {
var svg = diagram_div.find('svg')[0];
var width = parseInt(svg.width.baseVal.value);
var height = parseInt(svg.height.baseVal.value);
var data = editor.getValue();
var xml = '<?xml version="1.0" encoding="utf-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"><svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '" xmlns:xlink="http://www.w3.org/1999/xlink"><source><![CDATA[' + data + ']]></source>' + svg.innerHTML + '</svg>';
var a = $(this);
a.attr("download", "sequence_diagram.svg"); // TODO I could put title here
a.attr("href", "data:image/svg+xml," + encodeURIComponent(xml));
});
theme_div.change(on_change);
on_change();
function on_change() {
try {
var diagram = Diagram.parse(editor.getValue());
editor.getSession().setAnnotations([]);
saveData(editor);
// Clear out old diagram
diagram_div.html('');
var options = {
theme: theme_div.val(),
scale: 1
};
// Draw
diagram.drawSVG(diagram_div.get(0), options);
} catch (err) {
var annotation = {
type: "error", // also warning and information
column: 0,
row: 0,
text: err.message
};
if (err instanceof Diagram.ParseError) {
annotation.row = err.loc.first_line - 1;
annotation.column = err.loc.first_column;
}
editor.getSession().setAnnotations([annotation]);
throw err;
}
}
}
setup_editor($('#demo'));
function loadData (editor){
var data =localStorage.getItem('code_seq');
if(data && data!==''){
editor.setValue(data);
editor.gotoLine(1);
}
}
function saveData (editor){
var code = editor.getValue();
if( code!=='' && code!==code_default){
localStorage.setItem('code_seq',code);
}
}
function resetData (event){
var init_default =event.data.editor.getValue();
if(init_default !== code_default){
var result = confirm('提示:示例代码将覆盖现有代码,刷新页面即可恢复。确认继续?');
if(result){
event.data.editor.setValue(code_default);
event.data.editor.gotoLine(1);
}
}
}
});
</script>
<!--百度统计-->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?6170e1119afef70fda29a507d082b10f";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>