From ba22b387a827f9b7b9b252817e3f48cdb9fb4a77 Mon Sep 17 00:00:00 2001 From: Hyde Song Date: Sun, 22 Apr 2018 19:14:10 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- .../09-alert-prompt-confirm/article.md | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/article.md b/1-js/02-first-steps/09-alert-prompt-confirm/article.md index 65a4255774..57a6737e69 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/article.md @@ -1,48 +1,48 @@ -# Interaction: alert, prompt, confirm +# 交互:alert, prompt,confirm -This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks. +本部分旨在覆盖 JavaScript “原样”,而无需针对特定环境进行调整。 -But still we use a browser as the demo environment. So we should know at least a few user-interface functions. In this chapter we'll get familiar with the browser functions `alert`, `prompt` and `confirm`. +但我们仍然使用浏览器作为演示环境。所以我们至少应该知道一些用户界面函数。在本章节我们将会熟悉函数 `alert`,`prompt` 和 `confirm` 的用法。 ## alert -Syntax: +语法: ```js alert(message); ``` -This shows a message and pauses the script execution until the user presses "OK". +浏览器会弹出一段信息并暂停脚本,直到用户点击了 “确定”。 -For example: +举个例子: ```js run alert("Hello"); ``` -The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons etc, until they have dealt with the window. In this case -- until they press "OK". +这个小窗口被称为 *模态窗*。“modal” 意味着用户不能与页面的其他部分进行交互,按其他按钮等,直到他们处理完窗口。 在这种情况下 - 直到他们按下“确定”。 ## prompt -Function `prompt` accepts two arguments: +`prompt` 函数接收两个参数: ```js no-beautify result = prompt(title[, default]); ``` -It shows a modal window with a text message, an input field for the visitor and buttons OK/CANCEL. +浏览器会显示一个带有文本消息的模态窗口,还有 input 框和确定/取消按钮。 `title` -: The text to show to the visitor. +:显示给用户的文本 `default` -: An optional second parameter, the initial value for the input field. +:可选的第二个参数,指定 input 框的初始值。 -The visitor may type something in the prompt input field and press OK. Or they can cancel the input by pressing the CANCEL button or hitting the `key:Esc` key. +用户在 prompt 对话框的 input 框输入文本并点击确定。不然就点击取消按钮或敲击 `key:Esc` 键来取消。 -The call to `prompt` returns the text from the field or `null` if the input was canceled. +`prompt` 返回输入的文本;如果点击确定就返回 `null`。 -For instance: +举个例子: ```js run let age = prompt('How old are you?', 100); @@ -51,15 +51,15 @@ alert(`You are ${age} years old!`); // You are 100 years old! ``` ````warn header="IE: always supply a `default`" -The second parameter is optional. But if we don't supply it, Internet Explorer would insert the text `"undefined"` into the prompt. +第二个参数可选。但是如果我们不提供的话,Internet Explorer 会把 `"undefined"` 插入到 prompt。 -Run this code in Internet Explorer to see that: +在 Internet Explorer 中运行将会看到: ```js run let test = prompt("Test"); ``` -So, to look good in IE, it's recommended to always provide the second argument: +所以,在 IE 中看起来很好,建议始终提供第二个参数: ```js run let test = prompt("Test", ''); // <-- for IE @@ -68,17 +68,17 @@ let test = prompt("Test", ''); // <-- for IE ## confirm -The syntax: +语法: ```js result = confirm(question); ``` -Function `confirm` shows a modal window with a `question` and two buttons: OK and CANCEL. +`confirm` 函数显示一个带有 `question` 和两个按钮的模态窗口:确定和取消。 -The result is `true` if OK is pressed and `false` otherwise. +点击确定返回 `true`,点击取消返回 `false`。 -For example: +举一个例子: ```js run let isBoss = confirm("Are you the boss?"); @@ -86,24 +86,24 @@ let isBoss = confirm("Are you the boss?"); alert( isBoss ); // true if OK is pressed ``` -## Summary +## 总结 -We covered 3 browser-specific functions to interact with the visitor: +我们探讨了与用户交互的 3 个浏览器指定的函数: `alert` -: shows a message. +:显示信息 `prompt` -: shows a message asking the user to input text. It returns the text or, if CANCEL or `key:Esc` is clicked, all browsers return `null`. +:显示信息要求用户输入文本。点击确定返回文本,或者点击取消或按下 `key:Esc` 键,返回 `null`。 `confirm` -: shows a message and waits for the user to press "OK" or "CANCEL". It returns `true` for OK and `false` for CANCEL/`key:Esc`. +:显示信息等待用户点击确定或取消。点击确定返回 `true`,点击取消或 `key:Esc` 键返回 `false`。 -All these methods are modal: they pause the script execution and don't allow the visitor to interact with the rest of the page until the message has been dismissed. +这些方法都是模态的:它们暂停脚本执行,并且不允许用户与该页面的其余部分交互,直到消息被解除。 -There are two limitations shared by all the methods above: +上述所有方法共有两个限制: -1. The exact location of the modal window is determined by the browser. Usually it's in the center. -2. The exact look of the window also depends on the browser. We can't modify it. +1. 模态窗口的确切位置由浏览器决定。 通常它在页面中心。 +2. 窗口的确切外观还取决于浏览器。 我们不能修改它。 -That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine. +这是简单的代价。 还有其他一些方法可以显示更漂亮的窗口,并与用户进行更丰富的交互,但如果“花里胡哨”不重要,这些方法就可以正常工作。 From 108dc6dcc8c26bda2e5864c0441faeeb9ec2168d Mon Sep 17 00:00:00 2001 From: Hyde Song Date: Sun, 22 Apr 2018 19:14:39 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- .../09-alert-prompt-confirm/1-simple-page/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/solution.md b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/solution.md index 903ee7ff35..0d7930aa57 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/solution.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/solution.md @@ -1,11 +1,11 @@ -JavaScript-code: +JavaScript 代码: ```js demo run let name = prompt("What is your name?", ""); alert(name); ``` -The full page: +整个页面的代码: ```html From 8a98ba6b76ed6ed355b90f60a4600ab30603a1e4 Mon Sep 17 00:00:00 2001 From: Hyde Song Date: Sun, 22 Apr 2018 19:15:08 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- .../09-alert-prompt-confirm/1-simple-page/task.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md index a65a654e05..7c82d42884 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md @@ -1,9 +1,8 @@ -importance: 4 +重要:4 --- -# A simple page - -Create a web-page that asks for a name and outputs it. +# 创建简单页面 +创建一页 web 页面,输入 name 并输出它。 [demo] From 267c4f44a6cb461526baa4d855e14b70991ed4c7 Mon Sep 17 00:00:00 2001 From: Hyde Song Date: Mon, 23 Apr 2018 09:40:05 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=A0=A1=E5=AF=B9?= =?UTF-8?q?=E8=80=85=E4=B8=80=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据校对者一件修改 --- .../09-alert-prompt-confirm/article.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/article.md b/1-js/02-first-steps/09-alert-prompt-confirm/article.md index 57a6737e69..b0ab0fc17e 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/article.md @@ -1,8 +1,8 @@ -# 交互:alert, prompt,confirm +# 交互:alert、prompt、confirm -本部分旨在覆盖 JavaScript “原样”,而无需针对特定环境进行调整。 +本部分旨在覆盖 JavaScript “原生”,而无需针对特定环境进行调整。 -但我们仍然使用浏览器作为演示环境。所以我们至少应该知道一些用户界面函数。在本章节我们将会熟悉函数 `alert`,`prompt` 和 `confirm` 的用法。 +但我们仍然使用浏览器作为演示环境。所以我们至少应该知道一些用户界面函数。在本章节我们将会熟悉函数 `alert`、`prompt` 和 `confirm` 的用法。 ## alert @@ -12,7 +12,7 @@ alert(message); ``` -浏览器会弹出一段信息并暂停脚本,直到用户点击了 “确定”。 +浏览器会弹出一段信息并暂停脚本,直到用户点击了“确定”。 举个例子: @@ -20,7 +20,7 @@ alert(message); alert("Hello"); ``` -这个小窗口被称为 *模态窗*。“modal” 意味着用户不能与页面的其他部分进行交互,按其他按钮等,直到他们处理完窗口。 在这种情况下 - 直到他们按下“确定”。 +这个小窗口被称为 **模态窗**。“modal” 意味着用户不能与页面的其他部分进行交互,点击其他按钮等,直到他们处理完窗口。在这种情况下 - 直到他们按下“确定”。 ## prompt @@ -40,7 +40,7 @@ result = prompt(title[, default]); 用户在 prompt 对话框的 input 框输入文本并点击确定。不然就点击取消按钮或敲击 `key:Esc` 键来取消。 -`prompt` 返回输入的文本;如果点击确定就返回 `null`。 +`prompt` 返回输入的文本;如果取消输入就返回 `null`。 举个例子: @@ -94,7 +94,7 @@ alert( isBoss ); // true if OK is pressed :显示信息 `prompt` -:显示信息要求用户输入文本。点击确定返回文本,或者点击取消或按下 `key:Esc` 键,返回 `null`。 +:显示信息要求用户输入文本。点击确定返回文本,或者点击取消或按下 `key:Esc` 键,对于所有浏览器来说,其返回值都是。 `confirm` :显示信息等待用户点击确定或取消。点击确定返回 `true`,点击取消或 `key:Esc` 键返回 `false`。 @@ -103,7 +103,7 @@ alert( isBoss ); // true if OK is pressed 上述所有方法共有两个限制: -1. 模态窗口的确切位置由浏览器决定。 通常它在页面中心。 -2. 窗口的确切外观还取决于浏览器。 我们不能修改它。 +1. 模态窗口的确切位置由浏览器决定。通常在页面中心。 +2. 窗口的确切外观还取决于浏览器。我们不能修改它。 -这是简单的代价。 还有其他一些方法可以显示更漂亮的窗口,并与用户进行更丰富的交互,但如果“花里胡哨”不重要,这些方法就可以正常工作。 +这是简单的代价。还有其他一些方法可以显示更漂亮的窗口,并与用户进行更丰富的交互,但如果“花里胡哨”不是非常重要,这些方法也可以工作的很好。 From d7d9c5fd73d3e4aec04a40325035d80489aa4b78 Mon Sep 17 00:00:00 2001 From: Hyde Song Date: Mon, 23 Apr 2018 20:48:25 +0800 Subject: [PATCH 5/8] Update task.md --- .../09-alert-prompt-confirm/1-simple-page/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md index 7c82d42884..d2467d61d5 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md @@ -1,4 +1,4 @@ -重要:4 +重要程度:4 --- From 45d1074978709fe3e92cca1ceb8f60e02d809be3 Mon Sep 17 00:00:00 2001 From: Hyde Song Date: Mon, 23 Apr 2018 20:52:11 +0800 Subject: [PATCH 6/8] Update article.md --- .../09-alert-prompt-confirm/article.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/article.md b/1-js/02-first-steps/09-alert-prompt-confirm/article.md index b0ab0fc17e..b06401feda 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/article.md @@ -20,7 +20,7 @@ alert(message); alert("Hello"); ``` -这个小窗口被称为 **模态窗**。“modal” 意味着用户不能与页面的其他部分进行交互,点击其他按钮等,直到他们处理完窗口。在这种情况下 - 直到他们按下“确定”。 +这个小窗口被称为 **模态窗**。"modal" 意味着用户不能与页面的其他部分进行交互,点击其他按钮等,直到他们处理完窗口。在这种情况下 - 直到他们按下“确定”。 ## prompt @@ -33,10 +33,10 @@ result = prompt(title[, default]); 浏览器会显示一个带有文本消息的模态窗口,还有 input 框和确定/取消按钮。 `title` -:显示给用户的文本 +: 显示给用户的文本 `default` -:可选的第二个参数,指定 input 框的初始值。 +: 可选的第二个参数,指定 input 框的初始值。 用户在 prompt 对话框的 input 框输入文本并点击确定。不然就点击取消按钮或敲击 `key:Esc` 键来取消。 @@ -91,13 +91,13 @@ alert( isBoss ); // true if OK is pressed 我们探讨了与用户交互的 3 个浏览器指定的函数: `alert` -:显示信息 +: 显示信息 `prompt` -:显示信息要求用户输入文本。点击确定返回文本,或者点击取消或按下 `key:Esc` 键,对于所有浏览器来说,其返回值都是。 +: 显示信息要求用户输入文本。点击确定返回文本,或者点击取消或按下 `key:Esc` 键,对于所有浏览器来说,其返回值都是。 `confirm` -:显示信息等待用户点击确定或取消。点击确定返回 `true`,点击取消或 `key:Esc` 键返回 `false`。 +: 显示信息等待用户点击确定或取消。点击确定返回 `true`,点击取消或 `key:Esc` 键返回 `false`。 这些方法都是模态的:它们暂停脚本执行,并且不允许用户与该页面的其余部分交互,直到消息被解除。 From 11146468b3ee9ad31d078fa68e7111a2f3a7225c Mon Sep 17 00:00:00 2001 From: LeviDing Date: Mon, 23 Apr 2018 22:21:48 +0800 Subject: [PATCH 7/8] Update task.md --- .../09-alert-prompt-confirm/1-simple-page/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md index d2467d61d5..d60226996f 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md @@ -1,4 +1,4 @@ -重要程度:4 +importance: 4 --- From 1b429c456f221db0e6b3ea3bf93fc518a1764e71 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Mon, 23 Apr 2018 22:23:20 +0800 Subject: [PATCH 8/8] Update article.md --- 1-js/02-first-steps/09-alert-prompt-confirm/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/article.md b/1-js/02-first-steps/09-alert-prompt-confirm/article.md index b06401feda..0d24fe3655 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/article.md @@ -91,7 +91,7 @@ alert( isBoss ); // true if OK is pressed 我们探讨了与用户交互的 3 个浏览器指定的函数: `alert` -: 显示信息 +: 显示信息。 `prompt` : 显示信息要求用户输入文本。点击确定返回文本,或者点击取消或按下 `key:Esc` 键,对于所有浏览器来说,其返回值都是。