From cad23444a9ff3f3a3f2959c171155cafa91ef57b Mon Sep 17 00:00:00 2001 From: MDN Web Docs GitHub Bot <108879845+mdn-bot@users.noreply.github.com> Date: Tue, 21 Nov 2023 11:59:24 +0100 Subject: [PATCH 01/93] [zh-cn] sync translated content (#17052) Co-authored-by: Jason Ren <40999116+jasonren0403@users.noreply.github.com> --- files/zh-cn/_redirects.txt | 16 +- files/zh-cn/_wikihistory.json | 24 +- .../web/api/history_api/example/index.md | 438 ------------------ .../working_with_the_history_api/index.md | 1 - .../web/api/window/popstate_event/index.md | 1 - files/zh-cn/web/guide/ajax/index.md | 2 - .../{compile => compile_static}/index.md | 2 +- .../index.md | 2 +- .../index.md | 2 +- .../index.md | 2 +- .../javascript_interface/module/index.md | 4 +- .../javascript_interface/table/index.md | 2 +- .../{validate => validate_static}/index.md | 8 +- 13 files changed, 32 insertions(+), 472 deletions(-) delete mode 100644 files/zh-cn/web/api/history_api/example/index.md rename files/zh-cn/webassembly/javascript_interface/{compile => compile_static}/index.md (98%) rename files/zh-cn/webassembly/javascript_interface/{compilestreaming => compilestreaming_static}/index.md (97%) rename files/zh-cn/webassembly/javascript_interface/{instantiate => instantiate_static}/index.md (99%) rename files/zh-cn/webassembly/javascript_interface/{instantiatestreaming => instantiatestreaming_static}/index.md (98%) rename files/zh-cn/webassembly/javascript_interface/{validate => validate_static}/index.md (94%) diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index 47f9de86039c7e..2dfc76f0de4d9f 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -1617,6 +1617,7 @@ /zh-CN/docs/Web/API/HTMLTableElement.deleteTHead /zh-CN/docs/Web/API/HTMLTableElement/deleteTHead /zh-CN/docs/Web/API/HTMLVideoElement/autoPictureInPicture /zh-CN/docs/Web/API/HTMLVideoElement /zh-CN/docs/Web/API/Headers/getAll /zh-CN/docs/Web/API/Headers/get +/zh-CN/docs/Web/API/History_API/Example /zh-CN/docs/Web/API/History_API/Working_with_the_History_API /zh-CN/docs/Web/API/IDBCursor.direction /zh-CN/docs/Web/API/IDBCursor/direction /zh-CN/docs/Web/API/IDBDatabase/onversionchange /zh-CN/docs/Web/API/IDBDatabase/versionchange_event /zh-CN/docs/Web/API/IDBFactory.open /zh-CN/docs/Web/API/IDBFactory/open @@ -2591,11 +2592,11 @@ /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module /zh-CN/docs/WebAssembly/JavaScript_interface/Module /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError /zh-CN/docs/WebAssembly/JavaScript_interface/RuntimeError /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table /zh-CN/docs/WebAssembly/JavaScript_interface/Table -/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile /zh-CN/docs/WebAssembly/JavaScript_interface/compile -/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming /zh-CN/docs/WebAssembly/JavaScript_interface/compileStreaming -/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate /zh-CN/docs/WebAssembly/JavaScript_interface/instantiate -/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming /zh-CN/docs/WebAssembly/JavaScript_interface/instantiateStreaming -/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate /zh-CN/docs/WebAssembly/JavaScript_interface/validate +/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile /zh-CN/docs/WebAssembly/JavaScript_interface/compile_static +/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming /zh-CN/docs/WebAssembly/JavaScript_interface/compileStreaming_static +/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate /zh-CN/docs/WebAssembly/JavaScript_interface/instantiate_static +/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming /zh-CN/docs/WebAssembly/JavaScript_interface/instantiateStreaming_static +/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate /zh-CN/docs/WebAssembly/JavaScript_interface/validate_static /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/null /zh-CN/docs/Web/JavaScript/Reference/Operators/null /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/uneval /zh-CN/docs/Web/JavaScript/Reference/Global_Objects /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/生成器函数 /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction @@ -2693,6 +2694,11 @@ /zh-CN/docs/Web/性能 /zh-CN/docs/Web/Performance /zh-CN/docs/Web/演示说明 /zh-CN/docs/Web/Demos /zh-CN/docs/WebAPI/Using_geolocation /zh-CN/docs/Web/API/Geolocation_API +/zh-CN/docs/WebAssembly/JavaScript_interface/compile /zh-CN/docs/WebAssembly/JavaScript_interface/compile_static +/zh-CN/docs/WebAssembly/JavaScript_interface/compileStreaming /zh-CN/docs/WebAssembly/JavaScript_interface/compileStreaming_static +/zh-CN/docs/WebAssembly/JavaScript_interface/instantiate /zh-CN/docs/WebAssembly/JavaScript_interface/instantiate_static +/zh-CN/docs/WebAssembly/JavaScript_interface/instantiateStreaming /zh-CN/docs/WebAssembly/JavaScript_interface/instantiateStreaming_static +/zh-CN/docs/WebAssembly/JavaScript_interface/validate /zh-CN/docs/WebAssembly/JavaScript_interface/validate_static /zh-CN/docs/WebAssembly/概念 /zh-CN/docs/WebAssembly/Concepts /zh-CN/docs/WebGL /zh-CN/docs/Web/API/WebGL_API /zh-CN/docs/WebGL/Getting_started_with_WebGL /zh-CN/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index 316a781e06e56e..ea4d243d1e45f5 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -10932,10 +10932,6 @@ "xgqfrms-GitHub" ] }, - "Web/API/History_API/Example": { - "modified": "2019-07-31T00:29:31.092Z", - "contributors": ["Shadowhiker", "xgqfrms"] - }, "Web/API/History_API/Working_with_the_History_API": { "modified": "2020-09-07T23:10:09.451Z", "contributors": ["Nothing_bin"] @@ -32727,23 +32723,23 @@ "modified": "2020-11-04T03:44:08.051Z", "contributors": ["moniang", "hurrytospring"] }, - "WebAssembly/JavaScript_interface/compile": { - "modified": "2020-10-15T21:58:44.128Z", - "contributors": ["kungfucode-rex"] - }, - "WebAssembly/JavaScript_interface/compileStreaming": { + "WebAssembly/JavaScript_interface/compileStreaming_static": { "modified": "2020-10-15T22:15:30.451Z", "contributors": ["Cyandev"] }, - "WebAssembly/JavaScript_interface/instantiate": { - "modified": "2020-10-15T21:57:59.458Z", - "contributors": ["wallena3", "Hedgehog", "airt", "kungfucode-rex"] + "WebAssembly/JavaScript_interface/compile_static": { + "modified": "2020-10-15T21:58:44.128Z", + "contributors": ["kungfucode-rex"] }, - "WebAssembly/JavaScript_interface/instantiateStreaming": { + "WebAssembly/JavaScript_interface/instantiateStreaming_static": { "modified": "2020-10-15T22:11:30.410Z", "contributors": ["Xiaoming666"] }, - "WebAssembly/JavaScript_interface/validate": { + "WebAssembly/JavaScript_interface/instantiate_static": { + "modified": "2020-10-15T21:57:59.458Z", + "contributors": ["wallena3", "Hedgehog", "airt", "kungfucode-rex"] + }, + "WebAssembly/JavaScript_interface/validate_static": { "modified": "2020-10-15T22:15:29.365Z", "contributors": ["Cyandev"] }, diff --git a/files/zh-cn/web/api/history_api/example/index.md b/files/zh-cn/web/api/history_api/example/index.md deleted file mode 100644 index ca922fdfb2ab4b..00000000000000 --- a/files/zh-cn/web/api/history_api/example/index.md +++ /dev/null @@ -1,438 +0,0 @@ ---- -title: Ajax navigation example -slug: Web/API/History_API/Example ---- - -这是一个仅由三个页面组成的 AJAX 网站示例 (_first_page.php_, _second_page.php_ and _third_page.php_). 要查看其如何工作的,请创建以下文件 (或 git clone [https://github.com/giabao/mdn-ajax-nav-example.git](https://github.com/giabao/mdn-ajax-nav-example) ): - -> **备注:** 为了在该机制中很好地整合 {{HTMLElement("form")}} 元素 , 请看一下这段[提交表单和上传文件](/zh-CN/docs/Web/API/XMLHttpRequest_API/Using_XMLHttpRequest#提交表单和上传文件)。 - -**first_page.php**: - -```php - - - - -" . $page_title . ""; -?> - - - - - - -

This paragraph is shown only when the navigation starts from first_page.php.

- -
- - -

This is the content of first_page.php.

- - $page_title, "content" => ob_get_clean())); - } else { -?> -
- -

This paragraph is shown only when the navigation starts from first_page.php.

- -\n"; - } -?> -``` - -**second_page.php**: - -```php - - - - -" . $page_title . ""; -?> - - - - - - -

This paragraph is shown only when the navigation starts from second_page.php.

- -
- - -

This is the content of second_page.php.

- - $page_title, "content" => ob_get_clean())); - } else { -?> -
- -

This paragraph is shown only when the navigation starts from second_page.php.

- -\n"; - } -?> -``` - -**third_page.php**: - -```php -This is the content of third_page.php. This content is stored into a php variable.

"; - - if (isset($_GET["view_as"]) && $_GET["view_as"] == "json") { - echo json_encode(array("page" => $page_title, "content" => $page_content)); - } else { -?> - - - -" . $page_title . ""; -?> - - - - - - -

This paragraph is shown only when the navigation starts from third_page.php.

- -
- -
- -

This paragraph is shown only when the navigation starts from third_page.php.

- -\n"; - } -?> -``` - -**css/style.css**: - -```css -#ajax-loader { - position: fixed; - display: table; - top: 0; - left: 0; - width: 100%; - height: 100%; -} - -#ajax-loader > div { - display: table-cell; - width: 100%; - height: 100%; - vertical-align: middle; - text-align: center; - background-color: #000000; - opacity: 0.65; -} -``` - -**include/after_content.php**: - -```php -

This is the footer. It is shared between all ajax pages.

-``` - -**include/before_content.php**: - -```php -

-[ First example -| Second example -| Third example -| Unexisting page ] -

-``` - -**include/header.php**: - -```php - - - -``` - -**js/ajax_nav.js**: - -```js -"use strict"; - -const ajaxRequest = new (function () { - function closeReq() { - oLoadingBox.parentNode && document.body.removeChild(oLoadingBox); - bIsLoading = false; - } - - function abortReq() { - if (!bIsLoading) { - return; - } - oReq.abort(); - closeReq(); - } - - function ajaxError() { - alert("Unknown error."); - } - - function ajaxLoad() { - var vMsg, - nStatus = this.status; - switch (nStatus) { - case 200: - vMsg = JSON.parse(this.responseText); - document.title = oPageInfo.title = vMsg.page; - document.getElementById(sTargetId).innerHTML = vMsg.content; - if (bUpdateURL) { - history.pushState(oPageInfo, oPageInfo.title, oPageInfo.url); - bUpdateURL = false; - } - break; - default: - vMsg = nStatus + ": " + (oHTTPStatus[nStatus] || "Unknown"); - switch (Math.floor(nStatus / 100)) { - /* - case 1: - // Informational 1xx - console.log("Information code " + vMsg); - break; - case 2: - // Successful 2xx - console.log("Successful code " + vMsg); - break; - case 3: - // Redirection 3xx - console.log("Redirection code " + vMsg); - break; - */ - case 4: - /* Client Error 4xx */ - alert("Client Error #" + vMsg); - break; - case 5: - /* Server Error 5xx */ - alert("Server Error #" + vMsg); - break; - default: - /* Unknown status */ - ajaxError(); - } - } - closeReq(); - } - - function filterURL(sURL, sViewMode) { - return ( - sURL.replace(rSearch, "") + - ( - "?" + - sURL - .replace(rHost, "&") - .replace(rView, sViewMode ? "&" + sViewKey + "=" + sViewMode : "") - .slice(1) - ).replace(rEndQstMark, "") - ); - } - - function getPage(sPage) { - if (bIsLoading) { - return; - } - oReq = new XMLHttpRequest(); - bIsLoading = true; - oReq.onload = ajaxLoad; - oReq.onerror = ajaxError; - if (sPage) { - oPageInfo.url = filterURL(sPage, null); - } - oReq.open("get", filterURL(oPageInfo.url, "json"), true); - oReq.send(); - oLoadingBox.parentNode || document.body.appendChild(oLoadingBox); - } - - function requestPage(sURL) { - if (history.pushState) { - bUpdateURL = true; - getPage(sURL); - } else { - /* Ajax navigation is not supported */ - location.assign(sURL); - } - } - - function processLink() { - if (this.className === sAjaxClass) { - requestPage(this.href); - return false; - } - return true; - } - - function init() { - oPageInfo.title = document.title; - history.replaceState(oPageInfo, oPageInfo.title, oPageInfo.url); - for ( - var oLink, nIdx = 0, nLen = document.links.length; - nIdx < nLen; - document.links[nIdx++].onclick = processLink - ); - } - - const /* customizable constants */ - sTargetId = "ajax-content", - sViewKey = "view_as", - sAjaxClass = "ajax-nav", - /* not customizable constants */ - rSearch = /\?.*$/, - rHost = /^[^\?]*\?*&*/, - rView = new RegExp("&" + sViewKey + "\\=[^&]*|&*$", "i"), - rEndQstMark = /\?$/, - oLoadingBox = document.createElement("div"), - oCover = document.createElement("div"), - oLoadingImg = new Image(), - oPageInfo = { - title: null, - url: location.href, - }, - oHTTPStatus = - /* http://www.iana.org/assignments/http-status-codes/http-status-codes.xml */ { - 100: "Continue", - 101: "Switching Protocols", - 102: "Processing", - 200: "OK", - 201: "Created", - 202: "Accepted", - 203: "Non-Authoritative Information", - 204: "No Content", - 205: "Reset Content", - 206: "Partial Content", - 207: "Multi-Status", - 208: "Already Reported", - 226: "IM Used", - 300: "Multiple Choices", - 301: "Moved Permanently", - 302: "Found", - 303: "See Other", - 304: "Not Modified", - 305: "Use Proxy", - 306: "Reserved", - 307: "Temporary Redirect", - 308: "Permanent Redirect", - 400: "Bad Request", - 401: "Unauthorized", - 402: "Payment Required", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 406: "Not Acceptable", - 407: "Proxy Authentication Required", - 408: "Request Timeout", - 409: "Conflict", - 410: "Gone", - 411: "Length Required", - 412: "Precondition Failed", - 413: "Request Entity Too Large", - 414: "Request-URI Too Long", - 415: "Unsupported Media Type", - 416: "Requested Range Not Satisfiable", - 417: "Expectation Failed", - 422: "Unprocessable Entity", - 423: "Locked", - 424: "Failed Dependency", - 425: "Unassigned", - 426: "Upgrade Required", - 427: "Unassigned", - 428: "Precondition Required", - 429: "Too Many Requests", - 430: "Unassigned", - 431: "Request Header Fields Too Large", - 500: "Internal Server Error", - 501: "Not Implemented", - 502: "Bad Gateway", - 503: "Service Unavailable", - 504: "Gateway Timeout", - 505: "HTTP Version Not Supported", - 506: "Variant Also Negotiates (Experimental)", - 507: "Insufficient Storage", - 508: "Loop Detected", - 509: "Unassigned", - 510: "Not Extended", - 511: "Network Authentication Required", - }; - - var oReq, - bIsLoading = false, - bUpdateURL = false; - - oLoadingBox.id = "ajax-loader"; - oCover.onclick = abortReq; - oLoadingImg.src = - "data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA=="; - oCover.appendChild(oLoadingImg); - oLoadingBox.appendChild(oCover); - - onpopstate = function (oEvent) { - bUpdateURL = false; - oPageInfo.title = oEvent.state.title; - oPageInfo.url = oEvent.state.url; - getPage(); - }; - - window.addEventListener - ? addEventListener("load", init, false) - : window.attachEvent - ? attachEvent("onload", init) - : (onload = init); - - // Public methods - - this.open = requestPage; - this.stop = abortReq; - this.rebuildLinks = init; -})(); -``` - -For more information, please see: [Manipulating the browser history](/zh-CN/docs/DOM/Manipulating_the_browser_history). - -## See also - -- {{ domxref("window.history") }} -- {{ domxref("window.onpopstate") }} diff --git a/files/zh-cn/web/api/history_api/working_with_the_history_api/index.md b/files/zh-cn/web/api/history_api/working_with_the_history_api/index.md index 54795924d25c51..8375f748c2f446 100644 --- a/files/zh-cn/web/api/history_api/working_with_the_history_api/index.md +++ b/files/zh-cn/web/api/history_api/working_with_the_history_api/index.md @@ -103,5 +103,4 @@ const currentState = history.state; ## 参见 - [历史记录 API](/zh-CN/docs/Web/API/History_API) -- [历史导航示例](/zh-CN/docs/Web/API/History_API/Example) - {{domxref("window.history", "history")}} 全局对象 diff --git a/files/zh-cn/web/api/window/popstate_event/index.md b/files/zh-cn/web/api/window/popstate_event/index.md index 661a63523bf962..1ddb2637832bb9 100644 --- a/files/zh-cn/web/api/window/popstate_event/index.md +++ b/files/zh-cn/web/api/window/popstate_event/index.md @@ -55,4 +55,3 @@ history.go(2); // 弹出 "location: http://example.com/example.html?page=3, stat - {{domxref("window.history")}} - [Manipulating the browser history](/zh-CN/docs/Web/API/History_API) -- [Ajax 导航示例](/zh-CN/docs/Web/API/History_API/Example) diff --git a/files/zh-cn/web/guide/ajax/index.md b/files/zh-cn/web/guide/ajax/index.md index 958a51fa26299b..520ba63fa0270c 100644 --- a/files/zh-cn/web/guide/ajax/index.md +++ b/files/zh-cn/web/guide/ajax/index.md @@ -352,8 +352,6 @@ TIME: 312.15 - [监控请求过程](/zh-CN/docs/Web/API/XMLHttpRequest_API/Using_XMLHttpRequest#监控请求过程) - [提交表单或者上传二进制文件](/zh-CN/docs/Web/API/XMLHttpRequest_API/Using_XMLHttpRequest#提交表单和上传文件),使用*纯* Ajax 或者 {{domxref("FormData")}} 对象 - 在 [Web worker](/zh-CN/docs/Web/API/Worker) 中使用 Ajax -- [_纯 Ajax_ 导航示例](/zh-CN/docs/Web/API/History_API/Example) - - : 本文提供了一个仅由三个页面组成的*纯 Ajax* 网站的(最小)工作示例。 - [发送和接收二进制数据](/zh-CN/docs/Web/API/XMLHttpRequest_API/Sending_and_Receiving_Binary_Data) - : `XMLHttpRequest` 对象的 `responseType` 属性可以被设置来改变服务器的预期响应类型。可能的值是空字符串(默认)、`arraybuffer`、`blob`、`document`、`json` 和 `text`。`response` 属性将根据 `responseType` 包含,作为一个 `ArrayBuffer`、`Blob`、`Document`、`JSON` 或字符串的实体主体。这篇文章将展示一些 Ajax I/O 技术。 - [XML](/zh-CN/docs/Glossary/XML) diff --git a/files/zh-cn/webassembly/javascript_interface/compile/index.md b/files/zh-cn/webassembly/javascript_interface/compile_static/index.md similarity index 98% rename from files/zh-cn/webassembly/javascript_interface/compile/index.md rename to files/zh-cn/webassembly/javascript_interface/compile_static/index.md index fa96023f21d61f..75f372c92b7c98 100644 --- a/files/zh-cn/webassembly/javascript_interface/compile/index.md +++ b/files/zh-cn/webassembly/javascript_interface/compile_static/index.md @@ -1,6 +1,6 @@ --- title: WebAssembly.compile() -slug: WebAssembly/JavaScript_interface/compile +slug: WebAssembly/JavaScript_interface/compile_static --- {{WebAssemblySidebar}} {{SeeCompatTable}} diff --git a/files/zh-cn/webassembly/javascript_interface/compilestreaming/index.md b/files/zh-cn/webassembly/javascript_interface/compilestreaming_static/index.md similarity index 97% rename from files/zh-cn/webassembly/javascript_interface/compilestreaming/index.md rename to files/zh-cn/webassembly/javascript_interface/compilestreaming_static/index.md index d09e5f43cfc841..7712cf635f2237 100644 --- a/files/zh-cn/webassembly/javascript_interface/compilestreaming/index.md +++ b/files/zh-cn/webassembly/javascript_interface/compilestreaming_static/index.md @@ -1,6 +1,6 @@ --- title: WebAssembly.compileStreaming() -slug: WebAssembly/JavaScript_interface/compileStreaming +slug: WebAssembly/JavaScript_interface/compileStreaming_static --- {{WebAssemblySidebar}} diff --git a/files/zh-cn/webassembly/javascript_interface/instantiate/index.md b/files/zh-cn/webassembly/javascript_interface/instantiate_static/index.md similarity index 99% rename from files/zh-cn/webassembly/javascript_interface/instantiate/index.md rename to files/zh-cn/webassembly/javascript_interface/instantiate_static/index.md index 42b12fe9762178..6a37cecba9c51c 100644 --- a/files/zh-cn/webassembly/javascript_interface/instantiate/index.md +++ b/files/zh-cn/webassembly/javascript_interface/instantiate_static/index.md @@ -1,6 +1,6 @@ --- title: WebAssembly.instantiate() -slug: WebAssembly/JavaScript_interface/instantiate +slug: WebAssembly/JavaScript_interface/instantiate_static --- {{WebAssemblySidebar}} diff --git a/files/zh-cn/webassembly/javascript_interface/instantiatestreaming/index.md b/files/zh-cn/webassembly/javascript_interface/instantiatestreaming_static/index.md similarity index 98% rename from files/zh-cn/webassembly/javascript_interface/instantiatestreaming/index.md rename to files/zh-cn/webassembly/javascript_interface/instantiatestreaming_static/index.md index d218492e64254a..4afe43422c976f 100644 --- a/files/zh-cn/webassembly/javascript_interface/instantiatestreaming/index.md +++ b/files/zh-cn/webassembly/javascript_interface/instantiatestreaming_static/index.md @@ -1,6 +1,6 @@ --- title: WebAssembly.instantiateStreaming() -slug: WebAssembly/JavaScript_interface/instantiateStreaming +slug: WebAssembly/JavaScript_interface/instantiateStreaming_static --- {{WebAssemblySidebar}} diff --git a/files/zh-cn/webassembly/javascript_interface/module/index.md b/files/zh-cn/webassembly/javascript_interface/module/index.md index 4d075dbfa2170f..99bbd553352b32 100644 --- a/files/zh-cn/webassembly/javascript_interface/module/index.md +++ b/files/zh-cn/webassembly/javascript_interface/module/index.md @@ -25,7 +25,7 @@ slug: WebAssembly/JavaScript_interface/Module ### 将编译后的模块发送到 worker -以下示例将使用 [`WebAssembly.compileStreaming()`](/zh-CN/docs/WebAssembly/JavaScript_interface/compileStreaming) 方法编译 `simple.wasm` 加载后的字节码,并将返回的 `Module` 实例通过 {{domxref("Worker/postMessage", "postMessage()")}} 发送到一个 [worker](/zh-CN/docs/Web/API/Web_Workers_API)。 +以下示例将使用 [`WebAssembly.compileStreaming()`](/zh-CN/docs/WebAssembly/JavaScript_interface/compileStreaming_static) 方法编译 `simple.wasm` 加载后的字节码,并将返回的 `Module` 实例通过 {{domxref("Worker/postMessage", "postMessage()")}} 发送到一个 [worker](/zh-CN/docs/Web/API/Web_Workers_API)。 参见 `index-compile.html` 的[源代码](https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index-compile.html),或[查看在线演示](https://mdn.github.io/webassembly-examples/js-api-examples/index-compile.html)。 @@ -37,7 +37,7 @@ WebAssembly.compileStreaming(fetch("simple.wasm")).then((mod) => ); ``` -Worker 函数 [`wasm_worker.js`](https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js) 定义了模块需要使用的导入对象。然后,该函数会创建一个事件处理器,以接受主线程发送的模块。在接收到模块后,我们使用 [`WebAssembly.instantiate()`](/zh-CN/docs/WebAssembly/JavaScript_interface/instantiate) 方法创建一个它的实例,然后调用其导出的函数。 +Worker 函数 [`wasm_worker.js`](https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js) 定义了模块需要使用的导入对象。然后,该函数会创建一个事件处理器,以接受主线程发送的模块。在接收到模块后,我们使用 [`WebAssembly.instantiate()`](/zh-CN/docs/WebAssembly/JavaScript_interface/instantiate_static) 方法创建一个它的实例,然后调用其导出的函数。 ```js const importObject = { diff --git a/files/zh-cn/webassembly/javascript_interface/table/index.md b/files/zh-cn/webassembly/javascript_interface/table/index.md index d4ac1c32b398de..68aa65776c4f57 100644 --- a/files/zh-cn/webassembly/javascript_interface/table/index.md +++ b/files/zh-cn/webassembly/javascript_interface/table/index.md @@ -51,7 +51,7 @@ const importObj = { }; ``` -最后,我们使用 [`WebAssembly.instantiateStreaming()`](/zh-CN/docs/WebAssembly/JavaScript_interface/instantiateStreaming) 方法加载并实例化一个 Wasm 模块(table2.wasm)。table2.wasm 模块包含两个函数(一个返回 42,另一个返回 83),并将这两个函数分别存储到导入 Table 的 0 号和 1 号元素中(参见[文本表示](https://github.com/mdn/webassembly-examples/blob/main/js-api-examples/table2.wat))。因此,在实例化之后,表的长度仍然是 2,但元素中现在包含了可调用的 [WebAssembly 导出函数](/zh-CN/docs/WebAssembly/Exported_functions),可以通过 JS 调用这些函数。 +最后,我们使用 [`WebAssembly.instantiateStreaming()`](/zh-CN/docs/WebAssembly/JavaScript_interface/instantiateStreaming_static) 方法加载并实例化一个 Wasm 模块(table2.wasm)。table2.wasm 模块包含两个函数(一个返回 42,另一个返回 83),并将这两个函数分别存储到导入 Table 的 0 号和 1 号元素中(参见[文本表示](https://github.com/mdn/webassembly-examples/blob/main/js-api-examples/table2.wat))。因此,在实例化之后,表的长度仍然是 2,但元素中现在包含了可调用的 [WebAssembly 导出函数](/zh-CN/docs/WebAssembly/Exported_functions),可以通过 JS 调用这些函数。 ```js WebAssembly.instantiateStreaming(fetch("table2.wasm"), importObject).then( diff --git a/files/zh-cn/webassembly/javascript_interface/validate/index.md b/files/zh-cn/webassembly/javascript_interface/validate_static/index.md similarity index 94% rename from files/zh-cn/webassembly/javascript_interface/validate/index.md rename to files/zh-cn/webassembly/javascript_interface/validate_static/index.md index dd4d7629bb3e85..8f9e2efc1e8278 100644 --- a/files/zh-cn/webassembly/javascript_interface/validate/index.md +++ b/files/zh-cn/webassembly/javascript_interface/validate_static/index.md @@ -1,6 +1,6 @@ --- title: WebAssembly.validate() -slug: WebAssembly/JavaScript_interface/validate +slug: WebAssembly/JavaScript_interface/validate_static --- {{WebAssemblySidebar}} @@ -41,15 +41,15 @@ fetch("simple.wasm") }); ``` -## Specifications +## 规范 {{Specifications}} -## Browser compatibility +## 浏览器兼容性 {{Compat}} -## See also +## 参见 - [WebAssembly](/zh-CN/docs/WebAssembly) overview page - [WebAssembly concepts](/zh-CN/docs/WebAssembly/Concepts) From 6a1b9093050b21e51942d071b461678173d142d2 Mon Sep 17 00:00:00 2001 From: Jason Ren <40999116+jasonren0403@users.noreply.github.com> Date: Tue, 21 Nov 2023 19:01:00 +0800 Subject: [PATCH 02/93] [zh-cn] update & finish translation of 'keyboard navigable javascript widgets' (#16752) Co-authored-by: A1lo --- .../index.md | 166 +++++++----------- 1 file changed, 61 insertions(+), 105 deletions(-) diff --git a/files/zh-cn/web/accessibility/keyboard-navigable_javascript_widgets/index.md b/files/zh-cn/web/accessibility/keyboard-navigable_javascript_widgets/index.md index 9ce6b9a263a0b5..59626f45c860e2 100644 --- a/files/zh-cn/web/accessibility/keyboard-navigable_javascript_widgets/index.md +++ b/files/zh-cn/web/accessibility/keyboard-navigable_javascript_widgets/index.md @@ -1,105 +1,76 @@ --- -title: 键盘导航的 JavaScript 组件 +title: 键盘导航的 JavaScript 微件 slug: Web/Accessibility/Keyboard-navigable_JavaScript_widgets +l10n: + sourceCommit: 02e06e701230eb5c67caa00fc8d09604a07d5734 --- -### 概况 +网页应用经常使用 JavaScript 来模拟桌面组件,比如菜单、树状视图、富文本以及标签面板等。网页中这些微件通常是由 {{ HTMLElement("div") }} 和 {{ HTMLElement("span") }} 等元素组合而成,并不是原生的,也不会提供对应的桌面组件所拥有的键盘功能。本文档主要描述能让 JavaScript 微件使用键盘访问的技术。 -网页应用经常使用 JavaScript 来模拟桌面组件,比如菜单、树状视图、富文本以及标签面板等。网页中这些组件通常是由 {{ HTMLElement("div") }}和 {{ HTMLElement("span") }} 等元素组合而成,并不是原生的,也不会提供对应的桌面组件所拥有的键盘功能。本文档主要描述能让 JavaScript 组件通过键盘 access 的技术。 +## 利用 tabindex -### 利用 tabindex +默认情况下,当人们使用 tab 键浏览网页时,只有交互式元素(如链接、表单控件)才会被聚焦。通过 `tabindex` [全局属性](/zh-CN/docs/Web/HTML/Global_attributes),作者也可以使其他元素成为焦点。当设置为 `0` 时,元素可通过键盘和脚本聚焦。当设置为 `-1` 时,元素可被脚本聚焦,但不会成为键盘聚焦顺序的一部分。 -最初 tabindex 出现是做为 HTML4 的一部分,提供一种手段让开发人员定义元素的顺序,可以让用户通过键盘按此顺序来获取焦点。最新在 HTML5 草案里面针对 tabindex 的具体行为表现做了改动。所有主流浏览器都已经实现了这个修改后的设计。 +使用键盘时,元素获得焦点的顺序默认为源顺序。在特殊情况下,作者可能希望重新定义顺序。为此,作者可以将 `tabindex` 设置为任意正数。 -下面表格阐述在主流浏览器里面 `tabindex` 的表现: +> **警告:** 避免为 `tabindex` 使用正值。具有正 `tabindex` 值的元素会被放在页面上默认的交互式元素之前,这意味着页面作者在使用一个或多个 `tabindex` 正值时,必须为页面上所有可聚焦元素设置(并维护)`tabindex` 值。 - +下面表格阐述主流浏览器中 `tabindex` 的行为: + +
+ - - - + + - - - + + + - - + +
tabindex 属性 - 可用鼠标或者 用 JavaScript 语句 element.focus() 获取焦点 + 可用鼠标或 JavaScript 语句 element.focus() 获取焦点 可使用 Tab 键导航获取焦点
不存在 -

not present

-

(未设置)

-
- 遵循所在平台针对此元素的默认行为 (yes for form controls, links, etc.). + 遵循所在平台针对此元素的默认行为(表单控件、链接等) 遵循所在平台针对此元素的默认行为
Negative (i.e. tabindex="-1")Yes负值(也就是说,tabindex="-1" - No; 必须通过 - focus() + 否;作者必须使用 focus() 来聚焦该元素。可以在方向键或者其他键的响应里面做。
Zero (i.e. tabindex="0")Yestab 顺序对应于该元素在文档中的位置零(也就是说,tabindex="0"相对于元素在文档中的位置,以 tab 顺序排列(请注意,交互式元素如 {{HTMLElement('a')}} 默认具有这种行为,它们不需要该属性)。
Positive (e.g. tabindex="33")Yes正值(如 tabindex="33" - tabindex 值决定了元素的 tab 顺序:通常这些带有正数值的 - tabindex 元素会排在 tabindex="0"和原生可以 tabable - 的元素前面;特别指出的是值越小越排在前面(举个例子,tabindex="7" - 会排在tabindex="11"前面) + tabindex 值决定了该元素在制表符顺序中的位置:值越小,元素在制表符顺序中的位置就越靠前(例如,tabindex="7" 将位于 tabindex="11" 之前)。
-#### 简单控件 Simple Controls - -可以在 {{ HTMLElement("div") }} or {{ HTMLElement("span") }} 元素上设置 tabindex="0" 使得此简单控件变得可 tab 导航。这里有个 span-based checkbox 使用这个方法的例子。 +### 非原生控件 -_Example 1: A simple image-based checkbox widget using tabindex to allow keyboard access_ - -```html - -
- - - Include decorative fruit basket - -
-
- - - Include singing telegram - -
-
- - - Require payment before delivery - -
-``` +具有交互功能的原生 HTML 元素,如 {{ HTMLElement("a") }}、{{ HTMLElement("input") }} 和 {{ HTMLElement("select") }},已经可以被键盘访问,因此使用其中之一是让组件与键盘配合使用的最快途径。 -#### 组合控件 Grouping controls +作者还可以为 {{ HTMLElement("div") }} 或 {{ HTMLElement("span") }} 添加为 `0` 的 `tabindex` 值,使其可以通过键盘访问。这对于使用 HTML 中不存在的交互式元素的组件尤其有用。 -针对像菜单、标签面板、树等这些组合控件,父元素应该在 tab 序列里面 (tabindex="0") 而每个后代选择/标签/单元/行应该从 tab 序列里面移除 (tabindex="-1")。用户应该可通过方向键来操控这些后代元素。(关于组件一般预期的键盘支持,可以查看 [DHTML Style Guide](http://access.aol.com/dhtml-style-guide-working-group/).) +### 组合控件 -下面这个组合菜单的例子展示了这种技术的使用。一旦键盘 focus 中容器 ul 元素,Javascript 开发人员需要在键盘事件里针对方向键的响应里管理里面元素的 focus 顺序。在组件里管理 focus 的办法,看下面这个 "在组合控件里管理 focus " 例子。 +对于菜单、选项卡列表、网格或树状视图等组合微件,父元素应处于选项卡顺序中(`tabindex="0"`),而每个子选项/选项卡/单元格/行都应从选项卡顺序中移除(`tabindex="-1"`)。用户应能使用箭头键浏览后代元素。(有关典型窗口微件通常需要的键盘支持的完整描述,请参阅 [WAI-ARIA 创作实践](https://www.w3.org/WAI/ARIA/apg/))。 -_范例 2: 一个使用 tabindex 控制键盘 access 的菜单控件_ +下面的示例展示了这种技术在嵌套菜单控件中的应用。一旦键盘焦点落在包含 {{ HTMLElement("ul") }} 的元素上,JavaScript 开发人员就必须以编程方式管理焦点并响应箭头键。有关在微件内管理焦点的技术,请参阅下面的“在组内管理焦点”。 ```html