Skip to content

Commit

Permalink
zh-cn: Format /web/api using Prettier (part 10) (#14684)
Browse files Browse the repository at this point in the history
Co-authored-by: Allo <[email protected]>
  • Loading branch information
queengooborg and yin1999 authored Jul 30, 2023
1 parent 1b8c94d commit 25ba236
Show file tree
Hide file tree
Showing 106 changed files with 2,318 additions and 1,962 deletions.
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,3 @@ build/
/files/ru/web/http/**/*.md
/files/ru/web/javascript/**/*.md
/files/ru/web/svg/**/*.md

# zh-cn
/files/zh-cn/web/api/**/*.md
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/element/getboundingclientrect/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ slug: Web/API/Element/getBoundingClientRect

## 语法

```js
```js-nolint
getBoundingClientRect()
```

Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/filelist/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ for (var i = 0; i < files.length; i++) {
下面是一个更完整的例子。

```html
<!DOCTYPE html>
<!doctype html>
<html>
<head> </head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion files/zh-cn/web/api/htmlmediaelement/seekable/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var video = document.querySelector("video");
var timeRangesObject = video.seekable;
var timeRanges = [];
//遍历所有时间区域并输出数组
for (let count = 0; count < timeRangesObject.length; count ++) {
for (let count = 0; count < timeRangesObject.length; count++) {
timeRanges.push([timeRangesObject.start(count), timeRangesObject.end(count)]);
}
```
Expand Down
14 changes: 7 additions & 7 deletions files/zh-cn/web/api/mediasource/mediasource/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ new MediaSource()
以下片段基于 Nick Desaulniers 编写的一个简单示例([查看完整的在线演示](https://nickdesaulniers.github.io/netfix/demo/bufferAll.html),或者[下载源代码](https://github.com/nickdesaulniers/netfix/blob/gh-pages/demo/bufferAll.html)进行进一步研究)。

```js
var video = document.querySelector('video');
var video = document.querySelector("video");

var assetURL = 'frag_bunny.mp4';
var assetURL = "frag_bunny.mp4";
// Need to be specific for Blink regarding codecs
// ./mp4info frag_bunny.mp4 | grep Codec
var mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';

if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {
var mediaSource = new MediaSource;
if ("MediaSource" in window && MediaSource.isTypeSupported(mimeCodec)) {
var mediaSource = new MediaSource();
//console.log(mediaSource.readyState); // closed
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', sourceOpen);
mediaSource.addEventListener("sourceopen", sourceOpen);
} else {
console.error('Unsupported MIME type or codec: ', mimeCodec);
console.error("Unsupported MIME type or codec: ", mimeCodec);
}

//
Expand All @@ -45,7 +45,7 @@ if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {

{{Compat}}

## 相关链接
## 参见

- {{domxref("SourceBuffer")}}
- {{domxref("SourceBufferList")}}
8 changes: 3 additions & 5 deletions files/zh-cn/web/api/node/textcontent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ someOtherNode.textContent = string;

此外,使用 `textContent` 可以防止 [XSS 攻击](/zh-CN/docs/Glossary/Cross-site_scripting)

## 例子
## 示例

给出这个 HTML 片段:

```html
<div id="divA">
This is <span>some</span> text!
</div>
<div id="divA">This is <span>some</span> text!</div>
```

你可以使用 `textContent` 去获取该元素的文本内容:
Expand Down Expand Up @@ -116,7 +114,7 @@ if (

{{Compat}}

## 相关链接
## 参见

- {{domxref("HTMLElement.innerText")}}
- {{domxref("Element.innerHTML")}}
Expand Down
12 changes: 6 additions & 6 deletions files/zh-cn/web/api/subtlecrypto/unwrapkey/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function getKeyMaterial() {
enc.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
["deriveBits", "deriveKey"],
);
}

Expand All @@ -156,7 +156,7 @@ async function getUnwrappingKey() {
keyMaterial,
{ name: "AES-KW", length: 256 },
true,
["wrapKey", "unwrapKey"]
["wrapKey", "unwrapKey"],
);
}

Expand All @@ -178,7 +178,7 @@ async function unwrapSecretKey(wrappedKey) {
"AES-KW", // 加密密钥时使用的算法
"AES-GCM", // 解包密钥使用的算法
true, // 解包后的密钥的可导出性
["encrypt", "decrypt"] // 解包后的密钥的用途
["encrypt", "decrypt"], // 解包后的密钥的用途
);
}
```
Expand Down Expand Up @@ -314,7 +314,7 @@ function getKeyMaterial() {
enc.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
["deriveBits", "deriveKey"],
);
}

Expand All @@ -339,7 +339,7 @@ async function getUnwrappingKey() {
keyMaterial,
{ name: "AES-GCM", length: 256 },
true,
["wrapKey", "unwrapKey"]
["wrapKey", "unwrapKey"],
);
}

Expand Down Expand Up @@ -371,7 +371,7 @@ async function unwrapPrivateKey(wrappedKey) {
hash: "SHA-256",
},
true, // 解包后的密钥的可导出性
["sign"] // 解包后的密钥的用途
["sign"], // 解包后的密钥的用途
);
}
```
Expand Down
10 changes: 5 additions & 5 deletions files/zh-cn/web/api/subtlecrypto/verify/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function getMessageEncoding() {
*/
async function verifyMessage(publicKey) {
const signatureValue = document.querySelector(
".rsassa-pkcs1 .signature-value"
".rsassa-pkcs1 .signature-value",
);
signatureValue.classList.remove("valid", "invalid");

Expand All @@ -82,7 +82,7 @@ async function verifyMessage(publicKey) {
"RSASSA-PKCS1-v1_5",
publicKey,
signature,
encoded
encoded,
);

signatureValue.classList.add(result ? "valid" : "invalid");
Expand Down Expand Up @@ -122,7 +122,7 @@ async function verifyMessage(publicKey) {
},
publicKey,
signature,
encoded
encoded,
);

signatureValue.classList.add(result ? "valid" : "invalid");
Expand Down Expand Up @@ -162,7 +162,7 @@ async function verifyMessage(publicKey) {
},
publicKey,
signature,
encoded
encoded,
);

signatureValue.classList.add(result ? "valid" : "invalid");
Expand Down Expand Up @@ -199,7 +199,7 @@ async function verifyMessage(key) {
"HMAC",
key,
signature,
encoded
encoded,
);

signatureValue.classList.add(result ? "valid" : "invalid");
Expand Down
24 changes: 12 additions & 12 deletions files/zh-cn/web/api/subtlecrypto/wrapkey/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function getKeyMaterial() {
enc.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
["deriveBits", "deriveKey"],
);
}

Expand All @@ -111,7 +111,7 @@ function getKey(keyMaterial, salt) {
keyMaterial,
{ name: "AES-KW", length: 256 },
true,
["wrapKey", "unwrapKey"]
["wrapKey", "unwrapKey"],
);
}

Expand All @@ -137,7 +137,7 @@ window.crypto.subtle
length: 256,
},
true,
["encrypt", "decrypt"]
["encrypt", "decrypt"],
)
.then((secretKey) => wrapCryptoKey(secretKey))
.then((wrappedKey) => console.log(wrappedKey));
Expand All @@ -163,7 +163,7 @@ function getKeyMaterial() {
enc.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
["deriveBits", "deriveKey"],
);
}

Expand All @@ -181,7 +181,7 @@ function getKey(keyMaterial, salt) {
keyMaterial,
{ name: "AES-GCM", length: 256 },
true,
["wrapKey", "unwrapKey"]
["wrapKey", "unwrapKey"],
);
}

Expand Down Expand Up @@ -214,7 +214,7 @@ window.crypto.subtle
hash: "SHA-256",
},
true,
["sign", "verify"]
["sign", "verify"],
)
.then((keyPair) => wrapCryptoKey(keyPair.privateKey))
.then((wrappedKey) => {
Expand Down Expand Up @@ -242,7 +242,7 @@ function getKeyMaterial() {
enc.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
["deriveBits", "deriveKey"],
);
}

Expand All @@ -260,7 +260,7 @@ function getKey(keyMaterial, salt) {
keyMaterial,
{ name: "AES-CBC", length: 256 },
true,
["wrapKey", "unwrapKey"]
["wrapKey", "unwrapKey"],
);
}

Expand Down Expand Up @@ -293,7 +293,7 @@ window.crypto.subtle
hash: "SHA-256",
},
true,
["encrypt", "decrypt"]
["encrypt", "decrypt"],
)
.then((keyPair) => wrapCryptoKey(keyPair.publicKey))
.then((wrappedKey) => console.log(wrappedKey));
Expand All @@ -319,7 +319,7 @@ function getKeyMaterial() {
enc.encode(password),
{ name: "PBKDF2" },
false,
["deriveBits", "deriveKey"]
["deriveBits", "deriveKey"],
);
}

Expand All @@ -337,7 +337,7 @@ function getKey(keyMaterial, salt) {
keyMaterial,
{ name: "AES-GCM", length: 256 },
true,
["wrapKey", "unwrapKey"]
["wrapKey", "unwrapKey"],
);
}

Expand Down Expand Up @@ -367,7 +367,7 @@ window.crypto.subtle
namedCurve: "P-384",
},
true,
["sign", "verify"]
["sign", "verify"],
)
.then((keyPair) => wrapCryptoKey(keyPair.privateKey))
.then((wrappedKey) => console.log(wrappedKey));
Expand Down
4 changes: 2 additions & 2 deletions files/zh-cn/web/api/svgaelement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ See {{domxref("HTMLAnchorElement.href")}}
var linkRef = document.querySelector("a");
linkRef.target = "_self";

linkRef.onclick = function(){
linkRef.onclick = function () {
if (linkRef.target === "_blank") {
console.log("BLANK!");
linkRef.target = "_self";
} else {
console.log("SORRY! not _blank");
}
}
};
```

## 规范
Expand Down
6 changes: 3 additions & 3 deletions files/zh-cn/web/api/svgcircleelement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ slug: Web/API/SVGCircleElement

## 属性

| 名称 | 类型 | 描述 |
| ---- | -------------------------------------------- | -------------------------------------------------------------------------------- |
| 名称 | 类型 | 描述 |
| ---- | ---------------------------------- | ----------------------------------------------------------------- |
| `cx` | {{ domxref("SVGAnimatedLength") }} | 对应于给定{{ SVGElement("circle") }}元素的{{ SVGAttr("cx") }}属性 |
| `cy` | {{ domxref("SVGAnimatedLength") }} | 对应于给定{{ SVGElement("circle") }}元素的{{ SVGAttr("cy") }}属性 |
| `r` | {{ domxref("SVGAnimatedLength") }} | 对应于给定{{ SVGElement("circle") }}元素的{{ SVGAttr("r") }}属性 |
| `r` | {{ domxref("SVGAnimatedLength") }} | 对应于给定{{ SVGElement("circle") }}元素的{{ SVGAttr("r") }}属性 |

## 方法

Expand Down
10 changes: 5 additions & 5 deletions files/zh-cn/web/api/svgevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ slug: Web/API/SVGEvent

## Properties

| Property | Type | Description |
| ------------------------------------- | ------------------------------------ | -------------------------- |
| Property | Type | Description |
| ------------------------------- | -------------------------- | -------------------------- |
| `target` {{readonlyInline}} | {{domxref("EventTarget")}} | 事件目标(DOM 树的最顶端) |
| `type` {{readonlyInline}} | {{domxref("DOMString")}} | 事件类型 |
| `bubbles` {{readonlyInline}} | {{jsxref("Boolean")}} | 事件是否冒泡 |
| `cancelable` {{readonlyInline}} | {{jsxref("Boolean")}} | 事件是否可取消 |
| `type` {{readonlyInline}} | {{domxref("DOMString")}} | 事件类型 |
| `bubbles` {{readonlyInline}} | {{jsxref("Boolean")}} | 事件是否冒泡 |
| `cancelable` {{readonlyInline}} | {{jsxref("Boolean")}} | 事件是否可取消 |
Loading

0 comments on commit 25ba236

Please sign in to comment.