Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(zh-cn): add language tags for fenced codes (part 2) #23192

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions files/zh-cn/web/api/baseaudiocontext/decodeaudiodata/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@ slug: Web/API/BaseAudioContext/decodeAudioData

## 语法

旧版的回调函数语法
```js-nolint
// 基于 Promise 的语法返回一个 Promise:
decodeAudioData(arrayBuffer)

```
audioCtx.decodeAudioData(audioData, function(decodedData) {
// use the decoded data here
});
```

新版的 promise-based 语法:

```
audioCtx.decodeAudioData(audioData).then(function(decodedData) {
// use the decoded data here
});
// 回调语法没有返回值:
decodeAudioData(arrayBuffer, successCallback)
decodeAudioData(arrayBuffer, successCallback, errorCallback)
```

## 举例
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ data 属性返回一个 {{jsxref("Uint8ClampedArray")}},它可以被使用作

例如,要读取图片中位于第 50 行,第 200 列的像素的蓝色部份,你会写以下代码:

```
blueComponent = imageData.data[((50 * (imageData.width * 4)) + (200 * 4)) + 2];
```js
blueComponent = imageData.data[50 * (imageData.width * 4) + 200 * 4 + 2];
yin1999 marked this conversation as resolved.
Show resolved Hide resolved
```

根据行、列读取某像素点的 R/G/B/A 值的公式:

```
imageData.data[((50 * (imageData.width * 4)) + (200 * 4)) + 0/1/2/3];
```js
imageData.data[50 * (imageData.width * 4) + 200 * 4 + 0 / 1 / 2 / 3];
```

你可能用会使用 `Uint8ClampedArray.length` 属性来读取像素数组的大小(以字节为单位):
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/clipboard/writetext/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ slug: Web/API/Clipboard/writeText

## 语法

```
var promise = navigator.clipboard.writeText(newClipText)
```js-nolint
writeText(newClipText)
```

### 参数
Expand Down
6 changes: 0 additions & 6 deletions files/zh-cn/web/api/clipboardevent/clipboarddata/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ slug: Web/API/ClipboardEvent/clipboardData

参见 [`cut`](/zh-CN/docs/Web/API/Element/cut_event) 、[`copy`](/zh-CN/docs/Web/API/Element/copy_event) 和 [`paste`](/zh-CN/docs/Web/API/Element/paste_event) 事件的文档以获取更多信息。

## 语法

```
data = ClipboardEvent.clipboardData
```

## 规范

{{Specifications}}
Expand Down
5 changes: 3 additions & 2 deletions files/zh-cn/web/api/clipboardevent/clipboardevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ slug: Web/API/ClipboardEvent/ClipboardEvent

## 语法

```
var clipboardEvent = new ClipboardEvent(type[, options]);
```js-nolint
new ClipboardEvent(type)
new ClipboardEvent(type, options)
```

### 参数
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/console/count_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ console.count();

控制台输出看起来像这样:

```
```plain
"default: 1"
"default: 2"
"default: 3"
Expand Down Expand Up @@ -76,7 +76,7 @@ console.count("alice");

我们会看到如下的输出:

```
```plain
"bob: 1"
"alice: 1"
"alice: 2"
Expand Down
10 changes: 5 additions & 5 deletions files/zh-cn/web/api/console/error_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ slug: Web/API/console/error_static

## 语法

```
console.error(obj1 [, obj2, ..., objN]);
console.error(msg [, subst1, ..., substN]);
console.exception(obj1 [, obj2, ..., objN]);
console.exception(msg [, subst1, ..., substN]);
```js-noline
yin1999 marked this conversation as resolved.
Show resolved Hide resolved
error(val1)
error(val1, /* …, */ valN)
error(msg)
error(msg, subst1, /* …, */ substN)
```

> **备注:** `console.exception()` 是 `console.error()` 的别名;它们功能相同。
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/css/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ CSS 接口是一个工具接口,无法创建该类型的对象:其内部只

- : 可以用来返回一个 [`CSSUnitValue`](/zh-CN/docs/Web/API/CSSUnitValue)。它的值由传入的数值以及调用的 factory 方法名称组成。

```
CSS.em(3) // CSSUnitValue {value: 3, unit: "em"}
```js
CSS.em(3); // CSSUnitValue {value: 3, unit: "em"}
```

## 规范
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/cssrule/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ An up-to-date informal list of constants can be found on the [CSSWG Wiki](https:

使用 [WebIDL](https://dev.w3.org/2006/webapi/WebIDL/) 语法格式进行描述。

```
```plain
interface CSSRule {
const unsigned short STYLE_RULE = 1;
const unsigned short CHARSET_RULE = 2;
Expand Down
57 changes: 3 additions & 54 deletions files/zh-cn/web/api/cssstylesheet/insertrule/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ slug: Web/API/CSSStyleSheet/insertRule

## 语法

```
stylesheet.insertRule(rule [, index])
```js-nolint
insertRule(rule)
insertRule(rule, index)
```

### 参数
Expand Down Expand Up @@ -105,52 +106,6 @@ function addStylesheetRules(decls) {
}
```

## 兼容补丁

以下补丁将会在 IE 5-8 中纠正提供给 `insertRule()` 的参数,使其标准化。to standardize them in Internet Explorer 5–8. 它通过一个函数对 `insertRule()` 进行补充,使得在参数传递给原生的 `insertRule()` 函数之前将其中的选择器从规则中分离出来。

```
(function(Sheet_proto){
var originalInsertRule = Sheet_proto.insertRule;

if (originalInsertRule.length === 2){ // 2 个托管参数: (selector, rules)
Sheet_proto.insertRule = function(selectorAndRule){
// 首先,从规则中分离选择器
a: for (var i=0, Len=selectorAndRule.length, isEscaped=0, newCharCode=0; i !== Len; ++i) {
newCharCode = selectorAndRule.charCodeAt(i);
if (!isEscaped && (newCharCode === 123)) { // 123 = "{".charCodeAt(0)
// 其次,找到花括号
var openBracketPos = i, closeBracketPos = -1;

for (; i !== Len; ++i) {
newCharCode = selectorAndRule.charCodeAt(i);
if (!isEscaped && (newCharCode === 125)) { // 125 = "}".charCodeAt(0)
closeBracketPos = i;
}
isEscaped ^= newCharCode===92?1:isEscaped; // 92 = "\\".charCodeAt(0)
}

if (closeBracketPos === -1) break a; // No closing bracket was found!
/*else*/ return originalInsertRule.call(
this, // 想要改变的样式表
selectorAndRule.substring(0, openBracketPos), // 选择器
selectorAndRule.substring(closeBracketPos), // 规则
arguments[3] // 插入的索引
);
}

// Works by if the char code is a backslash, then isEscaped
// gets flipped (XOR-ed by 1), and if it is not a backslash
// then isEscaped gets XORed by itself, zeroing it
isEscaped ^= newCharCode===92?1:isEscaped; // 92 = "\\".charCodeAt(0)
}
// Else, there is no unescaped bracket
return originalInsertRule.call(this, selectorAndRule, "", arguments[2]);
};
}
})(CSSStyleSheet.prototype);
```

## 规范

{{Specifications}}
Expand All @@ -159,12 +114,6 @@ function addStylesheetRules(decls) {

{{Compat}}

### 传统浏览器支持

为了支持 Internet Explorer 8 和更早版本,请使用:`addRule(selector, rule [, index]);`。例如:`addRule('pre', 'font: 14px verdana'); // add rule at end`

另外注意非标准的 [`removeRule()`](http://www.quirksmode.org/dom/w3c_css.html#change) 和 [`.rules`](http://www.quirksmode.org/dom/w3c_css.html#access) 方法分别用 {{domxref("CSSStyleSheet.deleteRule","deleteRule()")}} 和{{domxref("CSSStyleSheet",".cssRules")}} 代替。

## 参见

- {{domxref("CSSStyleSheet.deleteRule")}}
Expand Down
5 changes: 3 additions & 2 deletions files/zh-cn/web/api/customelementregistry/define/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ slug: Web/API/CustomElementRegistry/define

## 语法

```
customElements.define(name, constructor, options);
```js-nolint
define(name, constructor)
define(name, constructor, options)
```

### 参数
Expand Down
14 changes: 7 additions & 7 deletions files/zh-cn/web/api/customevent/initcustomevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ slug: Web/API/CustomEvent/initCustomEvent
>
> Instead use specific event constructors, like {{domxref("CustomEvent.CustomEvent", "CustomEvent()")}}. The page on [Creating and triggering events](/zh-CN/docs/Web/Guide/Events/Creating_and_triggering_events) gives more information about the way to use these.

## Syntax
## 语法

```
event.initCustomEvent(type, canBubble, cancelable, detail);
```js-nolint
event.initCustomEvent(type, canBubble, cancelable, detail)
```

### Parameters
### 参数

- `type`
- : 类型{{domxref("DOMString")}},事件名称。
Expand All @@ -30,15 +30,15 @@ event.initCustomEvent(type, canBubble, cancelable, detail);
- _`detail`_
- : 事件初始化时传入的数据。

## Specifications
## 规范

{{Specifications}}

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

{{Compat}}

## See also
## 参见

- {{domxref("CustomEvent")}}
- The constructor to use instead of this deprecated method: {{domxref("CustomEvent.CustomEvent", "CustomEvent()")}}.
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/datatransfer/setdata/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ slug: Web/API/DataTransfer/setData

## 语法

```
void dataTransfer.setData(format, data);
```js-nolint
setData(format, data)
```

### 参数
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/datatransfer/setdragimage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ slug: Web/API/DataTransfer/setDragImage

## 语法

```
void dataTransfer.setDragImage(img, xOffset, yOffset);
```js-nolint
setDragImage(imgElement, xOffset, yOffset)
```

### 参数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ slug: Web/API/DataTransferItem/webkitGetAsEntry

## 语法

```
DataTransferItem.webkitGetAsEntry();
```js-nolint
webkitGetAsEntry()
```

### 参数
Expand Down
6 changes: 0 additions & 6 deletions files/zh-cn/web/api/devicemotionevent/acceleration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ acceleration 属性会返回设备的加速度记录(单位:[m / s2](https:/
> [!NOTE]
> 如果硬件无法从 acceleration 数据中移除重力加速度,则该值在{{ domxref("DeviceMotionEvent") }}中可能并不存在,你应当使用{{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }}代替

## 语法

```
var acceleration = instanceOfDeviceMotionEvent.acceleration;
```

## 值

`acceleration`是一个包括三轴(x、y、z)加速度信息的对象,每个轴都有自己的属性:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ The **`DeviceMotionEvent`** constructor 会创建一个新的 {{DOMxRef("DeviceM

## 语法

```
var deviceMotionEvent = new DeviceMotionEvent(type[, options])
```js-nolint
new DeviceMotionEvent(type)
new DeviceMotionEvent(type, options)
```

### 参数
Expand Down
6 changes: 0 additions & 6 deletions files/zh-cn/web/api/devicemotionevent/rotationrate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ slug: Web/API/DeviceMotionEvent/rotationRate
> [!NOTE]
> 如果设备无法提供此信息,则为 null

## 语法

```
var rates = instanceOfDeviceMotionEvent.rotationRate;
```

## 值

rotationRates 属性是一个只读对象,用于描述设备围绕其每个轴的旋转速率:
Expand Down
5 changes: 3 additions & 2 deletions files/zh-cn/web/api/document/createelement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ slug: Web/API/Document/createElement

## 语法

```
var element = document.createElement(tagName[, options]);
```js-nolint
createElement(tagName)
createElement(tagName, options)
```

### 参数
Expand Down
10 changes: 2 additions & 8 deletions files/zh-cn/web/api/document/evaluate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ slug: Web/API/Document/evaluate

## 语法

```
var xpathResult = document.evaluate(
xpathExpression,
contextNode,
namespaceResolver,
resultType,
result
);
```js-nolint
evaluate(xpathExpression, contextNode, namespaceResolver, resultType, result)
```

- `xpathExpression` 表示要计算的 Xpath 字符串。
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/document/getelementsbytagname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ slug: Web/API/Document/getElementsByTagName

## 语法

```
var elements = document.getElementsByTagName(name);
```js-nolint
getElementsByTagName(name)
```

- `elements` 是一个由发现的元素出现在树中的顺序构成的动态的 HTML 集合 {{domxref("HTMLCollection")}} (但是看下面的提示) 。
Expand Down
10 changes: 2 additions & 8 deletions files/zh-cn/web/api/document/getelementsbytagnamens/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@ slug: Web/API/Document/getElementsByTagNameNS

{{ ApiRef("DOM") }}

```
Firefox 3.6 note

请参阅 Notes section of element.getElementsByTagNameNS 中的更改,这些更改同时适用于 Firefox 3.6 的 API.
```

返回带有指定名称和命名空间的元素集合。整个文件结构都会被搜索,包括根节点。

## 语法

```
elements = document.getElementsByTagNameNS(namespace, name)
```js-nolint
getElementsByTagNameNS(namespace, name)
```

- `elements` 是一个在树中按顺序查询到的动态的 HTML 集合 [`HTMLCollection`](/zh-CN/docs/Web/API/HTMLCollection) (但是看下面的提示)。
Expand Down
Loading