|
1 | 1 | # Interaction: alert, prompt, confirm |
2 | | - |
3 | | -As we'll be using the browser as our demo environment, let's see a couple of functions to interact with the user: `alert`, `prompt` and `confirm`. |
| 2 | +ബ്രൗസർ നമ്മൾ ഒരു Demo environment ആയി ഉപയോഗിക്കുന്നതിനാൽ,user-നോട് interact ചെയ്യാൻ കുറച്ച് functions നോക്കാം: `alert`, `prompt`, പിന്നെ `confirm`. |
4 | 3 |
|
5 | 4 | ## alert |
6 | 5 |
|
7 | | -This one we've seen already. It shows a message and waits for the user to press "OK". |
| 6 | +ഇത് നമ്മൾ ഇതിനകം തന്നെ കണ്ടിട്ടുണ്ട്. ഇത് ഒരു alert കാണിക്കുകയും user "OK" അമർത്തുന്നതിനായി കാത്തിരിക്കുകയും ചെയ്യുന്നു. |
8 | 7 |
|
9 | | -For example: |
| 8 | +ഉദാഹരണത്തിന്: |
10 | 9 |
|
11 | 10 | ```js run |
12 | 11 | alert("Hello"); |
13 | 12 | ``` |
14 | 13 |
|
15 | | -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". |
| 14 | +alertനോട് കൂടെയുള്ള മിനി-വിൻഡോയെ *modal window* എന്ന് വിളിക്കുന്നു . "modal" എന്ന വാക്കിന്റെ അർത്ഥം, വിൻഡോ കൈകാര്യം ചെയ്യുന്നതുവരെ user ന് പേജിന്റെ ബാക്കി ഭാഗങ്ങളുമായി സംവദിക്കുക, മറ്റ് ബട്ടണുകൾ അമർത്തുക, മുതലായവ പറ്റില്ല. അതായത് 'OK' ഞെക്കുന്നത് വരെ. |
16 | 15 |
|
17 | 16 | ## prompt |
18 | 17 |
|
19 | | -The function `prompt` accepts two arguments: |
| 18 | +Function `prompt` രണ്ട് arguments സ്വീകരിക്കുന്നു: |
20 | 19 |
|
21 | 20 | ```js no-beautify |
22 | 21 | result = prompt(title, [default]); |
23 | 22 | ``` |
24 | 23 |
|
25 | | -It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel. |
| 24 | +ഇത് ഒരു text message ഉം സന്ദർശകനുള്ള ഇൻപുട്ട് ഫീൽഡും OK/Cancel ബട്ടണുകളും ഉള്ള ഒരു modal window കാണിക്കുന്നു. |
26 | 25 |
|
27 | 26 | `title` |
28 | | -: The text to show the visitor. |
| 27 | +: സന്ദർശകനെ കാണിക്കാനുള്ള text. |
29 | 28 |
|
30 | 29 | `default` |
31 | | -: An optional second parameter, the initial value for the input field. |
| 30 | +: ഒരു optional second parameter, ഇൻപുട്ട് ഫീൽഡിന്റെ initial value. |
32 | 31 |
|
33 | | -```smart header="The square brackets in syntax `[...]`" |
34 | | -The square brackets around `default` in the syntax above denote that the parameter is optional, not required. |
| 32 | +```smart header="syntax ഇൽ ഉള്ള square bracket `[...]`" |
| 33 | +മുകളിലുള്ള syntax ന്റെ `default` ന് ചുറ്റുമുള്ള square ബ്രാക്കറ്റുകൾ, parameter ഓപ്ഷണൽ ആണെന്ന് സൂചിപ്പിക്കുന്നു,നമുക്ക് വേണമെങ്കിൽ മതി.ഇതിന്റെ ആവശ്യമില്ല. |
35 | 34 | ``` |
36 | 35 |
|
37 | | -The visitor can type something in the prompt input field and press OK. Then we get that text in the `result`. Or they can cancel the input by pressing Cancel or hitting the `key:Esc` key, then we get `null` as the `result`. |
38 | | -
|
39 | | -The call to `prompt` returns the text from the input field or `null` if the input was canceled. |
| 36 | +User ന് prompt ഇൻപുട്ട് ഫീൽഡിൽ എന്തെങ്കിലും ടൈപ്പ് ചെയ്ത് OK അമർത്താം. അപ്പോൾ ആ text നമുക്ക് `result` ൽ ലഭിക്കും. Cancel അമർത്തുന്നതിലൂടെ അവർക്ക് ഇൻപുട്ട് cancel ചെയ്യാനും പറ്റും, `key:Esc` കീ അമർത്തുന്നതിലൂടെ, നമുക്ക് `result`ൽ `null` ലഭിക്കും. |
40 | 37 |
|
41 | | -For instance: |
| 38 | +`prompt` ലേക്കുള്ള കോൾ, ഇൻപുട്ട് ഫീൽഡിൽ നിന്ന് text return ചെയ്യും. ഇൻപുട്ട് cancel ആക്കുകയാണെങ്കിൽ `null` return ചെയ്യും. |
| 39 | +ഉദാഹരണത്തിന്: |
42 | 40 |
|
43 | 41 | ```js run |
44 | 42 | let age = prompt('How old are you?', 100); |
45 | 43 |
|
46 | 44 | alert(`You are ${age} years old!`); // You are 100 years old! |
47 | 45 | ``` |
48 | 46 |
|
49 | | -````warn header="In IE: always supply a `default`" |
50 | | -The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt. |
51 | | - |
52 | | -Run this code in Internet Explorer to see: |
| 47 | +````warn header="IE ൽ: എപ്പോഴും `default` കൊടുക്കുക" |
| 48 | +രണ്ടാമത്തെ parameter ഓപ്ഷണൽ ആണ്, പക്ഷേ നമ്മൾ അത് നൽകുന്നില്ലെങ്കിൽ, Internet Explorer `"undefined"` എന്ന് text promptൽ ചേർക്കും. |
53 | 49 |
|
| 50 | +ഇത് കാണാൻ Internet Explorer(IE)ൽ ഈ കോഡ് run ചെയ്യുക: |
54 | 51 | ```js run |
55 | 52 | let test = prompt("Test"); |
56 | 53 | ``` |
57 | 54 |
|
58 | | -So, for prompts to look good in IE, we recommend always providing the second argument: |
59 | | - |
| 55 | +അതിനാൽ, IE- ൽ നന്നായി കാണുന്നതിന്, രണ്ടാമത്തെ argument എല്ലായ്പ്പോഴും നൽകുക: |
60 | 56 | ```js run |
61 | | -let test = prompt("Test", ''); // <-- for IE |
| 57 | +let test = prompt("Test", ''); // <-- IE ൽ |
62 | 58 | ``` |
63 | 59 | ```` |
64 | 60 |
|
65 | 61 | ## confirm |
66 | 62 |
|
67 | | -The syntax: |
| 63 | +syntax: |
68 | 64 |
|
69 | 65 | ```js |
70 | 66 | result = confirm(question); |
71 | 67 | ``` |
72 | 68 |
|
73 | | -The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel. |
74 | | -
|
75 | | -The result is `true` if OK is pressed and `false` otherwise. |
76 | | -
|
77 | | -For example: |
| 69 | +`confirm` function ൽ, ഒരു ചോദ്യവും, OK and Cancel ഉള്ള രണ്ട് ബട്ടണുകളും ഒരു modal വിൻഡോയും ആണ് കാണുന്നത്. |
| 70 | +OK അമർത്തിയാൽ `true` കിട്ടും, അല്ലാത്തപക്ഷം`false`. |
| 71 | +ഉദാഹരണത്തിന്: |
78 | 72 |
|
79 | 73 | ```js run |
80 | 74 | let isBoss = confirm("Are you the boss?"); |
81 | 75 |
|
82 | 76 | alert( isBoss ); // true if OK is pressed |
83 | 77 | ``` |
84 | 78 |
|
85 | | -## Summary |
| 79 | +## സംഗ്രഹം |
86 | 80 |
|
87 | | -We covered 3 browser-specific functions to interact with visitors: |
| 81 | +സന്ദർശകരുമായി സംവദിക്കാൻ ഞങ്ങൾ 3 browser-specific പ്രവർത്തനങ്ങൾ ഉൾപ്പെടുത്തി: |
88 | 82 |
|
89 | 83 | `alert` |
90 | | -: shows a message. |
| 84 | +: ഒരു സന്ദേശം കാണിക്കുന്നു. |
91 | 85 |
|
92 | 86 | `prompt` |
93 | | -: shows a message asking the user to input text. It returns the text or, if Cancel button or `key:Esc` is clicked, `null`. |
| 87 | +: ടെക്സ്റ്റ് ഇൻപുട്ട് ചെയ്യാൻ ഉപയോക്താവിനോട് ആവശ്യപ്പെടുന്ന ഒരു സന്ദേശം കാണിക്കുന്നു. ഇത് text return നൽകുന്നു അല്ലെങ്കിൽ, Cancel ബട്ടൺ, `key: Esc` ക്ലിക്ക് ചെയ്തിട്ടുണ്ടെങ്കിൽ,` null` return ചെയ്യും. |
94 | 88 |
|
95 | 89 | `confirm` |
96 | | -: shows a message and waits for the user to press "OK" or "Cancel". It returns `true` for OK and `false` for Cancel/`key:Esc`. |
97 | | -
|
98 | | -All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed. |
| 90 | +: ഒരു സന്ദേശം കാണിക്കുകയും ഉപയോക്താവ് "OK" അല്ലെങ്കിൽ "Cancel" അമർത്തുന്നതിനായി കാത്തിരിക്കുകയും ചെയ്യുന്നു.ഇത് OK എന്നതിന് `true`, Cancel/`key:Esc` എന്നതിന് `false` എന്നിവ നൽകുന്നു. |
99 | 91 |
|
100 | | -There are two limitations shared by all the methods above: |
| 92 | +ഈ രീതികളെല്ലാം modal ആണ്: അവർ സ്ക്രിപ്റ്റ് execution താൽക്കാലികമായി നിർത്തി, വിൻഡോ dismiss ചെയ്യുന്നതുവരെ സന്ദർശകനെ ബാക്കി പേജുമായി സംവദിക്കാൻ അനുവദിക്കുന്നില്ല. |
101 | 93 |
|
102 | | -1. The exact location of the modal window is determined by the browser. Usually, it's in the center. |
103 | | -2. The exact look of the window also depends on the browser. We can't modify it. |
| 94 | +മുകളിലുള്ള എല്ലാ രീതികളിലും common ആയി രണ്ട് പരിമിതികളുണ്ട്: |
| 95 | +1. modal വിൻഡോയുടെ കൃത്യമായ സ്ഥാനം ബ്രൗസർ നിർണ്ണയിക്കുന്നു. സാധാരണയായി, അത് നടുവിലായിട്ടാണ്. |
| 96 | +2. വിൻഡോയുടെ കൃത്യമായ രൂപവും ബ്രൗസറിനെ ആശ്രയിച്ചിരിക്കുന്നു. നമ്മൾക്ക് അത് modify ചെയ്യാൻ കഴിയില്ല. |
104 | 97 |
|
105 | | -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. |
| 98 | +User മായി ഇടപെടലുകൾ കാണിക്കാൻ ഇതിലും നല്ല മറ്റ് വഴികളുണ്ട്, പക്ഷേ നിസാരമായ ഈ പരിമിതികൾ നമ്മൾ കാര്യമാക്കുന്നില്ലെങ്കിൽ, ഈ 3 രീതികൾ തന്നെ നമുക്ക് ധാരാളം. |
0 commit comments