-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd.html
More file actions
468 lines (438 loc) · 15.1 KB
/
add.html
File metadata and controls
468 lines (438 loc) · 15.1 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
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
467
468
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link href="css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../css/app.css" />
<link href="css/mui.picker.min.css" rel="stylesheet" />
<style>
html,
body,
.mui-content {
height: 0px;
margin: 0px;
background-color: #efeff4;
}
h5.mui-content-padded {
margin-left: 3px;
margin-top: 20px !important;
}
h5.mui-content-padded:first-child {
margin-top: 12px !important;
}
.ui-alert {
text-align: center;
padding: 20px 10px;
font-size: 16px;
}
* {
-webkit-touch-callout: none;
-webkit-user-select: none;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">添加</h1>
</header>
<div class="mui-content">
<div class="mui-card">
<ul class="mui-table-view">
<li class="mui-table-view-cell mui-collapse mui-active">
<a class="mui-navigate-right " href="#">添加日程</a>
<div class="mui-collapse-content">
<a href="ttst.html"></a>
<!--<form class="mui-input-group">-->
<div class="mui-input-row">
<label>标题</label>
<input type="text" id = "rTitle" class=" mui-input-speech mui-input-clear" placeholder="输入日程标题">
</div>
<div class="mui-input-row">
<label>标签Tag</label>
<input type="text" id = "rTag" class="mui-input-clear" placeholder="输入日程标签 Tag">
</div>
<div class="mui-input-row">
<label>开始时间</label>
<label id="result" style="width: auto;"> </label>
<button id='demo1' data-options='{}' class="btn mui-btn">⏱</button>
</div>
<div class="mui-input-row">
<label>结束时间</label>
<label id="result1" style="width: auto;"> </label>
<button id='demo1' data-options='{}' class="btn1 mui-btn">⏱</button>
</div>
<div class="mui-input-row">
<label>提醒时间</label>
<label id="result2" style="width: auto;"> </label>
<button id='demo1' data-options='{}' class="btn2 mui-btn">⏱</button>
</div>
<div class="mui-input-row" style="margin: 10px 5px; height: auto;">
<textarea id="Remindtextarea" rows="7" placeholder="提醒内容" class="mui-input-speech mui-input-clear"></textarea>
</div>
<div class="mui-button-row">
<button class="mui-btn mui-btn-primary" type="button" onclick="addRemind()">确认</button>
<!--<button class="mui-btn mui-btn-primary" type="button" onclick="return false;">取消</button>-->
</div>
<!--</form>-->
</div>
</li>
<li class="mui-table-view-cell mui-collapse">
<a class="mui-navigate-right" href="#">添加笔记</a>
<div class="mui-collapse-content">
<!-- <div class="mui-input-group">
--> <div class="mui-input-row">
<label>标题</label>
<input type="text" id = "nTitle" class=" mui-input-speech mui-input-clear" placeholder="输入日程标题">
</div>
<div class="mui-input-row">
<label>标签Tag</label>
<input type="text" id = "nTag" class="mui-input-clear" placeholder="输入日程标签 Tag">
</div>
<div class="mui-input-row" style="margin: 10px 5px; height: auto;">
<textarea id="Notetextarea" rows="9" placeholder="笔记内容" class="mui-input-speech mui-input-clear"></textarea>
</div>
<div class="mui-input-row" style="margin: 10px 5px; height: auto;">
<form method="post" action="http://up.qiniu.com/" enctype="multipart/form-data" target="nm_iframe">
<input type="hidden" name="token" value="c0wWABqs6HQWZFcnVwXWGAo3_lAUOEkucASPdQq7:ZC7taNYt9L3imZ7SIXRwZQ_BlGE=:eyJzY29wZSI6InBob3RvIiwiZGVhZGxpbmUiOjE1NDYyNzU2NjF9">
OCR 图片识别<br/><input id="uuu" type="file" name="file" style="width:250px";>
<input style="float: right; height: 30px; font-size: 15px;" type="submit" value="↑" onclick="sss()"/>
</form>
</div>
<div class="mui-button-row" style="margin: 10px 5px; height: auto;">
<button class="mui-btn mui-btn-primary" type="button" onclick="Tocr()">OCR</button>
<button class="mui-btn mui-btn-primary" type="button" onclick="addNote()">添加</button>
</div>
<!--</div>-->
</div>
</li>
</ul>
</div>
<iframe id="id_iframe" name="nm_iframe" style="display: none;" ></iframe>
</div>
<script src="js/mui.min.js"></script>
<script src="js/mui.picker.min.js"></script>
<script type="text/javascript">
mui.init({
//swipeBack:true //启用右滑关闭功能
});
function sss()
{
var tuu =document.getElementById("uuu").value;
if(tuu !== "")
{
plus.nativeUI.toast('正在上传……!~');
}
else
{
plus.nativeUI.toast('你没有选择图片啊!~');
}
}
//ocr 模块
function Tocr(){
//plus.nativeUI.toast('ocr~');
var path = window.frames["nm_iframe"].document.getElementsByTagName("pre")[0].innerHTML;
console.log(path);
//转为 json 对象取值
var oPath = JSON.parse(path);
//输出 key
var dPath = oPath['hash'];
console.log(dPath);
if(dPath == "Fto5o-5ea0sNMlW_75VgGJCv2AcJ")
{
plus.nativeUI.toast('换张图片试试?~');
}
else {
//拼接字符串,发送请求
var durl= "http://oi4ty6vxc.bkt.clouddn.com/"+ dPath;
console.log(durl);
//发送请求
var xhr = new plus.net.XMLHttpRequest();
//预处理请求
xhr.open("POST", "http://dstantside.com/Sdnote/api/Sdnote/orcapi");
plus.nativeUI.toast("请求处理中……请耐心等待!~");
//处理值
var user = {};
var attr1 = "Token";
var attr2 = "url";
user[attr1] = plus.storage.getItem('uToken');
user[attr2] = durl;
xhr.setRequestHeader('Content-Type','application/json');
xhr.send(user);
xhr.onreadystatechange = function (){
if ( xhr.status == 200 ) {
console.log("xhr请求成功:"+xhr.responseText);
//格式化获取的值
var oText = eval('('+xhr.responseText+')');
var re = eval('oText.'+'Results');
var uState = eval('oText.'+'State')
console.log(uState);
var Drea = re;
if (Drea == "")
{
plus.nativeUI.toast('处理异常,请重试或手动录入!~');
}
else
{
plus.nativeUI.toast("处理成功!~");
document.getElementById("Notetextarea").value = Drea;
}
}
else
{
//
plus.nativeUI.toast("请求异常,请检查网络!");
//console.log( "xhr请求失败:"+xhr.status );
}
}
}
}
//返回刷新预处理
mui.init({
beforeback: function() {
//获得父页面的webview
var list = plus.webview.currentWebview().opener();
//console.log(list.toString());
//触发父页面的自定义事件(refresh),从而进行刷新
mui.fire(list, 'refresh');
//返回true,继续页面关闭逻辑
return true;
}
});
mui.ready(function() {
mui('.mui-input-row textarea').input();
});
(function($) {
$.init();
var result = $('#result')[0];
var btns = $('.btn');
btns.each(function(i, btn) {
btn.addEventListener('tap', function() {
var _self = this;
if(_self.picker) {
_self.picker.show(function (rs) {
result.innerText = rs.text;
_self.picker.dispose();
_self.picker = null;
});
} else {
var optionsJson = this.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
var id = this.getAttribute('id');
_self.picker = new $.DtPicker(options);
_self.picker.show(function(rs) {
result.innerText = rs.text;
_self.picker.dispose();
_self.picker = null;
});
}
}, false);
});
})(mui);
//二
(function($) {
$.init();
var result = $('#result1')[0];
var btns = $('.btn1');
btns.each(function(i, btn) {
btn.addEventListener('tap', function() {
var _self = this;
if(_self.picker) {
_self.picker.show(function (rs) {
result.innerText = rs.text;
_self.picker.dispose();
_self.picker = null;
});
} else {
var optionsJson = this.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
var id = this.getAttribute('id');
_self.picker = new $.DtPicker(options);
_self.picker.show(function(rs) {
result.innerText = rs.text;
_self.picker.dispose();
_self.picker = null;
});
}
}, false);
});
})(mui);
//三
(function($) {
$.init();
var result = $('#result2')[0];
var btns = $('.btn2');
btns.each(function(i, btn) {
btn.addEventListener('tap', function() {
var _self = this;
if(_self.picker) {
_self.picker.show(function (rs) {
result.innerText = rs.text;
_self.picker.dispose();
_self.picker = null;
});
} else {
var optionsJson = this.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
var id = this.getAttribute('id');
_self.picker = new $.DtPicker(options);
_self.picker.show(function(rs) {
result.innerText = rs.text;
_self.picker.dispose();
_self.picker = null;
});
}
}, false);
});
})(mui);
//添加笔记事件
function addNote()
{
var xhr = new plus.net.XMLHttpRequest();
//预处理请求
xhr.open("POST", "http://dstantside.com/Sdnote/api/Note/add");
//参数
var info = {};
var attr1 = "Token";
var attr2 = "UserID";
var attr3 = "Title";
var attr4 = "time";
var attr5 = "Content";
var attr6 = "Tag";
info[attr1] = plus.storage.getItem('uToken');
info[attr2] = plus.storage.getItem('uId');
info[attr3] = document.getElementById("nTitle").value;
//判断登录
if (info[attr2] == null)
{
plus.nativeUI.toast('还没有登录呢!~');
return;
}
//标题空值判断
if (info[attr3] == "")
{
plus.nativeUI.toast('不能什么都不写啊!~');
return;
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
info[attr4] = new Date().Format("yyyy-MM-dd hh:mm");
info[attr5] = document.getElementById("Notetextarea").value;
info[attr6] = document.getElementById("nTag").value;
console.log(JSON.stringify(info));
//设置请求头
xhr.setRequestHeader('Content-Type','application/json');
// 发送HTTP请求
//console.log(user);
xhr.send(info);
xhr.onreadystatechange = function (){
if ( xhr.status == 200 ) {
console.log( "xhr请求成功:"+xhr.responseText);
var noteList = JSON.parse(xhr.responseText);
//console.log(xhr.responseText);
plus.nativeUI.toast('笔记添加成功!~');
mui.back();
} else {
//console.log( "xhr请求失败:"+xhr.status );
plus.nativeUI.toast('异常!');
}
}
}
//添加提醒
function addRemind()
{
var xhr = new plus.net.XMLHttpRequest();
//预处理请求
xhr.open("POST", "http://dstantside.com/Sdnote/api/remid/add");
//参数
var info = {};
var attr1 = "Token";
var attr2 = "UserID";
var attr3 = "Title";
var attr4 = "time";
var attr5 = "Content";
var attr6 = "Tag";
var attr7 = "stratTime";
var attr8 = "endTime";
var attr9 = "remindTime";
info[attr1] = plus.storage.getItem('uToken');
info[attr2] = plus.storage.getItem('uId');
info[attr3] = document.getElementById("rTitle").value;
if (info[attr2] == null)
{
plus.nativeUI.toast('还没有登录呢!~');
return;
}
//标题空值判断
if (info[attr3] == "")
{
plus.nativeUI.toast('不能什么都不写啊!~');
return;
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
info[attr4] = new Date().Format("yyyy-MM-dd hh:mm");
info[attr5] = document.getElementById("Remindtextarea").value;
info[attr6] = document.getElementById("rTag").value;
info[attr7] = document.getElementById("result").innerText;
info[attr8] = document.getElementById("result1").innerText;
info[attr9] = document.getElementById("result2").innerText;
console.log(info[attr5]+info[attr6]);
if (info[attr7] == "" || info[attr8] == "" || info[attr9] == "")
{
console.log(info[attr9]);
plus.nativeUI.toast('必须设置三个时间哦!~');
return;
}
console.log(JSON.stringify(info));
//设置请求头
xhr.setRequestHeader('Content-Type','application/json');
// 发送HTTP请求
//console.log(user);
xhr.send(info);
xhr.onreadystatechange = function (){
if ( xhr.status == 200 ) {
//console.log( "xhr请求成功:"+xhr.responseText);
var noteList = JSON.parse(xhr.responseText);
//console.log(xhr.responseText);
plus.nativeUI.toast('提醒添加成功!~');
mui.back();
} else {
//console.log( "xhr请求失败:"+xhr.status );
plus.nativeUI.toast('异常!');
}
}
}
function ocr(){
}
</script>
</body>
</html>