-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
757 lines (755 loc) · 35.9 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
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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
<!DOCTYPE html>
<html lang="en" dir="ltr" typeof="bibo:Document w3p:REC" prefix="bibo: http://purl.org/ontology/bibo/ w3p: http://www.w3.org/2001/02pd/rec54#">
<head>
<meta property="dc:language" content="en" lang="">
<title>振动接口</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style>/*****************************************************************
* ReSpec 3 CSS
* Robin Berjon - http://berjon.com/
*****************************************************************/
/* --- INLINES --- */
em.rfc2119 {
text-transform: lowercase;
font-variant: small-caps;
font-style: normal;
color: #900;
}
h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
border: none;
}
dfn {
font-weight: bold;
}
a.internalDFN {
color: inherit;
border-bottom: 1px solid #99c;
text-decoration: none;
}
a.externalDFN {
color: inherit;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
a.bibref {
text-decoration: none;
}
cite .bibref {
font-style: normal;
}
code {
color: #C83500;
}
/* --- TOC --- */
.toc a, .tof a {
text-decoration: none;
}
a .secno, a .figno {
color: #000;
}
ul.tof, ol.tof {
list-style: none outside none;
}
.caption {
margin-top: 0.5em;
font-style: italic;
}
/* --- TABLE --- */
table.simple {
border-spacing: 0;
border-collapse: collapse;
border-bottom: 3px solid #005a9c;
}
.simple th {
background: #005a9c;
color: #fff;
padding: 3px 5px;
text-align: left;
}
.simple th[scope="row"] {
background: inherit;
color: inherit;
border-top: 1px solid #ddd;
}
.simple td {
padding: 3px 10px;
border-top: 1px solid #ddd;
}
.simple tr:nth-child(even) {
background: #f0f6ff;
}
/* --- DL --- */
.section dd > p:first-child {
margin-top: 0;
}
.section dd > p:last-child {
margin-bottom: 0;
}
.section dd {
margin-bottom: 1em;
}
.section dl.attrs dd, .section dl.eldef dd {
margin-bottom: 0;
}
@media print {
.removeOnSave {
display: none;
}
}
</style>
<style>/* --- EXAMPLES --- */
div.example-title {
min-width: 7.5em;
color: #b9ab2d;
}
div.example-title span {
text-transform: uppercase;
}
aside.example, div.example, div.illegal-example {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
div.illegal-example { color: red }
div.illegal-example p { color: black }
aside.example, div.example {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
border-color: #e0cb52;
background: #fcfaee;
}
aside.example div.example {
border-left-width: .1em;
border-color: #999;
background: #fff;
}
aside.example div.example div.example-title {
color: #999;
}
</style>
<style>/* --- ISSUES/NOTES --- */
div.issue-title, div.note-title , div.warning-title {
padding-right: 1em;
min-width: 7.5em;
color: #b9ab2d;
}
div.issue-title { color: #e05252; }
div.note-title { color: #2b2; }
div.warning-title { color: #f22; }
div.issue-title span, div.note-title span, div.warning-title span {
text-transform: uppercase;
}
div.note, div.issue, div.warning {
margin-top: 1em;
margin-bottom: 1em;
}
.note > p:first-child, .issue > p:first-child, .warning > p:first-child { margin-top: 0 }
.issue, .note, .warning {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
}
div.issue, div.note , div.warning {
padding: 1em 1.2em 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
span.note, span.issue, span.warning { padding: .1em .5em .15em; }
.issue {
border-color: #e05252;
background: #fbe9e9;
}
.note {
border-color: #52e052;
background: #e9fbe9;
}
.warning {
border-color: #f11;
border-right-width: .2em;
border-top-width: .2em;
border-bottom-width: .2em;
border-style: solid;
background: #fbe9e9;
}
.warning-title:before{
content: "⚠"; /*U+26A0 WARNING SIGN*/
font-size: 3em;
float: left;
height: 100%;
padding-right: .3em;
vertical-align: top;
margin-top: -0.5em;
}
</style>
<style>/* HIGHLIGHTS */
code.prettyprint {
color: inherit;
}
/* this from google-code-prettify */
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
</style>
<style>/* --- WEB IDL --- */
pre.idl {
border-top: 1px solid #90b8de;
border-bottom: 1px solid #90b8de;
padding: 1em;
line-height: 120%;
}
pre.idl::before {
content: "WebIDL";
display: block;
width: 150px;
background: #90b8de;
color: #fff;
font-family: initial;
padding: 3px;
font-weight: bold;
margin: -1em 0 1em -1em;
}
.idlType {
color: #ff4500;
font-weight: bold;
text-decoration: none;
}
/*.idlModule*/
/*.idlModuleID*/
/*.idlInterface*/
.idlInterfaceID, .idlDictionaryID, .idlCallbackID, .idlEnumID {
font-weight: bold;
color: #005a9c;
}
a.idlEnumItem {
color: #000;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
.idlSuperclass {
font-style: italic;
color: #005a9c;
}
/*.idlAttribute*/
.idlAttrType, .idlFieldType, .idlMemberType {
color: #005a9c;
}
.idlAttrName, .idlFieldName, .idlMemberName {
color: #ff4500;
}
.idlAttrName a, .idlFieldName a, .idlMemberName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlMethod*/
.idlMethType, .idlCallbackType {
color: #005a9c;
}
.idlMethName {
color: #ff4500;
}
.idlMethName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlCtor*/
.idlCtorName {
color: #ff4500;
}
.idlCtorName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlParam*/
.idlParamType {
color: #005a9c;
}
.idlParamName, .idlDefaultValue {
font-style: italic;
}
.extAttr {
color: #666;
}
/*.idlSectionComment*/
.idlSectionComment {
color: gray;
}
/*.idlConst*/
.idlConstType {
color: #005a9c;
}
.idlConstName {
color: #ff4500;
}
.idlConstName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlException*/
.idlExceptionID {
font-weight: bold;
color: #c00;
}
.idlTypedefID, .idlTypedefType {
color: #005a9c;
}
.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code {
color: #c00;
font-weight: normal;
}
.excName a {
font-family: monospace;
}
.idlRaises a.idlType, .excName a.idlType {
border-bottom: 1px dotted #c00;
}
.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse {
width: 45px;
text-align: center;
}
.excGetSetTrue, .prmNullTrue, .prmOptTrue { color: #0c0; }
.excGetSetFalse, .prmNullFalse, .prmOptFalse { color: #c00; }
.idlImplements a {
font-weight: bold;
}
dl.attributes, dl.methods, dl.constants, dl.constructors, dl.fields, dl.dictionary-members {
margin-left: 2em;
}
.attributes dt, .methods dt, .constants dt, .constructors dt, .fields dt, .dictionary-members dt {
font-weight: normal;
}
.attributes dt code, .methods dt code, .constants dt code, .constructors dt code, .fields dt code, .dictionary-members dt code {
font-weight: bold;
color: #000;
font-family: monospace;
}
.attributes dt code, .fields dt code, .dictionary-members dt code {
background: #ffffd2;
}
.attributes dt .idlAttrType code, .fields dt .idlFieldType code, .dictionary-members dt .idlMemberType code {
color: #005a9c;
background: transparent;
font-family: inherit;
font-weight: normal;
font-style: italic;
}
.methods dt code {
background: #d9e6f8;
}
.constants dt code {
background: #ddffd2;
}
.constructors dt code {
background: #cfc;
}
.attributes dd, .methods dd, .constants dd, .constructors dd, .fields dd, .dictionary-members dd {
margin-bottom: 1em;
}
table.parameters, table.exceptions {
border-spacing: 0;
border-collapse: collapse;
margin: 0.5em 0;
width: 100%;
}
table.parameters { border-bottom: 1px solid #90b8de; }
table.exceptions { border-bottom: 1px solid #deb890; }
.parameters th, .exceptions th {
color: #fff;
padding: 3px 5px;
text-align: left;
font-family: initial;
font-weight: normal;
text-shadow: #666 1px 1px 0;
}
.parameters th { background: #90b8de; }
.exceptions th { background: #deb890; }
.parameters td, .exceptions td {
padding: 3px 10px;
border-top: 1px solid #ddd;
vertical-align: top;
}
.parameters tr:first-child td, .exceptions tr:first-child td {
border-top: none;
}
.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName {
width: 100px;
}
.parameters td.prmType {
width: 120px;
}
table.exceptions table {
border-spacing: 0;
border-collapse: collapse;
width: 100%;
}
</style>
<link href="https://www.w3.org/StyleSheets/TR/W3C-REC" rel="stylesheet">
<!--[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]-->
</head>
<body id="respecDocument" role="document" class="h-entry">
<div id="respecHeader" role="contentinfo" class="head">
<p>
<a href="http://www.w3.org/"><img src="https://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48"></a>
</p>
<h1 class="title p-name" id="title" property="dcterms:title">振动接口</h1>
<h2 id="w3c-recommendation-10-february-2015"><abbr title="World Wide Web Consortium">W3C</abbr> 推荐标准 <time property="dcterms:issued" class="dt-published" datetime="2015-02-10">2015年2月10日</time></h2>
<dl>
<dt>该版本:</dt>
<dd><a class="u-url" href="http://www.w3.org/TR/2015/REC-vibration-20150210/">http://www.w3.org/TR/2015/REC-vibration-20150210/</a></dd>
<dt>最新发布版本:</dt>
<dd><a href="http://www.w3.org/TR/vibration/">http://www.w3.org/TR/vibration/</a></dd>
<dt>最新编辑草案:</dt>
<dd><a href="http://dev.w3.org/2009/dap/vibration/">http://dev.w3.org/2009/dap/vibration/</a></dd>
<dt>测试套件:</dt>
<dd><a href="http://w3c-test.org/vibration/">http://w3c-test.org/vibration/</a></dd>
<dt>实现报告:</dt>
<dd><a href="http://w3c.github.io/test-results/vibration/20141118.html">http://w3c.github.io/test-results/vibration/20141118.html</a></dd>
<dt>历史版本:</dt>
<dd><a rel="dcterms:replaces" href="http://www.w3.org/TR/2014/PR-vibration-20141209/">http://www.w3.org/TR/2014/PR-vibration-20141209/</a></dd>
<dt>编辑:</dt>
<dd class="p-author h-card vcard" property="bibo:editor" resource="_:editor0"><span property="rdf:first" typeof="foaf:Person"><span property="foaf:name" class="p-name fn">Anssi Kostiainen</span>, Intel</span>
<span property="rdf:rest" resource="rdf:nil"></span>
</dd>
<dt>译者:</dt>
<dd><a href="https://github.com/otakustay">张立理</a></dd>
<dd><a href="https://github.com/kennyluck">吕康豪</a></dd>
<dd><a href="https://github.com/zqzhang">张志强</a></dd>
<dt>译者声明:</dt>
<dd>本规范的<a href="http://www.w3.org/TR/vibration/">英文版本</a>是其唯一标准版本。 其他<a href="http://www.w3.org/Consortium/Translation/">翻译版本</a>包括该译文都是参考性的。</dd>
<dd>虽然译者力求翻译准确,错误仍在所难免,欢迎指正。</dd>
</dl>
<p>
请参阅本规范的<a href="http://www.w3.org/2009/dap/vibration-errata.html"><strong>勘误表</strong></a>,其中包括本规范自最新发布以来所发现的错误或者缺陷。
</p>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
2015
<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
<a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>),
All Rights Reserved.
<abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
<a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a>
rules apply.
</p>
<hr>
</div>
<section property="dc:abstract" class="introductory" id="abstract">
<h2 resource="#h-abstract" id="h-abstract"><span property="xhv:role" resource="xhv:heading">摘要</span></h2>
<p>
本规范定义了一个接口,它提供了访问托管设备的振动机制。振动是一种触觉反馈。
</p>
</section>
<section id="sotd" class="introductory">
<h2 resource="#h-sotd" id="h-sotd"><span property="xhv:role" resource="xhv:heading">本文档状态</span></h2>
<p>
<em>本节描述本文档发布时状态,其他文档可能取代本文档。 <abbr title="World Wide Web Consortium">W3C</abbr> 最新发布的技术报告,
以及本技术报告的最新版本, 参见 <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> 技术报告索引</a>:
http://www.w3.org/TR/</em>。
</p>
<p>
自发布<a href="http://www.w3.org/TR/2014/PR-vibration-20141209/">提案推荐标准</a>以来,本文档没有任何新的改变。
</p>
<p>
W3C 期望通过发布该推荐标准,其所规范的功能不受 Web IDL 规范通往推荐标准的过程所影响。
</p>
<p>
本文档代表该小组在振动接口这一范围和特性的共识。应当指出的是,工作组意识到了
无法使用这一简单的第一个版本规范来实现更先进的使用案例。留待未来的修订来解决它们。
</p>
<p>
本文档由<a href="http://www.w3.org/2009/dap/">设备接口工作组</a>发布为推荐标准。
关于本文档的任何反馈意见,请发送至工作组邮件列表:
<a href="mailto:public-device-apis@w3.org">public-device-apis@w3.org</a>
(<a href="mailto:public-device-apis-request@w3.org?subject=subscribe">订阅</a>,
<a href="http://lists.w3.org/Archives/Public/public-device-apis/">归档</a>)。
欢迎反馈。
</p>
<p>
请参阅工作组的<a href="http://w3c.github.io/test-results/vibration/20141118.html">实现报告</a>。
</p>
<p>
本文档已由 <abbr title="World Wide Web Consortium">W3C</abbr> 成员、软件开发者、 <abbr title="World Wide Web Consortium">W3C</abbr>
工作组和有关各方审阅,并由 <abbr title="World Wide Web Consortium">W3C</abbr> 理事会批准为推荐标准。
此为稳定的文档,可以用作参考文献或从另一个文件中引用。
<abbr title="World Wide Web Consortium">W3C</abbr> 制定推荐标准的任务是使之受到关注,并促使其被广泛使用。这将增强 Web 的功能性与互操作性。
</p>
<p>
本文档由一个遵循
<a id="sotd_patent" property="w3p:patentRules" href="http://www.w3.org/Consortium/Patent-Policy-20040205/">2004年2月5日 <abbr title="World Wide Web Consortium">W3C</abbr> 专利政策</a>的小组创作。
<abbr title="World Wide Web Consortium">W3C</abbr> 维护着一个与工作组交付产品相关的<a href="http://www.w3.org/2004/01/pp-impl/43696/status" rel="disclosure">已公开的专利列表</a>;该列表页面还包括如何公开一项专利的说明。
对某专利拥有实际知识并相信该专利包含了
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">基本要求</a>的个人,必须根据
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure"> <abbr title="World Wide Web Consortium">W3C</abbr> 专利政策第6节</a>的要求公开这些信息。
</p>
<p>
本文档受制于<a id="w3c_process_revision" href="http://www.w3.org/2005/10/Process-20051014/">2005年10月14日 <abbr title="World Wide Web Consortium">W3C</abbr> 过程文档</a>。
</p>
</section>
<section id="toc">
<h2 resource="#h-toc" id="h-toc" class="introductory"><span property="xhv:role" resource="xhv:heading">目录</span></h2>
<ul id="respecContents" role="directory" class="toc">
<li class="tocline"><a class="tocxref" href="#introduction"><span class="secno">1. </span>引言</a></li>
<li class="tocline"><a class="tocxref" href="#conformance"><span class="secno">2. </span>一致性</a></li>
<li class="tocline"><a class="tocxref" href="#terminology"><span class="secno">3. </span>术语</a></li>
<li class="tocline"><a class="tocxref" href="#vibration-interface"><span class="secno">4. </span>振动接口</a></li>
<li class="tocline"><a class="tocxref" href="#examples"><span class="secno">5. </span>示例</a></li>
<li class="tocline"><a class="tocxref" href="#acknowledgements"><span class="secno">A. </span>致谢</a></li>
<li class="tocline">
<a class="tocxref" href="#references"><span class="secno">B. </span>参考文献</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#normative-references"><span class="secno">B.1 </span>规范性参考文献</a></li>
<li class="tocline"><a class="tocxref" href="#informative-references"><span class="secno">B.2 </span>信息性参考文献</a></li>
</ul>
</li>
</ul>
</section>
<section property="bibo:hasPart" resource="#introduction" typeof="bibo:Chapter" id="introduction" class="informative">
<!--OddPage-->
<h2 resource="#h-introduction" id="h-introduction"><span property="xhv:role" resource="xhv:heading"><span class="secno">1. </span>引言</span></h2>
<p><em>本章节不具有规范性。</em></p>
<p>
振动接口专门设计用于仅需简单触觉反馈的用例场景。那些需要细粒度控制的用例场景超出了本规范的范围。
该接口并非用于通用的通知机制。通用的通知可使用<cite>通知接口</cite>
[<cite><a href="#bib-NOTIFICATIONS" class="bibref">NOTIFICATIONS</a></cite>]
规范来处理。此外,决定是否启用振动也超出了本规范的范围。
</p>
</section>
<section property="bibo:hasPart" resource="#conformance" typeof="bibo:Chapter" id="conformance">
<!--OddPage-->
<h2 resource="#h-conformance" id="h-conformance"><span property="xhv:role" resource="xhv:heading"><span class="secno">2. </span>一致性</span></h2>
<p>
像其他不具有规范性的章节一样,本规范中所有指导方案、图表、示例以及注解都不具有规范性。
本规范中其余部分均具有规范性。
</p>
<p id="respecRFC2119">关键词<em class="rfc2119" title="MAY">可以</em>和<em class="rfc2119" title="MUST">必须</em>的释义由 [<cite><a href="#bib-RFC2119" class="bibref">RFC2119</a></cite>] 进行解释。
</p>
<p>
本规范所定义的一致性标准条件仅适用于实现了规范所包含接口的<dfn id="ua">用户代理</dfn>。
</p>
<p>
由于本规范使用了 WebIDL 规范及其术语,因此如果使用 ECMA 脚本对本规范定义的应用程序接口进行实现,
则必须保持实现与 ECMA 脚本绑定定义的 WebIDL 规范 [<cite><a href="#bib-WEBIDL" class="bibref">WEBIDL</a></cite>] 相一致。
</p>
</section>
<section property="bibo:hasPart" resource="#terminology" typeof="bibo:Chapter" id="terminology">
<!--OddPage-->
<h2 resource="#h-terminology" id="h-terminology"><span property="xhv:role" resource="xhv:heading"><span class="secno">3. </span>术语</span></h2>
<p>
<dfn id="dfn-browsing-context"><a href="http://www.w3.org/TR/html5/browsers.html#browsing-context">
browsing context</a></dfn> 和
<dfn id="dfn-spin-the-event-loop"><a href="http://www.w3.org/TR/html5/webappapis.html#spin-the-event-loop">
spin the event loop</a></dfn> 的概念由 [<cite><a href="#bib-HTML5" class="bibref">HTML5</a></cite>] 规范定义。
</p>
</section>
<section property="bibo:hasPart" resource="#vibration-interface" typeof="bibo:Chapter" id="vibration-interface">
<!--OddPage-->
<h2 resource="#h-vibration-interface" id="h-vibration-interface"><span property="xhv:role" resource="xhv:heading"><span class="secno">4. </span>振动接口</span></h2>
<pre class="idl"><span class="idlInterface" id="idl-def-Navigator"><span class="idlTypedef" id="idl-def-VibratePattern">typedef <span class="idlTypedefType">(unsigned long or sequence<unsigned long>)</span> <span class="idlTypedefID">VibratePattern</span>;</span><br><br>partial interface <span class="idlInterfaceID">Navigator</span> {
<span class="idlMethod"> <span class="idlMethType">boolean</span> <span class="idlMethName"><a href="#widl-Navigator-vibrate-boolean-VibratePattern-pattern">vibrate</a></span> (<span class="idlParam"><span class="idlParamType"><a class="idlType" href="#idl-def-VibratePattern"><code>VibratePattern</code></a></span> <span class="idlParamName">pattern</span></span>);</span>
};</span></pre>
<p>
当调用 <code id="widl-Navigator-vibrate-boolean-VibratePattern-pattern">vibrate()</code>
方法时,<em title="MUST" class="rfc2119">必须</em>运行 <a class="internalDFN" href="#dfn-processing-vibration-patterns">processing vibration patterns</a> 算法。
</p>
<p>
<dfn id="dfn-processing-vibration-patterns">processing vibration patterns</dfn> 的算法的规则描述如下:
</p>
<ol>
<li>
设 <var>pattern</var> 为 <code>vibrate()</code> 方法的第一个参数。
</li>
<li>
设 <var>valid pattern</var> 为 <var>pattern</var> 参数进行 <a class="internalDFN" href="#dfn-validate-and-normalize">validate and normalize</a> 的结果。
</li>
<li>
如果 <code>
<a href="https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#dom-document-hidden">
hidden</a></code> 属性值 [<cite><a href="#bib-PAGE-VISIBILITY" class="bibref">PAGE-VISIBILITY</a></cite>] 设置为 true,则返回 false 并终止所有步骤。
<div class="note">
<div id="h-note1" role="heading" aria-level="3" class="note-title"><span>注</span></div>
<div class="">
可信(也称授权)应用程序因为与操作系统功能集成紧密,即使完全不可见,也可能产生设备振动,
因此可以忽略前述步骤。
</div>
</div>
</li>
<li>
对 <var>valid pattern</var> <a class="internalDFN" href="#dfn-perform-vibration">Perform vibration</a>。
</li>
</ol>
<p>
为 <dfn id="dfn-validate-and-normalize">validate and normalize</dfn> 某一给定的振动模式
<var>pattern</var>,运行这些步骤:
</p>
<ol>
<li>
如果 <var>pattern</var> 是一个列表,则进入下一步。否则运行以下子步骤:
<ol>
<li>
设 <var>list</var> 为一个空的列表,并将
<var>pattern</var> 加入到 <var>list</var> 中。
</li>
<li>
设 <var>pattern</var> 的值为 <var>list</var>。
</li>
</ol>
</li>
<li>
设 <var>max length</var> 为实现相关的 <var>pattern</var> 的最大长度值。
<div class="note">
<div id="h-note2" role="heading" aria-level="3" class="note-title"><span>注</span></div>
<div class="">
如果模式的长度大于最大长度,该接口的实现可以考虑将此振动请求有效地分解成多个内部短请求,
来实现同样的效果,而不是忽略最大长度后面的请求。
然而,有些情况下忽略模式超过最大长度的部分是合时的。
一个例子是,如果长度太长,将会有效地创建一个拒绝服务攻击用户。
如果已知对某 web 应用程序来说某个长度太长时,该应用程序也可能采用多个请求;
模式之间可能存在的差距是可以接受的。
</div>
</div>
</li>
<li>
如果 <var>pattern</var> 长度大于
<var>max length</var>,截断 <var>pattern</var>,仅保留前 <var>max length</var> 项。
<div class="note">
<div id="h-note3" role="heading" aria-level="3" class="note-title"><span>注</span></div>
<div class="" id="remove-last-entry">
如果 <var>pattern</var> 的长度是偶数并且非零,那么模式中的最后一项就会没有效果,因此实现可以在此从 <var>pattern</var> 中将之删除。
</div>
</div>
</li>
<li>
设 <var>max duration</var> 为实现相关的 <var>pattern</var> 中单个振动项的最大持续时间值。
</li>
<li>
对 <var>pattern</var> 中所有的持续时间值大于
<var>max duration</var> 的项,设置其值为
<var>max duration</var>。
</li>
<li>
返回 <var>pattern</var>。
</li>
</ol>
<p>
为使用 <var>pattern</var> <dfn id="dfn-perform-vibration">perform vibration</dfn> ,运行这些步骤:
</p>
<ol>
<li>
算法的实现<em title="MAY" class="rfc2119">可以</em>在此返回 false 并终止这些步骤。
<div class="note">
<div id="h-note4" role="heading" aria-level="3" class="note-title"><span>注</span></div>
<div class="">
例如,用户设置了某些域的页面不得使设备振动,或者振动的总时间长度超过了页面允许的最大值从而拒绝振动请求,这些情况下算法实现可以停止算法运行。
</div>
</div>
</li>
<li>
如果已经存在 <a class="internalDFN" href="#dfn-perform-vibration">perform vibration</a> 的算法实例,那么运行下列子步骤:
<ol>
<li>
中止任何其他正在 <a class="internalDFN" href="#dfn-perform-vibration">perform vibration</a> 的实例。
</li>
<li>
如果 <var>pattern</var> 是一个空列表,包含单独一项的值为 0,或者该设备不能振动,那么返回 true 并且终止这些步骤。
</li>
</ol>
</li>
<li>
返回 true,然后继续异步执行后续步骤。
</li>
<li>
对于 <var>pattern</var> 中的每一项,设其为 <var>time</var>,运行以下子步骤:
<ol>
<li>
如果 <var>time</var> 对应的索引为偶数(第一项的索引为 0 ),控制设备振动 <var>time</var> 毫秒。
</li>
<li>
否则等待 <var>time</var> 毫秒。
</li>
</ol>
</li>
</ol>
<p>
当 <code>Document</code> <a class="internalDFN" href="#dfn-browsing-context">browsing context</a> 上的
<code><a href="https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-visibilitychange-event">
visibilitychange</a></code> 事件 [<cite><a href="#bib-PAGE-VISIBILITY" class="bibref">PAGE-VISIBILITY</a></cite>] 触发时,
<a class="product-ua" href="#ua">用户代理</a> <em title="MUST" class="rfc2119">必须</em> 终止所有已经在运行的 <a class="internalDFN" href="#dfn-processing-vibration-patterns">processing vibration patterns</a> 算法。
</p>
</section>
<section property="bibo:hasPart" resource="#examples" typeof="bibo:Chapter" id="examples" class="informative">
<!--OddPage-->
<h2 resource="#h-examples" id="h-examples"><span property="xhv:role" resource="xhv:heading"><span class="secno">5. </span>示例</span></h2>
<p><em>本章节不具有规范性。</em></p>
<p>
以下演示如何让设备振动 1 秒:
</p>
<div class="example">
<div class="example-title"><span>示例 1</span></div>
<pre style="" class="example highlight prettyprint prettyprinted"><span class="com">// 振动 1 秒</span><span class="pln">
navigator</span><span class="pun">.</span><span class="pln">vibrate</span><span class="pun">(</span><span class="lit">1000</span><span class="pun">);</span><span class="pln">
</span><span class="com">// 或者</span><span class="pln">
navigator</span><span class="pun">.</span><span class="pln">vibrate</span><span class="pun">([</span><span class="lit">1000</span><span class="pun">]);</span></pre>
</div>
<p>
以下演示如何让设备先振动 50 毫秒,再停止 100 毫秒,再振动 150 毫秒:
</p>
<div class="example">
<div class="example-title"><span>示例 2</span></div>
<pre style="" class="example highlight prettyprint prettyprinted"><span class="pln">navigator</span><span class="pun">.</span><span class="pln">vibrate</span><span class="pun">([</span><span class="lit">50</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">,</span><span class="pln"> </span><span class="lit">150</span><span class="pun">]);</span></pre>
</div>
<p>
</p>
<p>
以下演示如何取消振动:
</p>
<div class="example">
<div class="example-title"><span>示例 3</span></div>
<pre style="" class="example highlight prettyprint prettyprinted"><span class="com">// 取消所有振动</span><span class="pln">
navigator</span><span class="pun">.</span><span class="pln">vibrate</span><span class="pun">(</span><span class="lit">0</span><span class="pun">);</span><span class="pln">
</span><span class="com">// 或者</span><span class="pln">
navigator</span><span class="pun">.</span><span class="pln">vibrate</span><span class="pun">([]);</span></pre>
</div>
</section>
<section property="bibo:hasPart" resource="#acknowledgements" typeof="bibo:Chapter" id="acknowledgements" class="appendix">
<!--OddPage-->
<h2 resource="#h-acknowledgements" id="h-acknowledgements"><span property="xhv:role" resource="xhv:heading"><span class="secno">A. </span>致谢</span></h2>
<p>
工作组非常感谢 Justin Lebar、Mounir Lamouri、Jonas
Sicking 和 Mozilla WebAPI 团队的贡献和提供 WebVibrator 原型作为初始输入。
感谢 Anne van Kesteren 建议如何使规范重用于其他文档。
</p>
</section>
<section property="bibo:hasPart" resource="#references" typeof="bibo:Chapter" id="references" class="appendix">
<!--OddPage-->
<h2 resource="#h-references" id="h-references"><span property="xhv:role" resource="xhv:heading"><span class="secno">B. </span>参考文献</span></h2>
<section property="bibo:hasPart" resource="#normative-references" typeof="bibo:Chapter" id="normative-references">
<h3 resource="#h-normative-references" id="h-normative-references"><span property="xhv:role" resource="xhv:heading"><span class="secno">B.1 </span>规范性参考文献</span></h3>
<dl resource="" class="bibliography">
<dt id="bib-HTML5">[HTML5]</dt>
<dd>Ian Hickson; Robin Berjon; Steve Faulkner; Travis Leithead; Erika Doyle Navara; Edward O'Connor; Silvia Pfeiffer. <a property="dc:requires" href="http://www.w3.org/TR/html5/"><cite>HTML5</cite></a>. 28 October 2014. W3C Recommendation. URL: <a property="dc:requires" href="http://www.w3.org/TR/html5/">http://www.w3.org/TR/html5/</a></dd>
<dt id="bib-PAGE-VISIBILITY">[PAGE-VISIBILITY]</dt>
<dd>Jatinder Mann; Arvind Jain. <a property="dc:requires" href="http://www.w3.org/TR/page-visibility/"><cite>Page Visibility (Second Edition)</cite></a>. 29 October 2013. W3C Recommendation. URL: <a property="dc:requires" href="http://www.w3.org/TR/page-visibility/">http://www.w3.org/TR/page-visibility/</a></dd>
<dt id="bib-RFC2119">[RFC2119]</dt>
<dd>S. Bradner. <a property="dc:requires" href="https://tools.ietf.org/html/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. March 1997. Best Current Practice. URL: <a property="dc:requires" href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a></dd>
<dt id="bib-WEBIDL">[WEBIDL]</dt>
<dd>Cameron McCormack. <a property="dc:requires" href="http://www.w3.org/TR/WebIDL/"><cite>Web IDL</cite></a>. 19 April 2012. W3C Candidate Recommendation. URL: <a property="dc:requires" href="http://www.w3.org/TR/WebIDL/">http://www.w3.org/TR/WebIDL/</a></dd>
</dl>
</section>
<section property="bibo:hasPart" resource="#informative-references" typeof="bibo:Chapter" id="informative-references">
<h3 resource="#h-informative-references" id="h-informative-references"><span property="xhv:role" resource="xhv:heading"><span class="secno">B.2 </span>信息性参考文献</span></h3>
<dl resource="" class="bibliography">
<dt id="bib-NOTIFICATIONS">[NOTIFICATIONS]</dt>
<dd>Anne van Kesteren. <a property="dc:references" href="https://notifications.spec.whatwg.org/"><cite>Notifications API</cite></a>. Living Standard. URL: <a property="dc:references" href="https://notifications.spec.whatwg.org/">https://notifications.spec.whatwg.org/</a></dd>
</dl>
</section>
</section>
</body>
</html>