Skip to content

Commit

Permalink
remove event macro from zh-CN (Part 5)
Browse files Browse the repository at this point in the history
  • Loading branch information
yin1999 authored and irvin committed Nov 9, 2022
1 parent 06d9fde commit 1018ce3
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 115 deletions.
19 changes: 9 additions & 10 deletions files/zh-cn/web/api/rtcpeerconnection/addtrack/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ slug: Web/API/RTCPeerConnection/addTrack

{{domxref("RTCPeerConnection")}} 对象的 **`addTrack()`** 方法将一个新的媒体音轨添加到一组音轨中,这些音轨将被传输给另一个对等点。

> **备注:** 通过触发一个{{event("negotiationneeded")}}事件,向连接添加一个跟踪将触发重新协商。详情请参见{{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling", "Starting negotiation")}}。
> **备注:** 通过触发一个 {{DOMxRef("RTCPeerConnection/negotiationneeded_event", "negotiationneeded")}} 事件,向连接添加一个跟踪将触发重新协商。详情请参见{{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling", "Starting negotiation")}}。
## 语法

Expand Down Expand Up @@ -59,7 +59,7 @@ async openCall(pc) {
}
```

结果是一组没有流关联的跟踪被发送到远程对等点。远程对等点上的{{event("track")}}事件的处理程序将负责决定将每个跟踪添加到哪个流中,即使这意味着只是将它们全部添加到同一个流中。{{domxref("RTCPeerConnection.ontrack", "ontrack")}}方法如下:
结果是一组没有流关联的跟踪被发送到远程对等点。远程对等点上的 {{DOMxRef("RTCPeerConnection/track_event", "track")}} 事件的处理程序将负责决定将每个跟踪添加到哪个流中,即使这意味着只是将它们全部添加到同一个流中。{{domxref("RTCPeerConnection.ontrack", "ontrack")}} 方法如下:

```js
let inboundStream = null;
Expand Down Expand Up @@ -108,10 +108,10 @@ async openCall(pc) {
}
```

远程对等点然后可以使用一个看起来像这样的{{event("track")}}事件处理程序:
远程对等点然后可以使用一个看起来像这样的 {{DOMxRef("RTCPeerConnection/track_event", "track")}} 事件处理程序:

```js
pc.ontrack = ({streams: [stream]} => videoElem.srcObject = stream;
pc.ontrack = ({streams: [stream]} => videoElem.srcObject = stream);
```

这将把视频元素的当前流设置为包含已添加到连接中的音轨的流。
Expand Down Expand Up @@ -173,13 +173,12 @@ pc.setRemoteDescription(desc).then(function () {

{{Specifications}}

## 浏览器支持
## 浏览器兼容性

{{Compat}}

## 参考
## 参见

- [WebRTC](/zh-CN/docs/Web/Guide/API/WebRTC)
- [Introduction to the Real-time Transport Protocol (RTP)](/zh-CN/docs/Web/API/WebRTC_API/Intro_to_RTP)
- {{domxref("RTCPeerConnection.ontrack")}}
- {{event("track")}}
- [WebRTC](/zh-CN/docs/Web/API/WebRTC_API)
- [实时传输协议(RTP)简介](/zh-CN/docs/Web/API/WebRTC_API/Intro_to_RTP)
- {{DOMxRef("RTCPeerConnection/track_event", "track")}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ slug: Web/API/RTCPeerConnection/createDataChannel

{{domxref("RTCPeerConnection")}} 的 `createDataChannel()` 方法创建一个可以发送任意数据的数据通道 (data channel)。常用于后台传输内容,例如:图像,文件传输,聊天文字,游戏数据更新包,等等。

基于某个连接创建第一个 data channel 时,会通过发送一个{{event("negotiationneeded")}} event 来开始重新谈判 (renegotiation)
基于某个连接创建第一个 data channel 时,会通过发送一个 {{DOMxRef("RTCPeerConnection/negotiationneeded_event", "negotiationneeded")}} 事件来开始重新谈判(renegotiation

## 语法

Expand Down Expand Up @@ -65,7 +65,7 @@ A new {{domxref("RTCDataChannel")}} object with the specified `label`, configure

## Examples

This example shows how to create a data channel and set up handlers for the {{event("open")}} and [`message`](/zh-CN/docs/Web/API/BroadcastChannel/message_event) events to send and receive messages on it (For brievity, the example assumes onnegotiationneeded is set up).
This example shows how to create a data channel and set up handlers for the {{DOMxRef("RTCDataChannel/open_event", "open")}} and [`message`](/zh-CN/docs/Web/API/BroadcastChannel/message_event) events to send and receive messages on it (For brievity, the example assumes onnegotiationneeded is set up).

```js
// Offerer side
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/rtcpeerconnection/createoffer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ myPeerConnection.createOffer(successCallback, failureCallback, [options]) {{depr

## 举例

在这里,我们看到了{{event("negotiationneeded")}}事件的处理程序,该处理程序创建了要约,并通过信令通道将其发送到远程系统。
在这里,我们看到了 {{DOMxRef("RTCPeerConnection/negotiationneeded_event", "negotiationneeded")}} 事件的处理程序,该处理程序创建了要约,并通过信令通道将其发送到远程系统。

> **备注:** 请记住,这是信令过程的一部分,传输层的实现细节完全由您决定。在这种情况下,[WebSocket](/zh-CN/docs/Web/API/WebSocket_API)连接用于向其他端点发送带有值为“video-offer”的类型字段的{{Glossary("JSON")}}消息。传递给`sendToServer()`函数的对象的内容,以及承诺履行处理程序中的所有其他内容,完全取决于您的设计。
Expand Down
14 changes: 8 additions & 6 deletions files/zh-cn/web/api/rtcpeerconnection/datachannel_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ slug: Web/API/RTCPeerConnection/datachannel_event

{{APIRef("WebRTC")}}{{SeeCompatTable}}

**`RTCPeerConnection.ondatachannel`** 属性是一个 {{event("Event_handlers", "event handler")}},当这个 {{event("datachannel")}} 事件在 {{domxref("RTCPeerConnection")}} 发生时,它指定的那个事件处理函数就会被调用。这个事件继承于 {{domxref("RTCDataChannelEvent")}},当远方伙伴调用{{domxref("RTCPeerConnection.createDataChannel", "createDataChannel()")}}时这个事件被加到这个连接(RTCPeerConnection)中。
**`RTCPeerConnection.ondatachannel`** 属性是一个事件处理器,当 `datachannel` 事件在 {{domxref("RTCPeerConnection")}} 发生时,它指定的那个事件处理函数就会被调用。这个事件继承于 {{domxref("RTCDataChannelEvent")}},当远方伙伴调用 {{domxref("RTCPeerConnection.createDataChannel", "createDataChannel()")}} 时这个事件被加到这个连接(RTCPeerConnection)中。

在这个事件被收到的同时,这个{{domxref("RTCDataChannel")}} 实际上并没有打开,确保在 open 这个事件在`RTCDataChannel`触发以后才去使用它。
在这个事件被收到的同时,这个 {{domxref("RTCDataChannel")}} 实际上并没有打开,确保在 open 这个事件在`RTCDataChannel`触发以后才去使用它。

## 语法

Expand All @@ -34,12 +34,14 @@ pc.ondatachannel = function(ev) {

{{Specifications}}

## 浏览器支持
## 浏览器兼容性

{{Compat}}

## 相关阅读
## 参见

- The {{event("datachannel")}} event and its type, {{domxref("RTCDataChannelEvent")}}.
- [WebRTC API](/zh-CN/docs/Web/API/WebRTC_API)
- [使用 WebRTC data channel](/zh-CN/docs/Web/API/WebRTC_API/Using_data_channels)
- [RTCDataChannel 简单示例](/zh-CN/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample)
- {{domxref("RTCDataChannelEvent")}}
- {{domxref("RTCPeerConnection.createDataChannel()")}}
- [A simple RTCDataChannel sample](/zh-CN/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample)
8 changes: 3 additions & 5 deletions files/zh-cn/web/api/rtcpeerconnection/track_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: RTCPeerConnection.ontrack
slug: Web/API/RTCPeerConnection/track_event
---

{{APIRef("WebRTC")}}{{SeeCompatTable}}**`RTCPeerConnection.ontrack`** 属性是一个 {{event("Event_handlers", "event handler")}} 此属性指定了在{{domxref("RTCPeerConnection")}}接口上触发 {{event("track")}} 事件时调用的方法。该方法接收一个{{domxref("RTCTrackEvent")}}类型的 event 对象,该 event 对象将在{{domxref("MediaStreamTrack")}}被创建时或者是关联到已被添加到接收集合的{{domxref("RTCRtpReceiver")}}对象中时被发送。
{{APIRef("WebRTC")}}{{SeeCompatTable}}

**`RTCPeerConnection.ontrack`** 属性是一个事件处理器,此属性指定了在 {{domxref("RTCPeerConnection")}}接口上触发 `track` 事件时调用的方法。该方法接收一个 {{domxref("RTCTrackEvent")}} 类型的 event 对象,该 event 对象将在 {{domxref("MediaStreamTrack")}} 被创建时或者是关联到已被添加到接收集合的 {{domxref("RTCRtpReceiver")}} 对象中时被发送。

## 语法

Expand Down Expand Up @@ -35,7 +37,3 @@ pc.ontrack = function(event) {
## 浏览器兼容性

{{Compat}}

## 参见

- {{event("track")}} 事件和它的类型 {{domxref("RTCTrackEvent")}}.
44 changes: 24 additions & 20 deletions files/zh-cn/web/api/serviceworkerglobalscope/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,30 @@ slug: Web/API/ServiceWorkerGlobalScope
- {{domxref("ServiceWorkerGlobalScope.caches")}} {{readonlyinline}}
- : Contains the {{domxref("CacheStorage")}} object associated with the service worker.

### Event handlers

- {{domxref("ServiceWorkerGlobalScope.onactivate")}}
- : An event handler fired whenever an {{Event("activate")}} event occurs — when a {{domxref("ServiceWorkerRegistration")}} acquires a new {{domxref("ServiceWorkerRegistration.active")}} worker.
- {{domxref("ServiceWorkerGlobalScope.onfetch")}}
- : An event handler fired whenever a {{Event("fetch")}} event occurs — when a {{domxref("GlobalFetch.fetch", "fetch()")}} is called.
- {{domxref("ServiceWorkerGlobalScope.oninstall")}}
- : An event handler fired whenever an {{Event("install")}} event occurs — when a {{domxref("ServiceWorkerRegistration")}} acquires a new {{domxref("ServiceWorkerRegistration.installing")}} worker.
- {{domxref("ServiceWorkerGlobalScope.onmessage")}}
- : An event handler fired whenever a [`message`](/zh-CN/docs/Web/API/BroadcastChannel/message_event) event occurs — when incoming messages are received. Controlled pages can use the {{domxref("MessagePort.postMessage()")}} method to send messages to service workers. The service worker can optionally send a response back via the {{domxref("MessagePort")}} exposed in [`event.data.port`](https://html.spec.whatwg.org/multipage/comms.html#messageport), corresponding to the controlled page.
- {{domxref("ServiceWorkerGlobalScope.onnotificationclick")}}
- : An event handler fired whenever a {{Event("notificationclick")}} event occurs — when a user clicks on a displayed notification.
- {{domxref("ServiceWorkerGlobalScope.onnotificationclose")}}
- : An event handler fired whenever a {{Event("notificationclose")}} event occurs — when a user closes a displayed notification.
- {{domxref("ServiceWorkerGlobalScope.onpush")}}
- : An event handler fired whenever a {{Event("push")}} event occurs — when a server push notification is received.
- {{domxref("ServiceWorkerGlobalScope.onpushsubscriptionchange")}}
- : An event handler fired whenever a {{Event("pushsubscriptionchange")}} event occurs — when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time.)
- {{domxref("ServiceWorkerGlobalScope.onsync")}}
- : An event handler fired whenever a {{Event("SyncEvent")}} event occurs. This is triggered when a call to {{domxref("SyncManager.register")}} is made from a service worker client page. The attempt to sync is made either immediately if the network is available or as soon as the network becomes available.
## 事件

- {{domxref("ServiceWorkerGlobalScope/activate_event", "activate")}}
- : Occurs when a {{domxref("ServiceWorkerRegistration")}} acquires a new {{domxref("ServiceWorkerRegistration.active")}} worker.
- {{domxref("ServiceWorkerGlobalScope/contentdelete_event", "contentdelete")}} {{Experimental_Inline}}
- : Occurs when an item is removed from the {{domxref("ContentIndex", "Content Index")}}.
- {{domxref("ServiceWorkerGlobalScope/fetch_event", "fetch")}}
- : Occurs when a {{domxref("fetch()")}} is called.
- {{domxref("ServiceWorkerGlobalScope/install_event", "install")}}
- : Occurs when a {{domxref("ServiceWorkerRegistration")}} acquires a new {{domxref("ServiceWorkerRegistration.installing")}} worker.
- {{domxref("ServiceWorkerGlobalScope/message_event", "message")}}
- : Occurs when incoming messages are received. Controlled pages can use the {{domxref("MessagePort.postMessage()")}} method to send messages to service workers. The service worker can optionally send a response back via the {{domxref("MessagePort")}} exposed in [`event.data.port`](https://html.spec.whatwg.org/multipage/comms.html#messageport), corresponding to the controlled page.
- {{domxref("ServiceWorkerGlobalScope/notificationclick_event", "notificationclick")}}
- : Occurs when a user clicks on a displayed notification.
- {{domxref("ServiceWorkerGlobalScope/notificationclose_event", "notificationclose")}}
- : Occurs when a user closes a displayed notification.
- {{domxref("ServiceWorkerGlobalScope/sync_event", "sync")}}
- : Triggered when a call to {{domxref("SyncManager.register")}} is made from a service worker client page. The attempt to sync is made either immediately if the network is available or as soon as the network becomes available.
- {{domxref("ServiceWorkerGlobalScope/periodicsync_event", "periodicsync")}} {{Experimental_Inline}}
- : Occurs at periodic intervals, which were specified when registering a {{domxref("PeriodicSyncManager")}}.
- {{domxref("ServiceWorkerGlobalScope/push_event", "push")}}
- : Occurs when a server push notification is received.
- {{domxref("ServiceWorkerGlobalScope/pushsubscriptionchange_event", "pushsubscriptionchange")}}
- : Occurs when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time).

## 方法

Expand Down
27 changes: 15 additions & 12 deletions files/zh-cn/web/api/videotracklist/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ _This interface also inherits properties from its parent interface, {{domxref("E
- {{domxref("VideoTrackList.selectedIndex", "selectedIndex")}} {{ReadOnlyInline}}
- : The index of the currently selected track, if any, or `−1` otherwise.

## Event handlers
## 事件

- {{domxref("VideoTrackList.onaddtrack", "onaddtrack")}}
- : An event handler to be called when the {{event("addtrack")}} event is fired, indicating that a new video track has been added to the media element.
- {{domxref("VideoTrackList.onchange", "onchange")}}
- : An event handler to be called when the [`change`](/zh-CN/docs/Web/API/HTMLElement/change_event) event occurs — that is, when the value of the {{domxref("VideoTrack.selected", "selected")}} property for a track has changed, due to the track being made active or inactive.
- {{domxref("VideoTrackList.onremovetrack", "onremovetrack")}}
- : An event handler to call when the {{event("removetrack")}} event is sent, indicating that a video track has been removed from the media element.
- {{domxref("VideoTrackList/addtrack_event", "addtrack")}}
- : Fired when a new video track has been added to the media element.
Also available via the `onaddtrack` property.
- {{domxref("VideoTrackList.change_event", "change")}}
- : Fired when a video track has been made active or inactive.
Also available via the `onchange` property.
- {{domxref("VideoTrackList/removetrack_event", "removetrack")}}
- : Fired when a new video track has been removed from the media element.
Also available via the `onremovetrack` property.

## Methods

Expand All @@ -48,9 +51,9 @@ _This interface also inherits methods from its parent interface, {{domxref("Even

## Usage notes

In addition to being able to obtain direct access to the video tracks present on a media element, `VideoTrackList` lets you set event handlers on the {{event("addtrack")}} and {{event("removetrack")}} events, so that you can detect when tracks are added to or removed from the media element's stream. See {{domxref("VideoTrackList.onaddtrack", "onaddtrack")}} and {{domxref("VideoTrackList.onremovetrack", "onremovetrack")}} for details and examples.
In addition to being able to obtain direct access to the video tracks present on a media element, `VideoTrackList` lets you set event handlers on the {{domxref("VideoTrackList/addtrack_event", "addtrack")}} and {{domxref("VideoTrackList/removetrack_event", "removetrack")}} events, so that you can detect when tracks are added to or removed from the media element's stream.

## Examples
## 示例

### Getting a media element's video track list

Expand All @@ -62,7 +65,7 @@ var videoTracks = document.querySelector("video").videoTracks;

### Monitoring track count changes

In this example, we have an app that displays information about the number of channels available. To keep it up to date, handlers for the {{event("addtrack")}} and {{event("removetrack")}} events are set up.
In this example, we have an app that displays information about the number of channels available. To keep it up to date, handlers for the {{domxref("VideoTrackList/addtrack_event", "addtrack")}} and {{domxref("VideoTrackList/removetrack_event", "removetrack")}} events are set up.

```js
videoTracks.onaddtrack = updateTrackCount;
Expand All @@ -74,10 +77,10 @@ function updateTrackCount(event) {
}
```

## Specifications
## 规范

{{Specifications}}

## Browser compatibility
## 浏览器兼容性

{{Compat}}
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/web_speech_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Web Speech API 使 Web 应用能够处理语音数据,该项 API 包含以下
- {{domxref("SpeechRecognitionError")}}
- : 表示语音识别服务发出的报错信息。
- {{domxref("SpeechRecognitionEvent")}}
- : {{event("result")}} 和 {{event("nomatch")}} 的事件对象,包含了与语音识别过程中间或最终结果相关的全部数据。
- : {{domxref("SpeechRecognition.result_event", "result")}} 和 {{domxref("SpeechRecognition.nomatch_event", "nomatch")}} 的事件对象,包含了与语音识别过程中间或最终结果相关的全部数据。
- {{domxref("SpeechGrammar")}}
- : 我们将要交由语音识别服务进行识别的词汇或者词汇的模式。
- {{domxref("SpeechGrammarList")}}
Expand Down
Loading

0 comments on commit 1018ce3

Please sign in to comment.