webEditor.jsp
13.8 KB
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
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="com.weaver.formmodel.mobile.utils.MobileCommonUtil"%>
<%@ include file="/mobilemode/admin/init.jsp"%>
<%
String theme = "";
Cookie[] cookies = request.getCookies();
for(int i = 0; cookies != null && i < cookies.length; i++){
Cookie c = cookies[i];
if(c != null && "webeditor_theme".equals(c.getName())){
theme = Util.null2String(c.getValue());
}
}
if(theme.equals("")){theme = "light";}
String mode = Util.null2String(request.getParameter("mode"), "run");
%>
<html>
<head>
<title>Web Editor</title>
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" href="/mobilemode/admin/src/common/css/common.css">
<link type="text/css" rel="stylesheet" href="/mobilemode/admin/src/webEditor/webEditor.css">
</head>
<body class="<%=theme%>">
<div id="main-container" class="mode-<%=mode%>">
<div id="code-container">
<div id="box-html" class="split editor-wrapper">
<div class="editor-header" data-index="0">
<div class="config">HTML</div>
</div>
<div id="html-editor" data-type="html" class="editor-self"></div>
</div>
<div id="box-css" class="split editor-wrapper">
<div class="editor-header" data-index="1">
<div class="config">CSS</div>
<div class="help">?</div>
</div>
<div id="css-editor" data-type="css" class="editor-self"></div>
</div>
<div id="box-javascript" class="split editor-wrapper">
<div class="editor-header" data-index="2">
<div class="config">JavaScript</div>
</div>
<div id="javascript-editor" data-type="javascript" class="editor-self"></div>
</div>
</div>
<div id="result-container">
<div class="iphone">
<div class="header">
<span class="camera"></span>
<!-- 传感器 -->
<span class="sensor"></span>
<span class="speaker"></span>
</div>
<div class="buttons power-button"></div>
<div class="buttons voice-toogle"></div>
<div class="buttons voice-plus"></div>
<div class="buttons voice-minus"></div>
<div class="screen">
<iframe id="preview-frame" class="empty"></iframe>
</div>
<div class="home-button"><span></span></div>
</div>
</div>
<div id="settings-container">
<div id="settings-tabs-title">
<ul>
<li data-href="settings-html">HTML</li>
<li data-href="settings-css">CSS</li>
<li data-href="settings-javascript">JavaScript</li>
<li data-href="settings-behavior" style="display: none;">Behavior</li>
</ul>
</div>
<div id="settings-tabs-content">
<div id="settings-html">
<form name="settings-form">
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385700,user.getLanguage(),"HTML预处理器")%>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385701,user.getLanguage()," HTML预处理器可以使编写html更方便。例如,你可以在HTML中使用Markdown标记语言,选择对应的预处理器即可。 ")%>">?</div>
</div>
<div class="field-content">
<select class="form-control" id="htmlPreprocessor">
<option value="none">None</option>
<option value="markdown">Markdown</option>
</select>
</div>
<div class="field-label">
DOCTYPE
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385702,user.getLanguage(),"文档类型,此处选择的文档类型将直接应用于生成的html中。")%>">?</div>
</div>
<div class="field-content">
<select class="form-control" id="htmlDoctype">
<option value="XHTML 1.0 Strict">XHTML 1.0 Strict</option>
<option value="XHTML 1.0 Transitional">XHTML 1.0 Transitional</option>
<option value="HTML 4.01 Strict">HTML 4.01 Strict</option>
<option value="HTML 4.01 Transitional">HTML 4.01 Transitional</option>
<option value="HTML 4.01 Frameset">HTML 4.01 Frameset</option>
<option value="HTML 5" selected="selected">HTML 5</option>
</select>
</div>
<div class="field-label">
Stuff for <head>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385703,user.getLanguage(),"此处填写的内容会直接嵌入在head标签中。")%>">?</div>
</div>
<div class="field-content">
<textarea id="htmlStuffForHead" class="area-control" placeholder="e.g. <meta>, <link>, <script>"></textarea>
</div>
</form>
</div>
<div id="settings-css">
<form name="settings-form">
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385704,user.getLanguage()," CSS预处理器")%>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385705,user.getLanguage(),"CSS预处理器可以处理传统css之外的写法,例如,LESS或SCSS,选择对应的预处理器即可。")%>">?</div>
</div>
<div class="field-content">
<select class="form-control" id="cssPreprocessor">
<option value="none">None</option>
<option value="less">LESS</option>
<option value="scss">SCSS</option>
<option value="sass">Sass</option>
</select>
</div>
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385706,user.getLanguage(),"浏览器兼容性")%>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385707,user.getLanguage()," 为了获得最好的跨浏览器支持,在特定的CSS属性和值前面增加前缀是常见的做法。例如,-webkit- or -moz-。 ")%>">?</div>
</div>
<div class="field-content">
<select class="form-control" id="cssAutoprefixer">
<option value="0"><%=MobileCommonUtil.getHtmlLabelName(385708,user.getLanguage(),"不做兼容性处理")%></option>
<option value="1"><%=MobileCommonUtil.getHtmlLabelName(385709,user.getLanguage(),"自动加前缀")%></option>
</select>
</div>
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385710,user.getLanguage()," 添加外部CSS")%>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385711,user.getLanguage(),"这些样式将会按照显示顺序依次添加在页面上(在编辑器里写的css代码之前)。")%>">?</div>
</div>
<div class="field-content">
<table id="css-resource-table" class="settings-table">
<tbody>
<tr>
<td width="18px" align="left" class="bemove"></td>
<td width="412px"><input type="text" name="externalCss" value="" class="form-control" placeholder="http://yourwebsite.com/style.css"></td>
<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
</tr>
<tr>
<td width="18px" align="left" class="bemove"></td>
<td width="412px"><input type="text" name="externalCss" value="" class="form-control" placeholder="http://yourwebsite.com/style.css"></td>
<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
</tr>
</tbody>
</table>
<div class="external-resource-actions">
<%=MobileCommonUtil.getHtmlLabelName(385712,user.getLanguage()," 快速添加:")%>
<select class="form-control quick-add-select" data-for="css-resource-table">
<option value="">---</option>
<option value="/mobilemode/mobile/dist/css/mobilemode_wev8.css">Mobilemode</option>
<option value="/mobilemode/mobile/dist/css/lib/mobilebone/mobilebone_wev8.css">Mobilebone</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css">Bootstrap 4</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">Bootstrap 3</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.0/css/foundation.min.css">Foundation</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">Animate.css</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css">Materialize</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4.2/css/bulma.min.css">Bulma</option>
</select>
<div class="add-resource" data-for="css-resource-table">+<%=MobileCommonUtil.getHtmlLabelName(384113,user.getLanguage(),"添加")%></div>
</div>
</div>
</form>
</div>
<div id="settings-javascript">
<form name="settings-form">
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385713,user.getLanguage(),"JavaScript预处理器")%>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385714,user.getLanguage(),"JavaScript预处理器可以处理传统js之外的写法,例如,CoffeeScript或LiveScript,选择对应的预处理器即可。")%>">?</div>
</div>
<div class="field-content">
<select class="form-control" id="jsPreprocessor">
<option value="none">None</option>
<option value="coffeescript">CoffeeScript</option>
<option value="livescript">LiveScript</option>
<option value="typescript">TypeScript</option>
<option value="babel">Babel</option>
</select>
</div>
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385715,user.getLanguage()," 添加外部JavaScript")%>
<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385716,user.getLanguage(),"这些脚本将会按照显示顺序依次添加在页面上(在编辑器里写的JavaScript代码之前)。")%>">?</div>
</div>
<div class="field-content">
<table id="javascript-resource-table" class="settings-table">
<tbody>
<tr>
<td width="18px" align="left" class="bemove"></td>
<td width="412px"><input type="text" name="externalJS" value="" class="form-control" placeholder="http://yourwebsite.com/script.js"></td>
<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
</tr>
<tr>
<td width="18px" align="left" class="bemove"></td>
<td width="412px"><input type="text" name="externalJS" value="" class="form-control" placeholder="http://yourwebsite.com/script.js"></td>
<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
</tr>
</tbody>
</table>
<div class="external-resource-actions">
<%=MobileCommonUtil.getHtmlLabelName(385712,user.getLanguage()," 快速添加:")%>
<select class="form-control quick-add-select" data-for="javascript-resource-table">
<option value="">---</option>
<option value="/mobilemode/mobile/dist/js/lib/require/require.min_wev8.js">Mobilemode.require</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">jQuery</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js">jQuery UI</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js">Zepto</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js">React</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js">React DOM</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js">Angular</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js">Backbone</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js">Bootstrap 3</option>
<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js">Bootstrap 4</option>
</select>
<div class="add-resource" data-for="javascript-resource-table">+<%=MobileCommonUtil.getHtmlLabelName(384113,user.getLanguage(),"添加")%></div>
</div>
</div>
</form>
</div>
<div id="settings-behavior">
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385652,user.getLanguage()," 代码缩进")%>
</div>
<div class="field-content">
<input type="range" min="1" max="6" id="behaviorTabSize" value="4" list="tab-width-options">
<datalist id="tab-width-options">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</datalist>
</div>
<div class="field-label">
<%=MobileCommonUtil.getHtmlLabelName(385654,user.getLanguage(),"自动更新预览")%>
</div>
<div class="field-content">
<input type="checkbox" id="behaviorAutoRun" checked="checked"/><span style="top: 0px;"><%=MobileCommonUtil.getHtmlLabelName(31676,user.getLanguage(),"启用")%></span>
<div class="field-checkbox-desc"><%=MobileCommonUtil.getHtmlLabelName(385717,user.getLanguage(),"如果启用,预览面板会自动更新为您的代码。如果禁用,请使用“运行”按钮更新。")%></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var _mode = "<%=mode%>";
requirejs.config({
paths: {
'webEditor': './webEditor/webEditor',
'parser': './webEditor/parser/parser',
'parser/html': './webEditor/parser/html',
'parser/css': './webEditor/parser/css',
'parser/js': './webEditor/parser/javascript',
'parser/preprocessor': './webEditor/parser/preprocessor'
}
});
window.onEditorLoad = function() {}; // 供顶层父页面重写
require(["webEditor"], function (CodeEditor) {
window.codeEditor = new CodeEditor();
window.onEditorLoad(window.codeEditor);
});
</script>
</body>
</html>